Wednesday, 18 September 2013

In Google Maps Api, change zoom with html tag event. BEGGINER

In Google Maps Api, change zoom with html tag event. BEGGINER

i'am a begginer 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 to try a simple thing, but I couldn't make it! I
have look around for the answer, but I didn't get it. I have created the
map:
<script type="text/javascript">
function initialize() {
//CREATE THE MAP
var mapOptions = {
center: new google.maps.LatLng(-35.8190,-61.9010),
zoom: 15,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
//GET THE ZOOM
var ez = map.getZoom();
//TRYING TO CHANGE ZOOM FROM EXTERNAL LINK (DOESN'T WORK)
function cambiarZOOM(nro) {
var newZ = ez + nro;
map.setZoom(newZ);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Now, the HTML:
<html><body onload="initialize()">
<input type="button" onclick="cambiarZOOM(5)" value="CAMBIAR ZOOM">
</body></html>
Well, now I'am reading about google.maps.trigger(); but I'm not getting
it. I will apreciate a lot your answer!. THANK YOU!

No comments:

Post a Comment