How to order features in one layer, when they overlap?

Andrew Source

I use one GeoJsonSource and SymbolLayer that use the source. I apply 2 features in the Source, each of them has the same geometry (point on the map), but different icons - background icon and foreground icon.

I figured out that an order in which I put features in the featureList affects order of icons. But here two connected questions arise:

  1. Is this method of ordering features (overlapping icons) reliable, safe?
  2. Is there another way to control order of icons withing one layer? (Maybe some properties I don`t know).

Here I add a source:

private fun addSymbolSource(symbolId: String, positionList: List<Position>,
                                backgroundIconProperty: Pair<String, String>,
                                foregroundIconProperty: Pair<String, String>) {

        var alreadyAddedSourced: Source? =
        if (alreadyAddedSourced == null) {

            val backgroundIconFeature: Feature = getFeature1(positionList, backgroundIconProperty)
            val foregroundIconFeature: Feature = getFeature1(positionList, foregroundIconProperty)
            val featureList = listOf(foregroundIconFeature, backgroundIconFeature)

            alreadyAddedSourced = GeoJsonSource(symbolId, FeatureCollection.fromFeatures(featureList))

Here I add a layer:

private fun addSymbolLayer(symbolLayerId: String, symbolSourceId: String) {
        val symbolLayer = SymbolLayer(symbolLayerId, symbolSourceId).withProperties(
                PropertyFactory.iconImage(, Stops.identity<String>())),


comments powered by Disqus