i\'am a beginner in GMaps API and javascript, so this should be an easy question for you that are really experts. I have started to \"play around\" with the API, and wanted
Your problem is that the cambiarZOOM
function and map
variable are only accessible within the scope of the initialize function. To use a function on an onclick event, either it has to be available globally (this is discouraged), or you have to attach the function to the button while the function is in scope.
If you give your button an id (id='zoomButton'
), you can attach cambiarZOOM
within the initialize function like so:
...
function cambiarZOOM(nro) {
var newZ = ez + nro;
map.setZoom(newZ);
}
}
var button = document.getElementById('zoomButton');
button.onclick = function () { cambiarZOOM(5); };