如何在标记下拖动地图并将它们固定在离子2中?

时间:2017-06-25 09:06:58

标签: google-maps google-maps-api-3 ionic2

在这段代码中,我试图制作像Uber地图部分来固定和停止标记的东西。但我拖动制造商而不是标记下的地图。 它看起来不是很好的用户体验。 我想在设置位置并点击Originmaker后添加目标标记 然后在视图中绑定它们。

    initializeMap() {

    let image = 'assets/img/taxi3.png';
    let minZoomLevel = 16;
    Geolocation.getCurrentPosition().then((position) => {
    this.map = new google.maps.Map(document.getElementById('map_canvas'), {
    zoom: minZoomLevel,
    center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
    mapTypeControl: false,
    streetViewControl: false,
    disableDefaultUI: true,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    var trafficLayer = new google.maps.TrafficLayer();
            trafficLayer.setMap(this.map);
            this.OriginMarker();
      });
    }

OriginMarker(){   
   let image = 'assets/img/Untitled-1.png';   
   let marker = new google.maps.Marker({    
    map: this.map,
    animation: google.maps.Animation.DROP,
    position: this.map.getCenter(),
    draggable: true,
     icon: image
  });
}

TargetMarker() {  

    let image = 'assets/img/Untitled-2.png';
    let marker = new google.maps.Marker({
     map: this.map,
    animation: google.maps.Animation.DROP,
    position: this.map.getCenter(),
    draggable: true,
     icon: image
  }); 
}

0 个答案:

没有答案