Reputation: 1015
I am having trouble adding a default zoom number to this code as I am using a panTo function. I am using gmap for jquery. This is my code:
$('#map_canvas').gmap('get', 'map').panTo(myLatlng);
many thanks.
Upvotes: 0
Views: 1751
Reputation: 3294
I'm having trouble finding the gmap for v3 plugin. Can you add a link? If you're using the gmap for v2 plugin, you could use the setCenter function instead of the panTo function: $('#map_canvas').gmap('get', 'map').setCenter(myLatlng, myZoom);
If the gmap vor v3 plugin exposes the v3 api, then you could make a call to setZoom after making a call to panTo.
Updated after clarification of plugin source:
The plugin has a built-in method for doing that: centerAt
. You don't need to get the jQuery object with the map div, as that's a container for a DOM object, not a google.maps.Map object. I.E. it won't have a panTo method. Here's how you recenter/zoom, the way the plugin author intended (assuming myLatlng you mentioned is a google.maps.LatLng):
// initialize the map
$('#map_canvas').gMap(); // this can take a ton of options if you want.
Then later...
// reposition/zoom the map.
$('#map_canvas').gMap('centerAt', {
latitude: myLatlng.lat(),
longitude: myLatlng.lng(),
zoom: myZoom
});
Upvotes: 1