【问题标题】:How to display my location on Google Maps Nativescript如何在 Google Maps Nativescript 上显示我的位置
【发布时间】:2019-07-02 09:49:26
【问题描述】:

我在我的项目中使用了这个plugin

我想在地图上显示我的位置。在我阅读的文档中

**UI Settings**
myLocationButtonEnabled boolean - Whether the my-location button is enabled/disabled

如何在代码中应用这个?

我也尝试编写这段代码:

  onMapReady(event) {
    this.mapView = event.object;
          var marker = new Marker();
          marker.position = Position.positionFromLatLng(-33.86, 151.20);
          marker.userData = { index: 1 };
          this.mapView.addMarker(marker);
          this.mapView.myLocationEnabled= true;   
  }

这个this.mapView.myLocationEnabled= true; 不起作用。

你能告诉我如何显示我的位置吗?

【问题讨论】:

    标签: google-maps maps nativescript


    【解决方案1】:

    ReadMe file中已经描述过,

    您可以在 mapReady 之后通过更改 ma​​pView.settings

    上的以下属性来调整地图 UI 设置

    myLocationButtonEnabled boolean - 我的位置按钮是否 启用/禁用

    代码应该是,

    this.mapView.settings.myLocationButtonEnabled = true;
    

    确保您在启用位置按钮之前获得位置权限,如demo app 中所示。

    【讨论】:

      【解决方案2】:
      onMapReady(event) {
        this.mapView.gMap.setMyLocationEnabled(true);
      }
      

      我希望你错过了 gMap

      【讨论】:

        猜你喜欢
        • 2012-02-26
        • 2013-02-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-15
        • 2016-01-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多