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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.