HTML5地理位置不正确 [英] HTML5 geolocation is not accurate
本文介绍了HTML5地理位置不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码来获取当前位置.但是产生的经度和纬度根本不准确.它显示的位置距离我的位置约700公里.如何使其准确?
I was using the following code to get my current location. But the longitude and latitude generated was not at all accurate. It was showing a location about 700 Kms away from my location. How can I make it accurate?
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
推荐答案
或者您可以尝试使用其他地理编码提供程序.
Or you could try a different geocoding provider.
有很多选择:
- https://smartystreets.com
- http://geocoder.us
- http://geoservices.tamu.edu/Services/Geocode/
免责声明:我是SmartyStreets的开发人员.
Disclaimer: I'm a developer at SmartyStreets.
这篇关于HTML5地理位置不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文