html - 使用 HTML Geolocation API 的坐标错误
问题描述
我正在尝试使用 Chrome 作为浏览器在 Windows 10 上使用 HTML5 Geolocation API。我在获取正确的经度和纬度时遇到问题。我也尝试过使用一些 Web 应用程序,例如where-am-i.me,但它给出了相同的结果。只有谷歌提供正确的位置。我该如何解决这个问题,我们可以为此使用一些 Google API 吗?
enter code here
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
$(".latitude").text(position.coords.latitude);
$(".longitude").text(position.coords.longitude);
showMap(position.coords.latitude, position.coords.longitude);
}
解决方案
推荐阅读
- java - 图形不会自动移动,并且在按下箭头键时也会复制而不是移动
- perl - perl 对 return 语句的引用和取消引用
- huawei-mobile-services - HMS Push Kit,getToken() 方法在 Android 9 上不工作
- nativescript - Nativescript 6.5 iOS 挂起事件仅在应用再次激活时触发
- java - 如何从不同 PC 的另一个工作区导入 Java 类文件
- php - 导出 mysql 表和 zipArchive
- mysql - 生成两个日期之间的日期列表
- mongodb - 基于填充字段的虚拟
- laravel - zsh:找不到命令:laravel - 如何修复
- python - ModuleNotFoundError:没有名为“pyodbc”的模块-Azure Batch-Ubuntu