I list my users on the google maps based on their locations. But I dont want it zoom in to a degree where others can see on what street they live. Is there a way to disable "zoom in" feature in the following Google maps codes?
Thanks!
function initialize() {
var data = <%=Data%>;
var center = new google.maps.LatLng(48.404840395764175, 2.6845264434814453);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var markers = [];
for (var i = 0; i < data.users.length; i++) {
var location = data.users[i];
var latLng = new google.maps.LatLng(location.latitude, location.longitude);
var marker = new google.maps.Marker({ position: latLng });
markers.push(marker);
}
var markerCluster = new MarkerClusterer(map, markers);
}
google.maps.event.addDomListener(window, 'load', initialize);
I list my users on the google maps based on their locations. But I dont want it zoom in to a degree where others can see on what street they live. Is there a way to disable "zoom in" feature in the following Google maps codes?
Thanks!
function initialize() {
var data = <%=Data%>;
var center = new google.maps.LatLng(48.404840395764175, 2.6845264434814453);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var markers = [];
for (var i = 0; i < data.users.length; i++) {
var location = data.users[i];
var latLng = new google.maps.LatLng(location.latitude, location.longitude);
var marker = new google.maps.Marker({ position: latLng });
markers.push(marker);
}
var markerCluster = new MarkerClusterer(map, markers);
}
google.maps.event.addDomListener(window, 'load', initialize);
Share
Improve this question
edited May 30, 2012 at 13:14
James Allardice
166k22 gold badges334 silver badges315 bronze badges
asked May 30, 2012 at 13:08
EfeEfe
9543 gold badges20 silver badges37 bronze badges
2 Answers
Reset to default 5You can add minZoom
and maxZoom
properties to the options object you pass to the Map
constructor:
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP,
maxZoom: 10
});
From the docs for maxZoom
:
The maximum zoom level which will be displayed on the map. If omitted, or set to null, the maximum zoom from the current map type is used instead.
This can be used to disable scroll when mouse is hovered over map.
scrollwheel: false