Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google map zoom out limit [duplicate]

How do I set zoom out limit on the map, it currently lets me zoom out too far to the point that I see multiple world maps: zoom out limit too far

JS:

var map;  var all_coor = <?php echo json_encode($addresses); ?>; var dub = <?php echo json_encode($testadd); ?>;  function initialize() { var MainLatlng = new google.maps.LatLng(-74.337724,-49.69693);    var mapOptions = {     zoom: 7,     center: new google.maps.LatLng(31.386692,-12.700747)   };   map = new google.maps.Map(document.getElementById('map-canvas'),       mapOptions);   var markerr = new google.maps.Marker({       position: MainLatlng ,       map: map,       title: 'Main',       animation: google.maps.Animation.DROP   });  for (var t = 0, llen = dub.length; t < llen; t++) {      var marker = new google.maps.Marker({       position: new google.maps.LatLng(dub[t]['lat'], dub[t]['long']),       map: map,       title: dub[t]['title']     });  }  }   google.maps.event.addDomListener(window, 'load', initialize); 

HTML:

<div id="map-container" style="height: 500px;"> <div id="map-canvas" style="width: 100%; height: 100%"></div> </div> 

1.How can I set a zoom out limit for the map to render properly?

like image 986
Angad Dubey Avatar asked Feb 20 '14 15:02

Angad Dubey


People also ask

What is the maximum zoom level in Google map?

Overview. The Google Maps API provides map tiles at various zoom levels for map type imagery. Most roadmap imagery is available from zoom levels 0 to 18, for example. Satellite imagery varies more widely as this imagery is not generated, but directly photographed.

Why does Google Maps keep zooming out?

The app does this because you're not in navigation mode, you're browsing the route. It zooms out to fit the entire route on your screen when you reorient the device. If you don't want it to zoom, press the navigation button in the lower right corner and optionally switch off voice navigation.


Video Answer


1 Answers

It's been added to the api, you can just set that option directly on the map object:

  map.setOptions({ minZoom: 5, maxZoom: 15 }); 

ref - https://developers.google.com/maps/documentation/javascript/reference#MapOptions

like image 93
chrismarx Avatar answered Oct 21 '22 08:10

chrismarx