[120] | 1 | function TextualZoomControl() { |
---|
| 2 | } |
---|
| 3 | |
---|
| 4 | TextualZoomControl.prototype = new GControl(); |
---|
| 5 | |
---|
| 6 | // Creates a one DIV for each of the buttons and places them in a container |
---|
| 7 | // DIV which is returned as our control element. |
---|
| 8 | TextualZoomControl.prototype.initialize = function(map) { |
---|
| 9 | var container = document.createElement("div"); |
---|
| 10 | |
---|
| 11 | // "Zoom In" button |
---|
| 12 | var zoomInDiv = document.createElement("div"); |
---|
| 13 | this.setButtonStyle_(zoomInDiv); |
---|
| 14 | container.appendChild(zoomInDiv); |
---|
| 15 | zoomInDiv.appendChild(document.createTextNode("Zoom In")); |
---|
| 16 | // The "true" argument in the zoomIn() method allows continuous zooming |
---|
| 17 | GEvent.addDomListener(zoomInDiv, "click", function() {map.zoomIn(null,null,true);} ); |
---|
| 18 | |
---|
| 19 | // "Zoom Out" button |
---|
| 20 | var zoomOutDiv = document.createElement("div"); |
---|
| 21 | this.setButtonStyle_(zoomOutDiv); |
---|
| 22 | zoomOutDiv.style.borderTop = 0+'px'; |
---|
| 23 | container.appendChild(zoomOutDiv); |
---|
| 24 | zoomOutDiv.appendChild(document.createTextNode("Zoom Out")); |
---|
| 25 | // The "true" argument in the zoomOut() method allows continuous zooming |
---|
| 26 | GEvent.addDomListener(zoomOutDiv, "click", function() {map.zoomOut(null,true);} ); |
---|
| 27 | |
---|
| 28 | // We add the control to to the map container and return the element |
---|
| 29 | // for the map class to position properly. |
---|
| 30 | |
---|
| 31 | map.getContainer().appendChild(container); |
---|
| 32 | return container; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | // The control will appear in the top left corner of the map with 7 pixels of padding. |
---|
| 37 | TextualZoomControl.prototype.getDefaultPosition = function() { |
---|
| 38 | return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(15, 7)); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | // Sets the proper CSS for the given button element. |
---|
| 42 | TextualZoomControl.prototype.setButtonStyle_ = function(button) { |
---|
| 43 | button.style.textDecoration = "none"; |
---|
| 44 | button.style.color = "black"; |
---|
| 45 | button.style.backgroundColor = "white"; |
---|
| 46 | // button.style.font = "12px Verdana bold"; |
---|
| 47 | button.style.fontFamily = "Verdana"; |
---|
| 48 | button.style.fontSize = "12px"; |
---|
| 49 | button.style.fontWeight= "bold"; |
---|
| 50 | button.style.border = "1px solid gray"; |
---|
| 51 | button.style.padding = "0px"; |
---|
| 52 | button.style.marginBottom = "0px"; |
---|
| 53 | button.style.textAlign = "center"; |
---|
| 54 | button.style.width = "7em"; |
---|
| 55 | button.style.height = "15px"; |
---|
| 56 | button.style.cursor = "pointer"; |
---|
| 57 | } |
---|
| 58 | |
---|