在Google Maps上触摸标记时,Marker远离接触的位置



我没有得到为什么会发生这个问题。每当我尝试触摸标记时,它就会消失。我不知道以下代码有什么问题。这在Web浏览器和Android的构建APK中都发生。以下是我的代码。

地图启动代码

initMap() {
    this.loading = this.loadingCtrl.create({
      content: 'Please wait...'
    });
    this.geolocation.getCurrentPosition().then((resp) => {
      let latLng = {lat: resp.coords.latitude, lng: resp.coords.longitude};
      this.storage.set('latitude', resp.coords.latitude);
      this.storage.set('longitude', resp.coords.longitude);
      this.initializeCurrent(resp.coords.latitude, resp.coords.longitude);
      let mapOptions = {
        center: latLng,
        zoom: 15
      }
      this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
      this.marker = new google.maps.Marker({
        position: latLng,
        draggable: true,
        map: this.map,
        animation: google.maps.Animation.DROP,
        title: 'Marker is here.'
      });
      this.marker.addListener('dragend', ($event) => this.onMarkerDrop($event));
      this.loading.dismiss();
    });
  }

请让我知道我在上面的代码中在哪里做错了。谢谢。

尝试将disableAutoPan: true添加到标记选项中。

最新更新