Google Maps Zoom动画在Ionic 2中不起作用

时间:2018-10-03 10:57:05

标签: google-maps ionic3

这是我的交易代码

ionViewDidLoad() { 
    this.selectAddressForm.controls['housenumber'].setValue('fghjgfh');
    //console.log('house2', this.selectAddressForm);
    if(this.navParams.data.latitude){
          this.getLocation(this.navParams.data.latitude,this.navParams.data.longitude);
          this.service.codeLatLng(this.navParams.data.latitude,this.navParams.data.longitude).then(results => {

            this.placeAddress();
          
          });
    }else{
      this.initMap();
    }

  }

<!-- begin snippet: js hide: false console: true babel: false -->

----------


  initMap(){
    if ("geolocation" in navigator) {
    navigator.geolocation.getCurrentPosition((position) => {
          this. getLocation(position.coords.latitude,position.coords.longitude);
            this.service.codeLatLng(position.coords.latitude,position.coords.longitude);
    });
  }
}

  getLocation(latitude,longitude){
      let latLng = new google.maps.LatLng(latitude, longitude);
      let mapOptions = {
        center: latLng,
         zoom: 16,
        bearing: 140,
        duration: 2000,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        zoomControl:false,
        fullscreenControl:false,
        streetViewControl:false,
        mapTypeControl:false,
        scaleControl:true,
        crossOnDrag:false,
      }

      this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
      var that = this;
      google.maps.event.addListener(this.map, 'dragend', function () {
         // marker.setPosition(this.getCenter());
          that.updatePositionAfterDrag(this.getCenter().lat(), this.getCenter().lng());
          //that.service.codeLatLng(this.getCenter().lat(),  this.getCenter().lng()).then(results => that.service.locationData = results);
      });

      google.maps.event.addListener(this.map, 'drag', function () {
       // console.log("drag");
        //marker.setPosition(this.getCenter()); // set marker position to map center

      });

  }

enter image description here

谷歌地图打开缩放动画与选定的位置,这里所有的工作正常,但动画缩放不起作用,有没有选择做缩放动画的打开地图,在这里我正在使用ionic3和cordova geolocate插件,请告诉我解决此错误。

0 个答案:

没有答案