gpt4 book ai didi

html - 是否仍支持 google.loader.clientlocation

转载 作者:技术小花猫 更新时间:2023-10-29 12:11:15 27 4
gpt4 key购买 nike

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

但是我的测试结果为空:

if (google.loader.ClientLocation) 

这是google没有找到IP信息时的行为。

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

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

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

Google API 文档不再提及它。

我想确认 Google 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: ' + country + '<br />Country Code: ' + country_code + '<br />Region: ' + region;

} else {

var text = 'Google was not able to detect your location';

}

document.write(text);
}

geoTest();

</script>
</body>
</html>

最佳答案

虽然它仍然适用于某些 IP,但似乎该 API 有点“已弃用”。

这是我从这里得到的答案:

The geolocation functionality in the Loader hasn't been retired, per se. We stopped documenting it several years ago and have recommended the HTML-based solutions due to their improved accuracy, but the functionality itself has not been removed from the Loader at this time. Thanks!

因此,当找不到 IP 的位置时,google.loader.ClientLocation 为 null

关于html - 是否仍支持 google.loader.clientlocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14195837/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com