Hello, please help me with an example of how to do when the user clicks a button next to the map to have the map zoom in to show the entire country.
I could not make a practical example. I think with this information you can understand what I want.
Hello, please help me with an example of how to do when the user clicks a button next to the map to have the map zoom in to show the entire country.
I could not make a practical example. I think with this information you can understand what I want.
HTML:
<input type="button" value="Brasil" id="moveToBrasil" /><br>
<div id="googleMap" style="width:500px;height:380px;"></div>
JavaScript:
var map;
function initialize() {
var mapProp = {
center:new google.maps.LatLng(45,19),
zoom:3,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
$('#moveToBrasil').click(function(){
map.setCenter(new google.maps.LatLng( -14.235004 , -51.92528 ) );
});
JSFiddle:
References: