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
14 changes: 14 additions & 0 deletions src/main/java/com/mapconductor/maptiler/MapTilerMapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,20 @@ fun MapTilerMapSurface(
onDispose { state.serviceRegistry.remove(MarkerRenderingSupportKey) }
}

// MTMapView destroys its WebView itself; the controller (tile-server
// routes, overlay managers, its coroutine scope) is ours to free. Keyed
// like the WebView, so a design change frees the one it replaces.
DisposableEffect(controller) {
onDispose {
controller.destroy()
// No MapViewBase here to do it: the state (which the app keeps) must
// not hold on to the destroyed controller and its overlays. Only if
// it is still the attached one -- after a design change the new
// controller is attached before this runs.
state.detachController(controller)
}
}

// 設定を渡すだけ。**タイル経路に倒すかはコントローラが件数を見て決める**
// (`shouldUseMarkerLayer`)。ここで `useMarkerLayer = markerTiling != null` と
// 書くと、しきい値未満の件数でもタイル経路に落ちてマーカーが 1 つも描かれない。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class MapTilerViewState(
MapTilerViewStateInterface {
private var _mapDesignType by mutableStateOf(mapDesignType)

private var controller: MapTilerMapViewController? = null
// Read through the base so that letting go of the controller there (MapViewBase
// does it when the map is torn down) leaves nothing behind here.
private val controller: MapTilerMapViewController?
get() = attachedMapController as? MapTilerMapViewController

override var mapDesignType: MapTilerMapDesignTypeInterface
get() = _mapDesignType
Expand All @@ -49,7 +52,6 @@ class MapTilerViewState(

/** MapView 生成時にコントローラを紐付ける。 */
fun setController(controller: MapTilerMapViewController) {
this.controller = controller
// 初期カメラは MTMapOptions で地図生成時に渡しているので、接続時には移動しない。
attachController(controller, moveToInitialCamera = false)
}
Expand Down
Loading