Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/android-for-mapbox.api
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public final class com.mapconductor.mapbox.MapboxOverlayStacking {
public final com.mapconductor.core.controller.OverlayStacking$Key key(com.mapconductor.core.controller.OverlayKind, int);
public final com.mapconductor.core.controller.OverlayStacking$Key getMARKER_TILE();
public final com.mapconductor.core.controller.OverlayStacking$Key getPOLYGON_TILE();
public final com.mapconductor.core.controller.OverlayStacking$Key getPOLYLINE_TILE();
public final com.mapconductor.core.controller.OverlayStacking$Key getMARKER_DRAG();
public final void add(com.mapbox.maps.MapboxMap, com.mapbox.maps.Style, com.mapbox.maps.extension.style.layers.Layer, com.mapconductor.core.controller.OverlayStacking$Key);
public final void remove(com.mapbox.maps.MapboxMap, com.mapbox.maps.Style, java.lang.String);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import com.mapconductor.core.marker.dispatchGeoMarkerClick
import com.mapconductor.core.polygon.OnPolygonEventHandler
import com.mapconductor.core.polygon.PolygonState
import com.mapconductor.core.polyline.OnPolylineEventHandler
import com.mapconductor.core.polyline.POLYLINE_TILE_LAYER_ID
import com.mapconductor.core.polyline.PolylineState
import com.mapconductor.core.polyline.PolylineTiler
import com.mapconductor.core.polyline.polylineTileRasterLayerState
import com.mapconductor.mapbox.circle.MapboxCircleController
import com.mapconductor.mapbox.groundimage.MapboxGroundImageController
import com.mapconductor.mapbox.marker.MapboxMarkerController
Expand Down Expand Up @@ -132,6 +135,18 @@ class MapboxMapViewController internal constructor(
}
}
}

// Many polylines too: the same raster layer path, in the polyline band.
polylineController.tiler =
PolylineTiler().apply {
onTemplate = { template, tileSize ->
if (template != null) {
rasterLayerController.upsert(polylineTileRasterLayerState(template, tileSize))
} else {
rasterLayerController.removeById(POLYLINE_TILE_LAYER_ID)
}
}
}
}

override fun moveCamera(position: MapCameraPosition) = handleMoveCamera(position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ internal object MapboxOverlayStacking {
/** ポリゴンのタイル(ラスター): ポリゴンの帯の一番下。 */
val POLYGON_TILE = key(OverlayKind.Polygon, Int.MIN_VALUE)

/** ポリラインのタイル(ラスター): ポリラインの帯の一番下(サークルの上、ネイティブのポリラインの下)。 */
val POLYLINE_TILE = key(OverlayKind.Polyline, Int.MIN_VALUE)

/** ドラッグ中のマーカーの層: マーカーの帯の一番上。 */
val MARKER_DRAG = key(OverlayKind.Marker, Int.MAX_VALUE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ class MapboxPolylineOverlayRenderer(
private fun getAllPolylineEntities(): List<PolylineEntityInterface<MapboxActualPolyline>> {
// This would need access to the polyline manager
// For now, we'll implement a simple workaround
return polylineManager.allEntities()
return polylineManager.allEntities().filter { (it.polyline as MapboxActualPolyline?) != null }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.mapbox.maps.extension.style.sources.addSource
import com.mapbox.maps.extension.style.sources.generated.rasterSource
import com.mapconductor.core.controller.OverlayKind
import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID
import com.mapconductor.core.polyline.POLYLINE_TILE_LAYER_ID
import com.mapconductor.core.raster.RasterHeaderRuleSet
import com.mapconductor.core.raster.RasterLayerEntityInterface
import com.mapconductor.core.raster.RasterLayerOverlayRendererInterface
Expand All @@ -28,6 +29,8 @@ class MapboxRasterLayerOverlayRenderer(

private fun isPolygonTileRaster(state: RasterLayerState): Boolean = state.id == POLYGON_TILE_LAYER_ID

private fun isPolylineTileRaster(state: RasterLayerState): Boolean = state.id == POLYLINE_TILE_LAYER_ID

/** Mapbox Android はタイル要求を書き換える公開 API を持たない。 */
override suspend fun onAdd(
data: List<RasterLayerOverlayRendererInterface.AddParamsInterface>,
Expand Down Expand Up @@ -178,6 +181,8 @@ class MapboxRasterLayerOverlayRenderer(
MapboxOverlayStacking.MARKER_TILE
} else if (isPolygonTileRaster(state)) {
MapboxOverlayStacking.POLYGON_TILE
} else if (isPolylineTileRaster(state)) {
MapboxOverlayStacking.POLYLINE_TILE
} else {
MapboxOverlayStacking.key(OverlayKind.RasterLayer, state.zIndex)
}
Expand All @@ -188,7 +193,7 @@ class MapboxRasterLayerOverlayRenderer(
val ordered =
stateById.values
.asSequence()
.filter { !isMarkerTileRaster(it) && !isPolygonTileRaster(it) }
.filter { !isMarkerTileRaster(it) && !isPolygonTileRaster(it) && !isPolylineTileRaster(it) }
.sortedBy { it.zIndex }
.mapNotNull { state -> handleById[state.id]?.let { handle -> state to handle } }
.toList()
Expand Down
Loading