javascript - 使用javascript查找经纬度

标签 javascript latitude-longitude

我是第一次使用 javascript。实际上我想使用 java 脚本获取地址的纬度和经度。谁能指导我..

最佳答案

如果你需要给定地址的经纬度,你可以使用google maps api https://developers.google.com/maps/documentation/javascript/

举个例子: https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-simple

编辑:在警报弹出窗口中显示它:

var address = document.getElementById("address").value;
var geocoder = new google.maps.Geocoder();

geocoder.geocode( { 'address': address}, function(results, status) {
  var location = results[0].geometry.location;
  alert(location.lat() + '' + location.lng());
});

关于javascript - 使用javascript查找经纬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11033451/

相关文章:

javascript - Promise + async.js

android - 纬度/经度和米

c# - 查找离给定位置最近的城市

c# - C#计算平均经纬度

android - 将经纬度从数据库保存到 GPX 文件.Android

javascript - 当用户未登录到应用程序时,使用 React 路由重定向的正确方法是什么?

javascript - 如何同时使用 node-sass 和 sass-autoprefixer?

javascript - 在没有 cookie 的 Javascript 网页上处理公制到英寸的转换

javascript - jQuery 可排序列表在创建时不重新排序

postgresql - 纬度和经度的数据类型是什么?