diff --git a/src/main/java/com/mapconductor/googlemaps/GoogleMapViewController.kt b/src/main/java/com/mapconductor/googlemaps/GoogleMapViewController.kt index ef1ca51..17c85ed 100644 --- a/src/main/java/com/mapconductor/googlemaps/GoogleMapViewController.kt +++ b/src/main/java/com/mapconductor/googlemaps/GoogleMapViewController.kt @@ -28,6 +28,9 @@ import com.mapconductor.core.marker.StrategyMarkerController import com.mapconductor.core.marker.dispatchGeoMarkerClick import com.mapconductor.core.marker.dispatchNativeMarkerClick import com.mapconductor.core.polygon.OnPolygonEventHandler +import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID +import com.mapconductor.core.polygon.PolygonTiler +import com.mapconductor.core.polygon.polygonTileRasterLayerState import com.mapconductor.core.polyline.OnPolylineEventHandler import com.mapconductor.core.polyline.PolylineState import com.mapconductor.googlemaps.circle.GoogleMapCircleController @@ -96,6 +99,19 @@ class GoogleMapViewController internal constructor( markerTileLayers.forEach { entity -> rasterLayerController.removeById(entity.state.id) } } } + + // Many polygons are drawn as raster tiles, shown through the same RasterLayer + // controller as the marker tiles (upsert / removeById, never the app's layers). + polygonController.tiler = + PolygonTiler().apply { + onTemplate = { template, tileSize -> + if (template != null) { + rasterLayerController.upsert(polygonTileRasterLayerState(template, tileSize)) + } else { + rasterLayerController.removeById(POLYGON_TILE_LAYER_ID) + } + } + } } override fun moveCamera(position: MapCameraPosition) = handleMoveCamera(position) diff --git a/src/main/java/com/mapconductor/googlemaps/raster/GoogleMapRasterLayerOverlayRenderer.kt b/src/main/java/com/mapconductor/googlemaps/raster/GoogleMapRasterLayerOverlayRenderer.kt index 75c7c4b..0925f7a 100644 --- a/src/main/java/com/mapconductor/googlemaps/raster/GoogleMapRasterLayerOverlayRenderer.kt +++ b/src/main/java/com/mapconductor/googlemaps/raster/GoogleMapRasterLayerOverlayRenderer.kt @@ -7,6 +7,7 @@ import com.google.android.gms.maps.model.TileProvider import com.google.android.gms.maps.model.TileProvider.NO_TILE import com.mapconductor.core.controller.OverlayKind import com.mapconductor.core.controller.OverlayStacking +import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID import com.mapconductor.core.raster.RasterLayerEntityInterface import com.mapconductor.core.raster.RasterLayerOverlayRendererInterface import com.mapconductor.core.raster.RasterLayerSource @@ -100,6 +101,9 @@ class GoogleMapRasterLayerOverlayRenderer( if (isMarkerTileRaster(state)) { // マーカーのタイルはマーカーの帯(ポリラインより上)。 OverlayStacking.flatZIndex(OverlayKind.Marker, Int.MIN_VALUE) + } else if (state.id == POLYGON_TILE_LAYER_ID) { + // ポリゴンのタイルはポリゴンの帯の一番下(GroundImage より上、ネイティブのポリゴンより下)。 + OverlayStacking.flatZIndex(OverlayKind.Polygon, Int.MIN_VALUE) } else { OverlayStacking.flatZIndex(OverlayKind.RasterLayer, state.zIndex) }