From 36c733bd41f411a722024355f019fbf614cff07f Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Wed, 11 Nov 2026 11:41:05 -0800 Subject: [PATCH 1/2] Order markers with MarkerDrawOrder The symbol sort key is now zIndex first, then south and west, recomputed from the current state on every change. Unspecified markers in the southern hemisphere no longer outrank an explicit zIndex. --- .../mapbox/marker/MapboxMarkerOverlayRenderer.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt b/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt index e057e2e..294f551 100644 --- a/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt @@ -5,12 +5,12 @@ import com.google.gson.JsonObject import com.mapbox.geojson.Feature import com.mapbox.geojson.FeatureCollection import com.mapconductor.core.ResourceProvider -import com.mapconductor.core.calculateZIndex import com.mapconductor.core.features.GeoPoint import com.mapconductor.core.features.GeoPointInterface import com.mapconductor.core.marker.AbstractMarkerOverlayRenderer import com.mapconductor.core.marker.BitmapIcon import com.mapconductor.core.marker.DefaultMarkerIcon +import com.mapconductor.core.marker.MarkerDrawOrder import com.mapconductor.core.marker.MarkerEntityInterface import com.mapconductor.core.marker.MarkerIconInterface import com.mapconductor.core.marker.MarkerManager @@ -184,7 +184,7 @@ class MapboxMarkerOverlayRenderer( val props = (markerEntity.marker?.properties() ?: JsonObject()).deepCopy() props.addProperty( Prop.Z_INDEX, - markerEntity.state.zIndex ?: calculateZIndex(position), + MarkerDrawOrder.of(markerEntity.state.zIndex, position), ) val feature = Feature.fromGeometry( @@ -246,7 +246,7 @@ class MapboxMarkerOverlayRenderer( add(Prop.ICON_ANCHOR, getDefaultIconOffsetProperty()) } addProperty(Prop.SCALE, it.state.icon?.scale ?: 1.0) - addProperty(Prop.Z_INDEX, it.state.zIndex ?: calculateZIndex(it.state.position)) + addProperty(Prop.Z_INDEX, MarkerDrawOrder.of(it.state.zIndex, it.state.position)) } Feature.fromGeometry(position, properties, featureId) } @@ -335,7 +335,7 @@ class MapboxMarkerOverlayRenderer( ) addProperty( Prop.Z_INDEX, - params.current.state.zIndex ?: calculateZIndex(params.current.state.position), + MarkerDrawOrder.of(params.current.state.zIndex, params.current.state.position), ) if (currFinger.icon == prevFinger.icon) { addProperty( From 32a75e247fa4bbf83248aac6e8a947bf4b7cd534 Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Wed, 11 Nov 2026 15:00:56 -0800 Subject: [PATCH 2/2] Reorder markers when the map rotates Same-zIndex markers follow the screen position (lower in front) and are re-sorted after rotation settles. --- api/android-for-mapbox.api | 1 + .../marker/MapboxMarkerOverlayRenderer.kt | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/api/android-for-mapbox.api b/api/android-for-mapbox.api index bb0b2d8..8865c91 100644 --- a/api/android-for-mapbox.api +++ b/api/android-for-mapbox.api @@ -380,6 +380,7 @@ public final class com.mapconductor.mapbox.marker.MapboxMarkerOverlayRenderer ex public void setMarkerPosition(com.mapconductor.core.marker.MarkerEntityInterface, com.mapconductor.core.features.GeoPoint); public java.lang.Object onAdd(java.util.List, kotlin.coroutines.Continuation>); public java.lang.Object onRemove(java.util.List>, kotlin.coroutines.Continuation); + protected java.lang.Object applyDrawOrder(java.util.List>, kotlin.coroutines.Continuation); public java.lang.Object onPostProcess(kotlin.coroutines.Continuation); public java.lang.Object onChange(java.util.List>, kotlin.coroutines.Continuation>); public void onDragSelectionChanged(com.mapconductor.core.marker.MarkerEntityInterface, com.mapconductor.core.marker.MarkerEntityInterface); diff --git a/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt b/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt index 294f551..e73dde4 100644 --- a/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/mapbox/marker/MapboxMarkerOverlayRenderer.kt @@ -184,7 +184,7 @@ class MapboxMarkerOverlayRenderer( val props = (markerEntity.marker?.properties() ?: JsonObject()).deepCopy() props.addProperty( Prop.Z_INDEX, - MarkerDrawOrder.of(markerEntity.state.zIndex, position), + MarkerDrawOrder.of(markerEntity.state.zIndex, position, drawOrderFrame), ) val feature = Feature.fromGeometry( @@ -246,7 +246,7 @@ class MapboxMarkerOverlayRenderer( add(Prop.ICON_ANCHOR, getDefaultIconOffsetProperty()) } addProperty(Prop.SCALE, it.state.icon?.scale ?: 1.0) - addProperty(Prop.Z_INDEX, MarkerDrawOrder.of(it.state.zIndex, it.state.position)) + addProperty(Prop.Z_INDEX, drawOrderOf(it.state)) } Feature.fromGeometry(position, properties, featureId) } @@ -271,6 +271,17 @@ class MapboxMarkerOverlayRenderer( } } + // 地図が回ったら、各フィーチャーの並び順キー(symbol-sort-key)を付け直して流し直す。 + override suspend fun applyDrawOrder(entities: List>) { + val target = entities.filter { !it.tiling } + withContext(Dispatchers.Main) { + target.forEach { entity -> + entity.marker?.properties()?.addProperty(Prop.Z_INDEX, drawOrderOf(entity.state)) + } + markerLayer.draw(target) + } + } + override suspend fun onPostProcess() { val target = markerManager.allEntities().filter { !it.tiling } @@ -335,7 +346,7 @@ class MapboxMarkerOverlayRenderer( ) addProperty( Prop.Z_INDEX, - MarkerDrawOrder.of(params.current.state.zIndex, params.current.state.position), + drawOrderOf(params.current.state), ) if (currFinger.icon == prevFinger.icon) { addProperty(