相关疑难解决方法(0)

在Google地图上获取当前位置

当我想获得当前位置时,我遇到了一些麻烦.

这是我第一次使用这个GM API,还有很多我不理解的东西.

这是我的代码,我想要

var geocoder = new google.maps.Geocoder();

function initialize() {
  var latLng = new google.maps.LatLng(-7.7801502, 110.3846387);
  var map = new google.maps.Map(document.getElementById('mapCanvas'), {
    zoom: 15,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });

  var marker = new google.maps.Marker({
    position: latLng,
    title: 'Ambarrukmo Plaza Yogyakarta',
    map: map,
    draggable: true
  });
}
Run Code Online (Sandbox Code Playgroud)

问题是,我想根据用户的当前位置自动更改-7.7801502和110.3846387值.我能这样做吗?

在此之前,感谢您的帮助和解释.

另一个问题: - >如果我要根据嵌入GPS的设备更改这些值,该怎么办?

google-maps google-maps-api-3

23
推荐指数
2
解决办法
8万
查看次数

是否仍支持google.loader.clientlocation

我使用google.loader.ClientLocation进行了一些测试:

但我在测试中得到null:

if (google.loader.ClientLocation) 
Run Code Online (Sandbox Code Playgroud)

这是谷歌找不到IP信息时的行为.

我搜索了StackOverflow并且有很多关于它的问题,但没有好的答案.

我在网上搜索了这两个链接:

这似乎说应该使用导航器HTML地理位置.

Google API文档不再提及它了.

我想确认谷歌google.loader.clientlocation是否还在工作?

我的代码如下:

<html>
<head>
  <script type="text/javascript" src="http://www.google.com/jsapi"></script>
</head>
<body>
<script type="text/javascript"> 
function geoTest() {

    if (google.loader.ClientLocation) {

        var latitude = google.loader.ClientLocation.latitude;
        var longitude = google.loader.ClientLocation.longitude;
        var city = google.loader.ClientLocation.address.city;
        var country = google.loader.ClientLocation.address.country;
        var country_code = google.loader.ClientLocation.address.country_code;
        var region = google.loader.ClientLocation.address.region;

        var text = 'Your Location<br /><br />Latitude: ' + latitude + '<br />Longitude: ' + longitude + '<br />City: ' + city + '<br />Country: …
Run Code Online (Sandbox Code Playgroud)

html5 google-api geolocation google-geocoding-api

17
推荐指数
1
解决办法
3万
查看次数

从浏览器获取客户端位置的方法?

我需要的是客户端的经纬度(通过浏览器)

在网上找到了一些文章,在堆栈中发现了一些溢出本身(一篇旧文章)从网络浏览器获取 GPS 位置。大约 18 个月前就有人回答了——想知道是否还有其他(更有效的)方法可以从浏览器中获取用户位置信息。

到目前为止,找到 2

使用 Maxmind

其他,使用谷歌的api

w3c 的 geo api 将有向下兼容性问题:http : //dev.w3.org/geo/api/spec-source.html,所以不要选择它。

找到了一个网站,www.drumaroo.com——当我们第一次进入该网站时要求共享位置。需要类似的东西

geolocation

5
推荐指数
1
解决办法
3万
查看次数