This commit is contained in:
wangshiming
2021-12-15 13:19:03 +08:00
parent 0201624265
commit 5f7df7339a
23 changed files with 1159 additions and 105 deletions

View File

@ -46,7 +46,8 @@ export class AmapPoiPickerComponent implements OnInit {
'AMap.PoiPicker',
'AMap.Scale',
'AMap.InfoWindow',
'AMap.Geolocation'
'AMap.Geolocation',
'AMap.Geocoder'
],
AMapUI: {
// 是否加载 AMapUI缺省不加载
@ -110,11 +111,18 @@ export class AmapPoiPickerComponent implements OnInit {
infoWindow.setContent(`地址: <pre>${poi.name}</pre>`);
infoWindow.open(map, marker.getPosition());
map.setCenter(marker.getPosition());
//获取行政区信息
map.getCity(function (info: any) {
poi.cityInfo = info;
//获取地址所在的行政区
AMap.plugin('AMap.Geocoder', () => {
var geocoder = new AMap.Geocoder({
city: poi.adcode
});
geocoder.getLocation(poi.name, (status: any, result: any) => {
if (status === 'complete' && result.info === 'OK') {
// result中对应详细地理坐标信息
this.poi.cityInfo = result.geocodes[0].addressComponent;
}
});
});
});