3

I'm trying to set use a link on the page to pan and zoom to a specific array of coordinates (where I have a marker already dropped, and gmap3 initialized). When I click the link, the Javascript fires (I get the alert), but nothing happens in my map. Please help. Here is my code:

$(".phila").click(function(){
    alert("hello");
    $("#map").gmap3({
        action:'panTo', 
        args:[39.952335, -75.163789]
    });
});

Edit: now I am getting an error in the console saying "Uncaught Error: panTo: latLng must be of type LatLng"

skaffman
  • 398,947
  • 96
  • 818
  • 769

3 Answers3

6

To zoom using gmap3 you first need to get a reference to native map object and then simply set the level.

var map = $("#map_canvas").gmap3('get');
map.setZoom(1);
Sydwell
  • 4,954
  • 1
  • 33
  • 36
5

you may try this:

$('#test1').gmap3(
    {action:'panTo',
     args:[new google.maps.LatLng(-7,110)]}
);

it works.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
arjunaaji
  • 131
  • 1
  • 7
  • Could you also include how to use the address feature so you can use "London" instead of numerical coordinates? Thanks – Evanss Mar 02 '12 at 16:24
  • Works great, Does anyone no why the official doc does not reflect this or am I missing something. http://gmap3.net/examples/pan-to-markers.html – Sydwell Jul 01 '12 at 18:22
0

Looks like the expected argument is a single point, not two separate arguments, lat, lon. try:

$("#map").gmap3({
   action:'panTo', 
     args:[[39.952335, -75.163789]]
   });
});
Karl Rosaen
  • 4,508
  • 2
  • 27
  • 30