相关疑难解决方法(0)

是否仍支持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万
查看次数