使用定位,逆地理编码,经纬度《=转=》地址信息逆地理编码,地址《=转=》经纬度,贼方便!!!!
Posted fanzhen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用定位,逆地理编码,经纬度《=转=》地址信息逆地理编码,地址《=转=》经纬度,贼方便!!!!相关的知识,希望对你有一定的参考价值。
// 逆地理编码,经纬度=》地址信息
var lnglat = [lng, lat] AMap.plugin(‘AMap.Geocoder‘, function () {
var geocoder = new AMap.Geocoder({
city: ‘010‘,
//城市设为北京,默认:“全国”
radius: 1000,
//范围,默认:500
extensions: ‘all‘,
});
geocoder.getAddress(lnglat, function (status, result) {
if (status === ‘complete‘ && result.info === ‘OK‘) {
// geocoder_CallBack(result);
// console.log(result, "result");
self.city = result.regeocode.addressComponent.city;
self.resultData = result.regeocodeaddressComponent.city;
localStorage.localCity = result.regeocode.addressComponent.city;
localStorage.timestamp = new Date().getTime();
localStorage.position = JSON.stringify(position);
//将即将纬度存到本地
}
});
});
// 逆地理编码,地址-》经纬度
var address = ‘山东省苍山县‘;
//详细地址
AMap.plugin(‘AMap.Geocoder‘, function () {
var geocoder = new AMap.Geocoder({
city: ‘010‘,
//城市设为北京,默认:“全国”
radius: 1000,
//范围,默认:500
extensions: ‘all‘
});
geocoder.getAddress(address, function (status, result) {
if (status === ‘complete‘ && result.info === ‘OK‘) {
// geocoder_CallBack(result);
// console.log(result, "result");
self.city = result.regeocode.addressComponent.city;
self.resultData = result.regeocode.addressComponent.city;
localStorage.localCity = result.regeocode.addressComponent.city;
localStorage.timestamp = new Date().getTime();
localStorage.position = JSON.stringify(position);
//将即将纬度存到本地
}
})
});
以上是关于使用定位,逆地理编码,经纬度《=转=》地址信息逆地理编码,地址《=转=》经纬度,贼方便!!!!的主要内容,如果未能解决你的问题,请参考以下文章