繁体   English   中英

如何将Google地图集中到纬度和经度位置?

[英]How to center a Google Map to a latitude and longitude location?

请考虑以下代码:

$('.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')));
});

根据文档 ,我可以使用setCenter方法轻松地将地图居中,但我不理解文档正在使用的符号。

看到:

LatLng(lat:number, lng:number, noWrap?:boolean)

我究竟如何使用它?

我收到错误:

Uncaught ReferenceError: LatLng is not defined 

你必须使用

themap.setCenter(new google.maps.LatLng($(this).data('latitude'), $(this).data('longitude')));

所有Google Maps javascript类均使用google.maps.ClassName()表示法引用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM