Skip to content
Merged
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
5 changes: 5 additions & 0 deletions api/android-for-mappls.api
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public final class com.mapconductor.mappls.MapplsOverlayStacking {
public final com.mapconductor.core.controller.OverlayLayerStack stackOf(com.mappls.sdk.maps.MapplsMap);
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 getMARKER_DRAG();
public final void add(com.mappls.sdk.maps.MapplsMap, com.mappls.sdk.maps.Style, com.mappls.sdk.maps.style.layers.Layer, com.mapconductor.core.controller.OverlayStacking$Key);
public final void remove(com.mappls.sdk.maps.MapplsMap, com.mappls.sdk.maps.Style, java.lang.String);
Expand Down Expand Up @@ -312,6 +313,9 @@ public final class com.mapconductor.mappls.marker.MapplsMarkerController extends
public void destroy();
public java.lang.Object update(java.lang.Object, kotlin.coroutines.Continuation);
}
final class com.mapconductor.mappls.marker.MapplsMarkerController$Companion {
public final long getTILE_REFRESH_COALESCE-UwyO8pc();
}
public final class com.mapconductor.mappls.marker.MapplsMarkerOverlayRenderer extends com.mapconductor.core.marker.AbstractMarkerOverlayRenderer<com.mapconductor.mappls.MapplsMapViewHolderInterface, com.mappls.sdk.geojson.Feature> {
public com.mapconductor.mappls.marker.MapplsMarkerOverlayRenderer(com.mapconductor.mappls.MapplsMapViewHolderInterface, com.mapconductor.core.marker.MarkerManager<com.mappls.sdk.geojson.Feature>, com.mapconductor.mappls.marker.MarkerLayer, com.mapconductor.mappls.marker.MarkerDragLayer, kotlinx.coroutines.CoroutineScope);
public com.mapconductor.mappls.marker.MapplsMarkerOverlayRenderer(com.mapconductor.mappls.MapplsMapViewHolderInterface, com.mapconductor.core.marker.MarkerManager, com.mapconductor.mappls.marker.MarkerLayer, com.mapconductor.mappls.marker.MarkerDragLayer, kotlinx.coroutines.CoroutineScope, int, kotlin.jvm.internal.DefaultConstructorMarker);
Expand Down Expand Up @@ -389,6 +393,7 @@ public final class com.mapconductor.mappls.polygon.MapplsPolygonController exten
public com.mapconductor.mappls.polygon.MapplsPolygonController(com.mapconductor.mappls.polygon.MapplsPolygonCompositeRenderer);
public com.mapconductor.mappls.polygon.MapplsPolygonCompositeRenderer getRenderer();
public int getZIndex();
public void destroy();
public com.mapconductor.core.polygon.PolygonOverlayRendererInterface getRenderer();
}
public final class com.mapconductor.mappls.polygon.MapplsPolygonLayer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import java.util.WeakHashMap
* オーバーレイの層をスタイルのどこへ入れるか([OverlayStacking] の帯の順)。
*
* 下から: ラスター < GroundImage < ポリゴン < サークル < ポリライン < マーカー
* (マーカーのタイルはマーカーの帯の一番下、ドラッグ中の層は一番上)。
* (マーカーのタイルはマーカーの帯の一番下、ドラッグ中の層は一番上。
* ポリゴンのタイルはポリゴンの帯の一番下)。
*
* 位置は毎回スタイルの今の並びから決めるので、追加した順・送り直し・
* スタイルの読み直し(デザイン変更)に左右されない。
Expand All @@ -35,6 +36,9 @@ internal object MapplsOverlayStacking {
/** マーカーのタイル(ラスター): マーカーの帯の一番下。 */
val MARKER_TILE = key(OverlayKind.Marker, Int.MIN_VALUE)

/** ポリゴンのタイル(ラスター): ポリゴンの帯の一番下。 */
val POLYGON_TILE = key(OverlayKind.Polygon, Int.MIN_VALUE)

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

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/mapconductor/mappls/MapplsViewController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import com.mapconductor.core.marker.OnMarkerEventHandler
import com.mapconductor.core.marker.StrategyMarkerController
import com.mapconductor.core.marker.dispatchGeoMarkerClick
import com.mapconductor.core.polygon.OnPolygonEventHandler
import com.mapconductor.core.polygon.POLYGON_TILE_LAYER_ID
import com.mapconductor.core.polygon.PolygonState
import com.mapconductor.core.polygon.PolygonTiler
import com.mapconductor.core.polygon.polygonTileRasterLayerState
import com.mapconductor.core.polyline.OnPolylineEventHandler
import com.mapconductor.mappls.circle.MapplsCircleController
import com.mapconductor.mappls.groundimage.MapplsGroundImageController
Expand Down Expand Up @@ -105,6 +108,19 @@ class MapplsViewController(
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)
}
}
}
}

