简体   繁体   English

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

[英]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.

相关问题 如何获得谷歌地图中心的经纬度 - How to get latitude and longitude of center of google map 如何在Google地图上将标记的像素位置映射到经度和纬度 - How to map the pixel location of a marker on Google Map to Latitude and Longitude 如何使用谷歌地图查找当前位置(经度和纬度)? - How to find the current location(longitude and latitude) using Google Map? 拖动时获取谷歌地图中心的经度和纬度 - Get Latitude and Longitude of the center in google map when dragged 如何在Google地图上显示多个经度和纬度 - How to display multiple Latitude and Longitude on Google Map 如何获得两个位置之间路线的中心纬度和经度 - how to get center latitude and longitude in route between two location 如何通过Google Map API将经度和纬度值设置为其他位置? - How to set the longitude and latitude values to other location from google map api? 如何设置Cesium JS地图中心(坐标:纬度和经度) - How to set Cesium JS map center (coordinates: latitude & longitude) 如何估计纬度/经度以在地图上显示大概位置? - how to approximate a latitude/longitude to show an approximate location on the map? 使用经度/纬度在国家/地区地图上标记位置 - Marking location on a country map using Longitude/Latitude
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM