根据地理位置获取经纬度
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
</head>
<body>
<script src="https://webapi.amap.com/maps?v=1.4.6&key=e163cbe37323c268a52d856b3acbfef"></script>
<script type="text/javascript">
AMap.plugin('AMap.Geocoder', function() {
var geocoder = new AMap.Geocoder({
// city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
})
geocoder.getLocation('山东省淄博市', function(status, result) {
console.log(result)
if (status === 'complete' && result.info === 'OK') {
// result中对应详细地理坐标信息
}
})
})
</script>
</body>
</html>
请爱好前端技术的朋友,联系我,有问题大家一起讨论