Skip to content
Merged
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
18 changes: 18 additions & 0 deletions Sources/MapConductorForHERE/HereMapHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,17 @@ public final class HereMapHost: MapViewCoordinatorBase<HereMapViewState>, Marker
applyStrategyRendering(nil)
}

/// `clearOverlays()` から呼ばれる。strategy は接続したまま、描いたマーカーだけを消す。
/// 同じインスタンスの一覧が送られている間は描かず、顔ぶれが変わるか作り直された state が
/// 来たら描き直す(StrategyMarkerManager.clearMarkers・オーバーレイのコレクタと同じ)。
public func clearMarkers() async {
strategyClearedUntilListChanges = true
await strategyMarkerController?.clear()
}

/// ``clearMarkers()`` の後、一覧が変わるまで描かない印。
private var strategyClearedUntilListChanges = false

public func beginContentPass() {
strategyConnectedThisPass = false
}
Expand All @@ -340,6 +351,7 @@ public final class HereMapHost: MapViewCoordinatorBase<HereMapViewState>, Marker
let renderer = HereMarkerRenderer(mapView: mapView)
strategyMarkerRenderer = renderer
strategyMarkerController = StrategyMarkerController(strategy: strategy, renderer: renderer)
strategyClearedUntilListChanges = false
// find() の android 同等 screen 空間判定用に geo→screen 投影を注入する。
strategyMarkerController?.markerProjector = { [weak self] geo in
guard let mapView = self?.mapView,
Expand Down Expand Up @@ -380,6 +392,10 @@ public final class HereMapHost: MapViewCoordinatorBase<HereMapViewState>, Marker
newStatesById[state.id] = state
}
strategyMarkerStatesById = newStatesById
if strategyClearedUntilListChanges {
guard shouldSyncList else { return }
strategyClearedUntilListChanges = false
}

for id in oldIds.subtracting(newIds) {
strategyMarkerSubscriptions[id]?.cancel()
Expand Down Expand Up @@ -457,6 +473,8 @@ public final class HereMapHost: MapViewCoordinatorBase<HereMapViewState>, Marker
await groundImageController?.clear()
await circleController?.clear()
await rasterLayerController?.clear()
// strategy(クラスタリングなど)が描いたマーカーも消す。
await state.serviceRegistry.clearMarkerRendering()
}

public func unbind() {
Expand Down