Reputation: 22224
Consider the following code:
$('.stores').click(function() {
console.log($(this).data('latitude')); // -1754.26265626
console.log($(this).data('longitude')); // 65.262518
console.log(themap); // Properly a Google Map instance.
themap.setCenter(new LatLng($(this).data('latitude'), $(this).data('longitude')));
});
According to the documentation, I can use the setCenter
method and easily center the map, but I don't understand the notation the docs are using.
See:
LatLng(lat:number, lng:number, noWrap?:boolean)
How exactly do I use this?
I'm getting the error:
Uncaught ReferenceError: LatLng is not defined
Upvotes: 3
Views: 14862
Reputation: 7808
You have to use
themap.setCenter(new google.maps.LatLng($(this).data('latitude'), $(this).data('longitude')));
All Google Maps javascript classes are referenced with the google.maps.ClassName()
notation
Upvotes: 7