【问题标题】:Android MapBox change style of MyLocation markerAndroid MapBox 更改 MyLocation 标记的样式
【发布时间】:2017-07-15 13:29:24
【问题描述】:

我正在使用适用于 Android (v5.1) 的 MapBox API。我设法让它一切正常,并且我使用的是自定义样式(浅色样式但略有修改)。
我启用了MyLocation,它也工作得很好。但是在地图上显示我的位置的点(或标记)(在 GoogleMaps 中为蓝色)是浅灰色的,因此在地图上几乎看不到。 有什么办法可以改变它的颜色吗?我已经尝试获取belongong 层,但在MapBox Studio 和Android 中都找不到它。在哪里可以自定义?

我发现了一个可能的solution(尽管它是为谷歌地图设计的)也可以工作,但在我看来,这不是一个好的解决方案。

【问题讨论】:

    标签: java android mapbox mapbox-marker


    【解决方案1】:

    您应该能够通过MyLocationViewSettings 对象和setForegroundTintColor 方法更改这些设置。

    如果你已经有一个MapboxMap,你可以在调用newInstance时通过MapboxMapOptions进行配置,但你只能change the accuracy tint color。

    【讨论】:

      【解决方案2】:

      现在 MapboxMap 不推荐显示位置。推荐的解决方案是使用 LocationLayerPlugin。

      编辑 从 0.4.0 开始,Mapbox 现在在每个属性之前都有前缀 mapbox_。新样式名称可以在这里找到https://github.com/mapbox/mapbox-plugins-android/blob/master/plugin-locationlayer/src/main/res/values/styles.xml。

      要更改我的位置标记,您可以将自定义样式添加到继承自 mapbox_LocationLayer 的 styles.xml 并覆盖 mapbox_foregroundDrawable 项。

      <style name="CustomLocationLayer" parent="mapbox_LocationLayer">
          <item name="mapbox_foregroundDrawable">@drawable/location</item>
      </style>
      

      然后你就可以用这个样式创建图层了:

      LocationLayerPlugin(mapView, mapboxMap, locationEngine, R.style.CustomLocationLayer)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-21
        • 1970-01-01
        • 1970-01-01
        • 2013-01-27
        • 1970-01-01
        • 2018-12-29
        • 1970-01-01
        • 2011-01-03
        相关资源
        最近更新 更多