Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  25] [ 6]  / answers: 1 / hits: 65429  / 12 Years ago, mon, september 17, 2012, 12:00:00
function displayMapAndClick ()
{
var latlng = new google.maps.LatLng (29.0167, 77.3833);
var myOptions =
{
zoom:zm,
center:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

map = new google.maps.Map (document.getElementById ("map"), myOptions);
directionsDisplay.setMap (map);
}

Where zm is a global variable set to default 7.


Now, I wish to change the zoom level of this map thorough this program.


What is the way to do that without re-initializing the map, or is re-initializing the map compulsory?


More From » google-maps

 Answers
8

Use the setZoom() method from the google.maps.Map class.



var mapOptions = {
/* Initial zoom level */
zoom: 8
...
};
map = new google.maps.Map(..., mapOptions);
/* Change zoom level to 12 */
map.setZoom(12);

[#83048] Saturday, September 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleyi

Total Points: 121
Total Questions: 100
Total Answers: 109

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;