function CustomTypeControl() { } CustomTypeControl.prototype = new GControl(); // Creates a one DIV for each of the buttons and places them in a container // DIV which is returned as our control element. We add the control to // to the map container and return the element for the map class to // position properly. CustomTypeControl.prototype.initialize = function(map) { var container = document.createElement("div"); var mapDiv = document.createElement("div"); this.setButtonStyle_(mapDiv); container.appendChild(mapDiv); mapDiv.appendChild(document.createTextNode("Map")); GEvent.addDomListener(mapDiv, "click", function() { this.style.backgroundColor = "#E6EDF0"; this.style.fontWeight = "bold"; this.style.color = "black" ; satelliteDiv.style.backgroundColor = "white"; satelliteDiv.style.fontWeight = "normal"; satelliteDiv.style.color = "#1D4E6B" ; hybridDiv.style.backgroundColor = "white"; hybridDiv.style.fontWeight = "normal"; hybridDiv.style.color = "#1D4E6B" ; map.setMapType(G_NORMAL_MAP); }); var satelliteDiv = document.createElement("div"); this.setButtonStyle_(satelliteDiv); container.appendChild(satelliteDiv); satelliteDiv.appendChild(document.createTextNode("Satellite")); satelliteDiv.style.backgroundColor = "#E6EDF0"; satelliteDiv.style.fontWeight = "bold"; GEvent.addDomListener(satelliteDiv, "click", function() { this.style.backgroundColor = "#E6EDF0"; this.style.fontWeight = "bold"; this.style.color = "black" ; mapDiv.style.backgroundColor = "white"; mapDiv.style.fontWeight = "normal"; mapDiv.style.color = "#1D4E6B" ; hybridDiv.style.backgroundColor = "white"; hybridDiv.style.fontWeight = "normal"; hybridDiv.style.color = "#1D4E6B" ; map.setMapType(G_SATELLITE_MAP); }); var hybridDiv = document.createElement("div"); this.setButtonStyle_(hybridDiv); container.appendChild(hybridDiv); hybridDiv.appendChild(document.createTextNode("Hybrid")); GEvent.addDomListener(hybridDiv, "click", function() { this.style.backgroundColor = "#E6EDF0"; this.style.fontWeight = "bold"; this.style.color = "black" ; satelliteDiv.style.backgroundColor = "white"; satelliteDiv.style.fontWeight = "normal"; satelliteDiv.style.color = "#1D4E6B" ; mapDiv.style.backgroundColor = "white"; mapDiv.style.fontWeight = "normal"; mapDiv.style.color = "#1D4E6B" ; map.setMapType(G_HYBRID_MAP); }); map.getContainer().appendChild(container); currentMapType = map.getCurrentMapType().getName() ; if (currentMapType == "Satellite") { GEvent.trigger(satelliteDiv, "click") ; } else if (currentMapType == "Hybrid") { GEvent.trigger(hybridDiv, "click") ; } else if (currentMapType == "Map") { GEvent.trigger(mapDiv, "click") ; } return container; } // Position container div CustomTypeControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(3, 5)); } // Sets the proper CSS for the given button element. CustomTypeControl.prototype.setButtonStyle_ = function(button) { button.style.backgroundColor = "white"; button.style.fontFamily = "Verdana"; button.style.fontSize = "11px"; button.style.border = "1px solid black"; button.style.padding = "4px"; button.style.marginTop = "2px"; button.style.marginRight = "2px"; button.style.cssFloat = "left"; button.style.styleFloat = "left"; button.style.textAlign = "center"; button.style.width = "60px"; button.style.cursor = "pointer"; }