作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
基本上,每当有人打开我的(谷歌) map 时,我希望它默认为他们的大概位置。
有没有一种简单的方法可以使用 Google 的 API 来完成,还是我必须编写自定义代码(这是基于 python 的应用程序)?
最佳答案
您可以使用 Google API 的内置 ClientLocation对象:
if (GBrowserIsCompatible())
{
var map = new google.maps.Map2(document.getElementById("mapdiv"));
if (google.loader.ClientLocation)
{
var center = new google.maps.LatLng(
google.loader.ClientLocation.latitude,
google.loader.ClientLocation.longitude
);
var zoom = 8;
map.setCenter(center, zoom);
}
}
关于javascript - 基于地理编码的 IP 居中谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1365722/
leaflet:一个开源并且对移动端友好的交互式地图 JavaScript 库 中文文档: https://leafletjs.cn/reference.html 官网(英文): ht
我是一名优秀的程序员,十分优秀!