noway noway - 1 year ago 98
Javascript Question

jquery-ui-map set zoom level

I have the following code to how a map. Everything works fine except the zoom parameter. No matter what I set for zoom, it always shows the same zoom level. What can I do?

$('#pagemap').live("pageshow", function() {

$('#map_canvas').gmap().bind('init', function(evt, map) {

$('#map_canvas').gmap('getCurrentPosition', function(position, status) {

if ( status === 'OK' ) {

var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

$('#map_canvas').gmap('option', 'mapTypeId', google.maps.MapTypeId.SATELLITE);

$('#map_canvas').gmap('option', 'zoom', 13);

$('#map_canvas').gmap('addMarker', {'position': clientPosition, 'bounds': true});


Answer Source

you need to change the 'bounds' option of the marker to false.

$('#map_canvas').gmap('addMarker', {'position': clientPosition, 'bounds': false});

If you set the property bounds to true the map will calculate the viewport and zoom automagically, overriding any zoom set in the contructor Blockquote

this is a link for more informations

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download