【问题标题】:Blue dot doesn't appear in geolocation (Ionic 3)地理定位中未出现蓝点(Ionic 3)
【发布时间】:2018-06-15 03:01:28
【问题描述】:

我正在使用插件“地理定位”制作应用程序,一切正常,我可以定位自己,但我没有看到蓝点(如在谷歌地图中)或只是显示实际位置的标记地图。有人可以帮助我吗?这是我在视图中显示地图的功能。

showMap(){
  this.geolocation.getCurrentPosition().then((position) => {
    let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    let mapOption = {
      center: latLng,
      zoom: 18,
      mapTypeId:google.maps.MapTypeId.ROADMAP
    }
    this.map = new google.maps.Map(this.mapRef.nativeElement, mapOption);
  }, (err) => {
    console.log(err)
  }
);}

谢谢。 Screen

【问题讨论】:

    标签: geolocation ionic3


    【解决方案1】:

    没有原生方式为当前位置设置一个点(如原生 MKMapView)。但正如 Ionic Docs for Geolocation plugin 中所述,您可以观察位置变化并获取当前的纬度和经度:

    let watch = this.geolocation.watchPosition();
    watch.subscribe((data) => {
      // data can be a set of coordinates, or an error (if an error occurred).
      // data.coords.latitude
      // data.coords.longitude
    });
    

    然后你在当前位置设置一个自定义标记。

    【讨论】:

      猜你喜欢
      • 2018-09-19
      • 2018-05-30
      • 2018-04-17
      • 2018-03-31
      • 2022-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      相关资源
      最近更新 更多