diff --git a/api/android-for-mapbox.api b/api/android-for-mapbox.api index 9092445..bb0b2d8 100644 --- a/api/android-for-mapbox.api +++ b/api/android-for-mapbox.api @@ -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); diff --git a/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt b/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt index 665a509..02e37c8 100644 --- a/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt +++ b/src/main/java/com/mapconductor/mapbox/MapboxMapViewController.kt @@ -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 @@ -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) diff --git a/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt b/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt index 855290f..a850f33 100644 --- a/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt +++ b/src/main/java/com/mapconductor/mapbox/MapboxOverlayStacking.kt @@ -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) diff --git a/src/main/java/com/mapconductor/mapbox/polyline/MapboxPolylineOverlayRenderer.kt b/src/main/java/com/mapconductor/mapbox/polyline/MapboxPolylineOverlayRenderer.kt index d942083..b299838 100644 --- a/src/main/java/com/mapconductor/mapbox/polyline/MapboxPolylineOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/mapbox/polyline/MapboxPolylineOverlayRenderer.kt @@ -65,6 +65,6 @@ class MapboxPolylineOverlayRenderer( private fun getAllPolylineEntities(): List> { // 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 } } } diff --git a/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt b/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt index 3700979..e391bc7 100644 --- a/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/mapbox/raster/MapboxRasterLayerOverlayRenderer.kt @@ -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 @@ -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, @@ -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) } @@ -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()