Created
November 5, 2019 02:22
-
-
Save Pilaba/07355af22b4b66e0b5a708f8a954b457 to your computer and use it in GitHub Desktop.
Add new custom control on top of google map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var centerControlDiv = document.createElement('div') | |
var centerControl = new CenterControl(centerControlDiv, map) | |
centerControlDiv.index = 1 | |
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(centerControlDiv) | |
//Custom google map view | |
function CenterControl(controlDiv, map) { | |
// Set CSS for the control border. | |
var controlUI = document.createElement('div'); | |
controlUI.setAttribute("id", "clearMap"); | |
controlUI.style.backgroundColor = '#fff'; | |
controlUI.style.border = '2px solid #fff'; | |
controlUI.style.borderRadius = '3px'; | |
controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)'; | |
controlUI.style.cursor = 'pointer'; | |
controlUI.style.margin = '10px'; | |
controlUI.style.textAlign = 'center'; | |
controlUI.title = 'Click para limpiar el mapa'; | |
controlDiv.appendChild(controlUI); | |
// Set CSS for the control interior. | |
var controlText = document.createElement('div'); | |
controlText.style.color = 'rgb(173, 12, 4)'; | |
controlText.style.fontFamily = 'Roboto,Arial,sans-serif'; | |
controlText.style.fontSize = '16px'; | |
controlText.style.lineHeight = '38px'; | |
controlText.style.paddingLeft = '5px'; | |
controlText.style.paddingRight = '5px'; | |
controlText.innerHTML = 'Prueba XD'; | |
controlUI.appendChild(controlText); | |
// Setup the click event listeners: simply set the map to Chicago. | |
controlUI.addEventListener('click', function() { | |
console.log("click in") | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment