I am working on a googlemap, which all works fine, apart from the fact I can't seem to set a max and min zoom (I would like to limit the levels to a couple of levels either way of a default zoom view)
I have tried using the map.getMimimumResolution, but this doesn't seem to work - any ideas ?
function initialize() {
var latlng = new google.maps.LatLng("<%=Html.Encode(Model.Field01.Field01) %>", "<%=Html.Encode(Model.Field01.Field03) %>");
var myOptions = {
zoom: 13,
center: latlng,
disableDefaultUI: false,
navigationControl: true,
navigationControlOptions: {style: google.maps.NavigationControlStyle.ZOOM_PAN},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("mapcontainer"), myOptions);
map.getMinimumResolution = function() { return 6 };
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: "<%=Model.AccomName %>"
});
}
Any thoughts appreciated, Thanks
There's the apposite configuration parameter :)
Simple example:
<script type="text/javascript">
var latlng = new google.maps.LatLng(42.3493337, 13.398172299999942);
var options = {
zoom: 8,
minZoom: 6,
maxZoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById("map_canvas"), options);
</script>
Here you have the documentation:
http://code.google.com/apis/maps/documentation/javascript/reference.html#MapOptions
Happy coding!
Code below works smoothly for me. No flickering, glitches, etc. Maps API v3.
var inProcess = false;
function onZoomChanged() {
if (inProcess) return;
if (gmap.getZoom() > 16) {
inProcess = true;
gmap.setZoom(16);
inProcess = false;
return
}
else if (gmap.getZoom() < 10) {
inProcess = true;
gmap.setZoom(10);
inProcess = false;
return;
}
}
google.maps.event.addListener(gmap, 'zoom_changed', onZoomChanged);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With