Click button zoom in to show the entire country (Brazil) on Google Maps

1

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.

    
asked by anonymous 19.10.2015 / 19:43

1 answer

1

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:

link

References:

link

    
19.10.2015 / 20:42