fun setupListeners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ class MapplsPolygonOverlayRenderer(
return polygon
}

// Polygons drawn as tiles (PolygonController.tiler) stay in the manager, for
// taps, with no features: their entity's polygon is null.
@Suppress("USELESS_CAST")
private fun getAllPolygonEntities(): List<PolygonEntityInterface<MapplsActualPolygon>> =
polygonManager.allEntities()
polygonManager.allEntities().filter { (it.polygon as MapplsActualPolygon?) != null }

private fun getRemainingPolygonEntities(
removed: List<PolygonEntityInterface<MapplsActualPolygon>>,
): List<PolygonEntityInterface<MapplsActualPolygon>> {
val removedIds = removed.mapTo(HashSet()) { it.state.id }
return polygonManager.allEntities().filter { it.state.id !in removedIds }
return getAllPolygonEntities().filter { it.state.id !in removedIds }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapconductor.mappls.raster

import com.mapconductor.core.controller.OverlayKind
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
Expand All @@ -26,6 +27,8 @@ class MapplsRasterLayerOverlayRenderer(

private fun isMarkerTileRaster(state: RasterLayerState): Boolean = state.id.startsWith(MARKER_TILE_RASTER_ID_PREFIX)

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

override suspend fun onAdd(
data: List<RasterLayerOverlayRendererInterface.AddParamsInterface>,
): List<MapplsRasterLayerHandle?> =
Expand Down Expand Up @@ -101,7 +104,8 @@ class MapplsRasterLayerOverlayRenderer(

/**
* 帯の順([MapplsOverlayStacking])で足す。アプリのラスターはラスターの帯
* (一番下、ベースマップのラベルの下)、マーカーのタイルはマーカーの帯の一番下。
* (一番下、ベースマップのラベルの下)、マーカーのタイルはマーカーの帯の一番下、
* ポリゴンのタイルはポリゴンの帯の一番下(画像になったポリゴンであって、地図の画像ではない)。
*/
private fun addToStack(
style: com.mappls.sdk.maps.Style,
Expand All @@ -111,6 +115,8 @@ class MapplsRasterLayerOverlayRenderer(
val key =
if (isMarkerTileRaster(state)) {
MapplsOverlayStacking.MARKER_TILE
} else if (isPolygonTileRaster(state)) {
MapplsOverlayStacking.POLYGON_TILE
} else {
MapplsOverlayStacking.key(OverlayKind.RasterLayer, state.zIndex)
}
Expand Down Expand Up @@ -146,7 +152,7 @@ class MapplsRasterLayerOverlayRenderer(
val ordered =
stateById.values
.asSequence()
.filter { !isMarkerTileRaster(it) }
.filter { !isMarkerTileRaster(it) && !isPolygonTileRaster(it) }
.sortedBy { it.zIndex }
.mapNotNull { state -> handleById[state.id]?.let { handle -> state to handle } }
.toList()
Expand Down
Loading