[英]How to center a Google Map to a latitude and longitude location?
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. 根据文档 ,我可以使用setCenter
方法轻松地将地图居中,但我不理解文档正在使用的符号。
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 所有Google Maps javascript类均使用google.maps.ClassName()
表示法引用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.