fix bug
This commit is contained in:
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user