diff --git a/src/main/java/com/mapconductor/tomtom/TomTomMapViewController.kt b/src/main/java/com/mapconductor/tomtom/TomTomMapViewController.kt index 2158ce9..bd8bb17 100644 --- a/src/main/java/com/mapconductor/tomtom/TomTomMapViewController.kt +++ b/src/main/java/com/mapconductor/tomtom/TomTomMapViewController.kt @@ -277,6 +277,9 @@ class TomTomMapViewController internal constructor( } private suspend fun restackCircles() { + // Drawn as tiles: the tile layer has its own order, and clearing would tile them all again + // (6 s for 700k circles on a tablet, with the tiles gone meanwhile), as for polylines. + if (circleController.tiler?.tiledStates()?.isNotEmpty() == true) return val states = circleController.circleManager.allEntities().map { it.state } if (states.isEmpty()) return circleController.clear() diff --git a/src/main/java/com/mapconductor/tomtom/TomTomMapViewControllerRaster.kt b/src/main/java/com/mapconductor/tomtom/TomTomMapViewControllerRaster.kt index e586846..9a095a0 100644 --- a/src/main/java/com/mapconductor/tomtom/TomTomMapViewControllerRaster.kt +++ b/src/main/java/com/mapconductor/tomtom/TomTomMapViewControllerRaster.kt @@ -1,5 +1,7 @@ package com.mapconductor.tomtom +import com.mapconductor.core.circle.CIRCLE_TILE_LAYER_ID +import com.mapconductor.core.circle.CircleTiler import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID import com.mapconductor.core.polygon.PolygonTiler import com.mapconductor.core.polyline.POLYLINE_TILE_LAYER_ID @@ -73,6 +75,16 @@ fun TomTomMapViewController.setupMarkerTileRaster( } } } + circleController.tiler = + CircleTiler().apply { + onTemplate = { template, tileSize -> + if (template != null) { + upsertRasterLayer(CIRCLE_TILE_LAYER_ID, template, 1.0, tileSize, null, null) + } else { + removeRasterLayer(CIRCLE_TILE_LAYER_ID) + } + } + } } internal suspend fun TomTomMapViewController.applyPublicRasterLayer(state: RasterLayerState) { @@ -132,12 +144,13 @@ internal suspend fun TomTomMapViewController.applyComposedStyle() { val (markerTiles, others) = composedRasterLayers.values.partition { it.id == TomTomMapViewController.MARKER_RASTER_ID } val (polylineTiles, rest) = others.partition { it.id == POLYLINE_TILE_LAYER_ID } - val (polygonTiles, appRasters) = rest.partition { it.id == POLYGON_TILE_LAYER_ID } + val (circleTiles, remaining) = rest.partition { it.id == CIRCLE_TILE_LAYER_ID } + val (polygonTiles, appRasters) = remaining.partition { it.id == POLYGON_TILE_LAYER_ID } val uri = TomTomStyleComposer.composeStackedRasterStyle( apiKey = apiKey, cacheDir = cacheDir, - belowOverlays = appRasters.sortedBy { composedRasterZIndex[it.id] ?: 0 } + polygonTiles, + belowOverlays = appRasters.sortedBy { composedRasterZIndex[it.id] ?: 0 } + polygonTiles + circleTiles, aboveOverlays = markerTiles, outFile = outFile, withoutBasemap = withoutBasemap,