1

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

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)))
            }

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

这就是它的样子

在此处输入图像描述

4

1 回答 1

1

您需要将您的位置放在SymbolLayer图层堆栈中的标记图层下方。您可以使用map?.addLayerBelow(layer, "com.mapbox.annotations.points").

于 2018-09-19T12:12:10.200 回答