user537137
user537137

Reputation: 614

Google maps set bounds zoom level

I have a map that shows the users location and automatically zooms in. I am wondering how I can set this zoom level as 'zoom' and 'maxZoom' isn't working. After some googling it seems that I need to set the bounds but wouldn't know where to start. I am hoping to get it to zoom to around 12.

Here is part of the code:

jQuery('#map_canvas').gmap('getCurrentPosition', function(position, status) {
    if ( status === 'OK' ) {
        var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
        jQuery('#map_canvas').gmap('addMarker', {'position': clientPosition, 'bounds': true});
        jQuery('#map_canvas').gmap('addShape', 'Circle', { 
            'strokeWeight': 0, 
            'fillColor': "#008595", 
            'fillOpacity': 0.25, 
            'center': clientPosition, 
            'radius': 15, 
            'clickable': false 
        });
    }
}); 

Upvotes: 0

Views: 762

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117354

use the setZoom-method of the google.maps.Map-instance to apply a custom zoom after adding the marker

jQuery('#map_canvas').gmap('get','map').setZoom(12);

Upvotes: 2

Related Questions