【问题标题】:Realtime Tracking using leaflet使用传单进行实时跟踪
【发布时间】:2018-10-02 07:05:33
【问题描述】:

我想知道我可以使用 Ionic 使用传单实时跟踪我的位置,我能够获得我当前的位置,但我也想在我移动时跟踪它

 this.map.locate({
  setView: true,
  maxZoom: 16
}).on('locationfound', (e) => {
  let markerGroup = leaflet.featureGroup();
  this.marker = leaflet.marker([e.latitude, e.longitude], { icon: carIcon }).addTo(this.map);

【问题讨论】:

    标签: ionic-framework geolocation leaflet tracking


    【解决方案1】:

    locate 接受 watch 选项,让您不断更新标记位置:

    watch 类型:布尔默认值:false
    如果为 true,则使用 W3C watchPosition 方法开始连续观察位置变化(而不是检测一次)。您可以稍后使用map.stopLocate() 方法停止观看。

    例如:

    this.map.locate({
        watch: true,
        setView: true,
        maxZoom: 16
    }).on('locationfound', (e) => {
        if (!this.marker) {
            this.marker = leaflet.marker([e.latitude, e.longitude], { icon: carIcon }).addTo(this.map);
        } else {
            this.marker.setLatLng([e.latitude, e.longitude]);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多