import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; import { _HttpClient } from '@delon/theme'; import * as $ from 'jquery'; declare var AMapUI: any; declare var AMap: any; @Component({ selector: 'app-gaode-map', templateUrl: './gaode-map.component.html' }) export class GaodeMapComponent implements OnInit { addressInput: any; constructor() {} ngOnInit(): void { this.PoiPicker(); } // poi选点 PoiPicker() { AMapUI.setDomLibrary($); let map = new AMap.Map('container', { zoom: 10 }); AMapUI.loadUI(['misc/PoiPicker'], function (PoiPicker: any) { let poiPicker = new PoiPicker({ // city:'北京', input: 'pickerInput' }); //初始化poiPicker (window as any).poiPicker = poiPicker; var marker = new AMap.Marker(); var infoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -20) }); console.log('0000') console.log(PoiPicker) //选取了某个POI poiPicker.on('poiPicked', function (poiResult: any) { console.log(1111); console.log(poiResult) // console.log(this.addressInput) // this.addressInput = poiResult.item?.name var source = poiResult.source, poi = poiResult.item, info = { source: source, id: poi.id, name: poi.name, location: poi.location.toString(), address: poi.address }; marker.setMap(map); infoWindow.setMap(map); marker.setPosition(poi.location); infoWindow.setPosition(poi.location); infoWindow.setContent(`POI信息:
${JSON.stringify(info, null, 2)}
`); infoWindow.open(map, marker.getPosition()); map.setCenter(marker.getPosition()); }); poiPicker.onCityReady(() => { // poiPicker.suggest('美食'); }); }); } }