【发布时间】:2020-08-04 11:42:54
【问题描述】:
有没有办法将纬度和经度值转换为地名,然后能够在 HTML 页面上显示该地名?
if ('geolocation' in navigator) {
let watchID = navigator.geolocation.watchPosition(position => {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
console.log(latitude, longitude);
}, error => {
console.log(error.code);
}, {
enableHighAccuracy: true
});
console.log(watchID);
} else {
console.log("Not Supported");
}
代码可以返回经纬度并显示出来,如果可能的话我想获取具体的地方显示在页面上还是记录在表格中?
【问题讨论】:
-
将一组纬度/经度坐标转换为人类可读位置的实践名称称为反向地理编码。 Google Maps API 可以为您执行此操作,但请注意,免费版本的调用次数有限:developers.google.com/maps/documentation/javascript/examples/…
标签: javascript jquery geolocation