【问题标题】:Mapbox SymbolLayer hides markersMapbox SymbolLayer 隐藏标记
【发布时间】:2018-07-24 10:35:16
【问题描述】:

我使用符号层在地图上绘制一堆点:

var imgId = R.drawable.ic_route_stop

        var featureCollection = FeatureCollection.fromFeatures(mSelectedBusStops!!.map { stop ->
            Feature.fromGeometry(com.mapbox.geojson.Point.fromLngLat(
                    stop.Lon.toDouble(),
                    stop.Lat.toDouble()))
        });
        map?.addSource(
                GeoJsonSource(mMarkerSourceIdentifier,
                        featureCollection,
                        GeoJsonOptions()
                ))

        val image = BitmapFactory.decodeResource(activity?.resources, imgId)
        map?.addImage(mMarkerImgIdentifier, image)

        var layer = SymbolLayer(mMarkerStyleLayerIdentifier, mMarkerSourceIdentifier)
        layer.setProperties(PropertyFactory.iconImage(mMarkerImgIdentifier),
                PropertyFactory.iconAllowOverlap(true))
        map?.addLayer(layer)

之后我在地图中添加了几个标记(这些标记需要定期动画)

mSelectedBusCurrentStops?.forEach { stop ->
                (map ?: return).addMarker(MarkerOptions()
                        .icon(icon)
                        .position(LatLng(stop.lat, stop.lon)))
            }

这里的重要部分是标记,我稍后添加的,这些标记应该始终可见。但是我的符号层隐藏了标记图标,我需要将标记放在前面。有什么办法可以解决吗?

这就是它的样子

【问题讨论】:

    标签: android kotlin mapbox mapbox-android mapbox-marker


    【解决方案1】:

    您需要将SymbolLayer 定位在图层堆栈中的标记图层下方。您可以通过map?.addLayerBelow(layer, "com.mapbox.annotations.points") 实现这一目标。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      • 2017-04-28
      • 1970-01-01
      • 2014-12-01
      • 1970-01-01
      相关资源
      最近更新 更多