diff --git a/src/app/shared/components/amap/amap-poi-picker/amap-poi-picker.component.ts b/src/app/shared/components/amap/amap-poi-picker/amap-poi-picker.component.ts index c9577188..264ee76c 100644 --- a/src/app/shared/components/amap/amap-poi-picker/amap-poi-picker.component.ts +++ b/src/app/shared/components/amap/amap-poi-picker/amap-poi-picker.component.ts @@ -3,6 +3,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { amapConf } from '@conf/amap.config'; import { NzModalRef } from 'ng-zorro-antd/modal'; import { throwError } from 'rxjs'; +import { AmapService } from '../amap.service'; declare var AMap: any; declare var AMapUI: any; declare var Loca: any; @@ -26,7 +27,7 @@ export class AmapPoiPickerComponent implements OnInit { infoWindow: any; geocoder: any; - constructor(private modalRef: NzModalRef) {} + constructor(private modalRef: NzModalRef, private service: AmapService) {} ngOnInit(): void { this.mapInit(); // this.PoiPicker(); @@ -112,6 +113,12 @@ export class AmapPoiPickerComponent implements OnInit { radius: 1000 //范围,默认:500 }); + this.service.getCurrentPosition().subscribe(res => { + if (res) { + this.selectedPOI(res.position); + } + }); + //选取了某个POI poiPicker.on('poiPicked', (poiResult: any) => { const source = poiResult.source,