diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..671a084 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,6 @@ +{ + "attribution": { + "commit": "", + "pr": "" + } +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 19fd7f2..875c12a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,25 @@ jobs: - name: Show toolchain run: xcodebuild -version && swift --version + # Package.swift は `../ios-sdk-core` があればそれを使い、無ければ released 版 + # (`from: "1.1.4"`)へ解決する。CI はこのリポジトリしか checkout しないので + # 常に released 版になり、**コアの未リリースな変更に追随する PR は永久に赤いまま** + # になっていた(CameraBearing をコアへ足したときに踏んだ)。 + # 隣に置いてローカル開発と同じ経路に乗せる。同名ブランチがあればそちらを使う。 + - name: Check out MapConductorCore next to this package + env: + HEAD_REF: ${{ github.head_ref }} + run: | + url=https://github.com/MapConductor/ios-sdk-core.git + if [ -n "$HEAD_REF" ] && git ls-remote --exit-code --heads "$url" "$HEAD_REF" >/dev/null 2>&1; then + echo "ios-sdk-core: matching branch $HEAD_REF" + git clone --depth 1 --branch "$HEAD_REF" "$url" ../ios-sdk-core + else + echo "ios-sdk-core: default branch" + git clone --depth 1 "$url" ../ios-sdk-core + fi + test -f ../ios-sdk-core/Package.swift + - name: Build run: | scheme=$(sed -n 's/^[[:space:]]*name: "\([^"]*\)".*/\1/p' Package.swift | head -1) diff --git a/Package.swift b/Package.swift index 4114edf..1c60ce0 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ let frameworkLibraryType: Product.Library.LibraryType? = let usingLocalCore = FileManager.default.fileExists(atPath: "../ios-sdk-core/Package.swift") let coreDependency: Package.Dependency = usingLocalCore ? .package(path: "../ios-sdk-core") - : .package(url: "https://github.com/MapConductor/ios-sdk-core", from: "1.1.4") + : .package(url: "https://github.com/MapConductor/ios-sdk-core", from: "1.4.0") let package = Package( name: "mapconductor-for-mapkit", diff --git a/Sources/MapConductorForMapKit/MapCameraPositionExtensions.swift b/Sources/MapConductorForMapKit/MapCameraPositionExtensions.swift index e39a96c..1283bf7 100644 --- a/Sources/MapConductorForMapKit/MapCameraPositionExtensions.swift +++ b/Sources/MapConductorForMapKit/MapCameraPositionExtensions.swift @@ -1,6 +1,6 @@ import Foundation import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore private let converter = MapKitZoomAltitudeConverter(zoom0Altitude: 171_319_879.0) private let mapKitMaxPitch: Double = 80.9 @@ -8,6 +8,12 @@ private let mapConductorTileSizePoints: Double = 256.0 private let minCosLat: Double = 0.01 private let minCosTilt: Double = 0.05 +/// MapKit(iOS)のカメラの縦の視野角(度)。 +/// +/// MapKit は値を公開していない。iPad Pro 11 で、傾けた地図の中心と北の地点の画面位置から +/// 焦点距離を求めて実測した値(tilt 30°)。 +let mapKitVerticalFieldOfView: Double = 30.0 + // Convert from MapCameraPosition to MKMapCamera public extension MapCameraPosition { /// Pass the target map view so the camera distance is derived from the view's actual @@ -30,7 +36,7 @@ public extension MapCameraPosition { ? Spherical.computeOffset( origin: position, distance: distance * tan(pitchRadians), - heading: bearing + heading: CameraBearing.toNativeHeading(bearing) ) : position @@ -42,7 +48,7 @@ public extension MapCameraPosition { ), fromDistance: distance, pitch: nativePitch, - heading: bearing + heading: CameraBearing.toNativeHeading(bearing) ) } } @@ -54,7 +60,11 @@ public extension MKMapView { visibleRegion: VisibleRegion? = nil ) -> MapCameraPosition { let cameraAltitude = camera.altitude - let pitchRadians = camera.pitch * .pi / 180.0 + // `MKMapCamera.pitch` は CGFloat。CGFloat と Double の暗黙変換に任せると + // CoreGraphics の `cos(CGFloat)` と Foundation の `cos(Double)` が両方候補になり、 + // ツールチェーンによっては `ambiguous use of 'cos'` で落ちる(CI の macos-15 で踏んだ)。 + // 手元の Xcode では通ってしまうので、Double へ明示的に寄せておく。 + let pitchRadians = Double(camera.pitch) * .pi / 180.0 // Recover the slant distance set via MKMapCamera(fromDistance:) — the inverse of toMKMapCamera(). let slantDistance = cameraAltitude / max(cos(pitchRadians), minCosTilt) var position = GeoPoint( @@ -95,7 +105,7 @@ public extension MKMapView { return MapCameraPosition( position: position, zoom: zoom, - bearing: camera.heading, + bearing: CameraBearing.bearingFromNativeHeading(camera.heading), tilt: logicalTilt, visibleRegion: visibleRegion ) @@ -154,7 +164,11 @@ private extension MKMapView { /// from whatever camera happens to be set and reused to place the next one. func metersPerPointPerDistance() -> Double? { guard let metersPerPoint = measuredMetersPerPointAtCenter() else { return nil } - let pitchRadians = camera.pitch * .pi / 180.0 + // `MKMapCamera.pitch` は CGFloat。CGFloat と Double の暗黙変換に任せると + // CoreGraphics の `cos(CGFloat)` と Foundation の `cos(Double)` が両方候補になり、 + // ツールチェーンによっては `ambiguous use of 'cos'` で落ちる(CI の macos-15 で踏んだ)。 + // 手元の Xcode では通ってしまうので、Double へ明示的に寄せておく。 + let pitchRadians = Double(camera.pitch) * .pi / 180.0 let slantDistance = camera.altitude / max(cos(pitchRadians), minCosTilt) guard slantDistance > 0 else { return nil } let factor = metersPerPoint / slantDistance diff --git a/Sources/MapConductorForMapKit/MapKitMapView.swift b/Sources/MapConductorForMapKit/MapKitMapView.swift index a5772cf..b5db34f 100644 --- a/Sources/MapConductorForMapKit/MapKitMapView.swift +++ b/Sources/MapConductorForMapKit/MapKitMapView.swift @@ -1,6 +1,6 @@ import Combine import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore import QuartzCore import SwiftUI import UIKit @@ -9,6 +9,8 @@ public struct MapKitMapView: View { @ObservedObject private var state: MapKitViewState private let handlers: MapViewHandlers private let cameraRestriction: CameraRestriction? + private let style: MapViewStyle? + private let onStyleDiagnostics: (([String]) -> Void)? private let content: () -> MapViewContent public init( @@ -21,10 +23,18 @@ public struct MapKitMapView: View { onCameraMove: OnCameraMoveHandler? = nil, onCameraMoveEnd: OnCameraMoveHandler? = nil, sdkInitialize: (() -> Void)? = nil, + /// How the map looks, when the app states it rather than naming a + /// design. `MapConductorVectorStyle` builds one; what happens + /// underneath depends on this backend and the app does not have to + /// know. + style: MapViewStyle? = nil, + onStyleDiagnostics: (([String]) -> Void)? = nil, @MapViewContentBuilder content: @escaping () -> MapViewContent = { MapViewContent() } ) { self.state = state self.cameraRestriction = cameraRestriction + self.style = style + self.onStyleDiagnostics = onStyleDiagnostics self.handlers = MapViewHandlers( onMapLoaded: onMapLoaded, onMapClick: onMapClick, @@ -54,6 +64,8 @@ public struct MapKitMapView: View { state: state, cameraRestriction: cameraRestriction, handlers: handlers, + style: style, + onStyleDiagnostics: onStyleDiagnostics, content: mapContent ) } @@ -64,6 +76,8 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { @ObservedObject var state: MapKitViewState let cameraRestriction: CameraRestriction? let handlers: MapViewHandlers + let style: MapViewStyle? + let onStyleDiagnostics: (([String]) -> Void)? let content: MapViewContent func makeCoordinator() -> Coordinator { @@ -109,6 +123,9 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { } func updateUIView(_ uiView: MKMapView, context: Context) { + // Every evaluation of the app's `body` lands here; most calls do + // nothing. See `MapViewStyleHost.apply`. + context.coordinator.applyStyle(style, onDiagnostics: onStyleDiagnostics) // 制限値が変わったときだけ再適用する。 context.coordinator.applyCameraRestriction(cameraRestriction) uiView.mapType = state.mapDesignType.getValue() @@ -128,6 +145,7 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { } static func dismantleUIView(_ uiView: MKMapView, coordinator: Coordinator) { + coordinator.disposeStyle() coordinator.unbind() uiView.delegate = nil } @@ -168,11 +186,9 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { private weak var draggingAnnotationView: MKAnnotationView? private var dragDisplayLink: CADisplayLink? - // Store icon for each marker state to provide to delegate (best-effort cache). - // `mapView(_:viewFor:)` should not depend on this cache because it can be called - // before `updateContent` finishes populating it. - private var markerIcons: [String: BitmapIcon] = [:] - private var markerStates: [String: MarkerState] = [:] + /// アイコンを持たないマーカーの絵。1 枚を使い回す(`DefaultMarkerIcon()` を毎回作ると + /// そのたびに描き直しになる)。 + private let defaultBitmapIcon = DefaultMarkerIcon().toBitmapIcon() private lazy var strategyManager = StrategyMarkerManager( makeRenderer: { [weak self] strategy in @@ -253,6 +269,37 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { let rasterLayerController = MapKitRasterLayerController(mapView: mapView) self.rasterLayerController = rasterLayerController + // Many polygons are drawn into raster tiles and shown as one raster + // layer; taps still resolve against the original shapes. + let polygonTiler = PolygonTiler() + polygonTiler.onTemplate = { [weak rasterLayerController] template, tileSize in + if let template { + await rasterLayerController?.upsert(state: PolygonTiler.rasterLayerState(template: template, tileSize: tileSize)) + } else { + await rasterLayerController?.removeById(PolygonTiler.layerId) + } + } + polygonController.tiler = polygonTiler + // Many polylines likewise, in their own raster layer in the polyline band + // (under the natively drawn polylines); taps still resolve against the original lines. + let polylineTiler = PolylineTiler() + polylineTiler.onTemplate = { [weak rasterLayerController] template, tileSize in + if let template { + await rasterLayerController?.upsert(state: PolylineTiler.rasterLayerState(template: template, tileSize: tileSize)) + } else { + await rasterLayerController?.removeById(PolylineTiler.layerId) + } + } + polylineController.tiler = polylineTiler + let circleTiler = CircleTiler() + circleTiler.onTemplate = { [weak rasterLayerController] template, tileSize in + if let template { + await rasterLayerController?.upsert(state: CircleTiler.rasterLayerState(template: template, tileSize: tileSize)) + } else { + await rasterLayerController?.removeById(CircleTiler.layerId) + } + } + circleController.tiler = circleTiler let groundImageController = MapKitGroundImageController(mapView: mapView) self.groundImageController = groundImageController @@ -268,6 +315,7 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { controller.registerOverlayController(polygonController) controller.registerOverlayController(groundImageController) controller.registerOverlayController(rasterLayerController) + controller.clearOverlaysHandler = { [weak self] in await self?.clearOverlays() } let overlayScope = MapOverlayScope() self.overlayScope = overlayScope @@ -298,6 +346,19 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { } } + /// android-sdk の `clearOverlays()` と同じく、各オーバーレイのコントローラを空にする。 + /// `controller.clearOverlaysHandler` から呼ばれる。 + func clearOverlays() async { + await markerController?.clear() + await polylineController?.clear() + await polygonController?.clear() + await groundImageController?.clear() + await circleController?.clear() + await rasterLayerController?.clear() + // strategy(クラスタリングなど)が描いたマーカーも消す。 + await state.serviceRegistry.clearMarkerRendering() + } + func unbind() { // 登録した capability を取り下げる。レジストリの持ち主は state で、ビューより長生きするため、 // ここで外さないと破棄済みのコントローラを掴んだまま残る。 @@ -330,8 +391,6 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { groundImageController = nil overlayScope?.clear() overlayScope = nil - markerIcons.removeAll() - markerStates.removeAll() strategyMarkerIcons.removeAll() strategyManager.clear() @@ -341,23 +400,25 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { MCLog.map("MapKitMapView.updateContent markers=\(content.markers.count) circles=\(content.circles.count) polylines=\(content.polylines.count) polygons=\(content.polygons.count)") if let mapView { polylineController?.setCurrentCameraPosition(currentCameraPosition(from: mapView)) + circleController?.setCurrentCameraPosition(currentCameraPosition(from: mapView)) } infoBubbleCoordinator?.syncInfoBubbles(content.infoBubbles) - // Prime marker caches before triggering MKMapView annotation creation. - // (MapKit can ask for annotation views immediately after addAnnotation.) - markerIcons = content.markers.reduce(into: [:]) { dict, marker in - dict[marker.id] = (marker.state.icon ?? DefaultMarkerIcon()).toBitmapIcon() - } - markerStates = content.markers.reduce(into: [:]) { dict, marker in - dict[marker.id] = marker.state - } - + // マーカーは門番(MarkerListIdentity、syncMarkers の入口)を通るものだけを触る。 + // ここで全マーカーのアイコンや辞書を作ると、同じ一覧の再送でも body の評価ごとに + // 14.4 万本ぶん(@Published の icon の読み出しと、アイコンを持たないマーカーの + // 描き直し)が走り、門番が意味を失う。アイコンは `mapView(_:viewFor:)` が + // その場で state から引き、追加直後の state はコントローラが同期的に持っている。 markerController?.tilingOptions = content.markerTilingOptions markerController?.syncMarkers(content.markers) overlayScope?.circleCollector.sync(content.circles.map { $0.state }) overlayScope?.polylineCollector.sync(content.polylines.map { $0.state }) overlayScope?.polygonCollector.sync(content.polygons.map { $0.state }) + polygonController?.tiler?.refreshIfServerMoved() + if polylineController?.tiler?.setOptions(content.polylineTilingOptions) == true { overlayScope?.polylineCollector.flush() } + if circleController?.tiler?.setOptions(content.circleTilingOptions) == true { overlayScope?.circleCollector.flush() } + polylineController?.tiler?.refreshIfServerMoved() + circleController?.tiler?.refreshIfServerMoved() for handler in content.polygonSyncHandlers { let hullController = hullPolygonController handler.bindPolygonSync { [weak hullController] states in @@ -375,15 +436,18 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { isRegionChanging = true let camera = currentCameraPosition(from: mapView) polylineController?.setCurrentCameraPosition(camera) + circleController?.setCurrentCameraPosition(camera) controller?.notifyCameraMoveStart(camera) onCameraMoveStart?(camera) } func mapViewDidChangeVisibleRegion(_ mapView: MKMapView) { guard isRegionChanging else { return } - let camera = mapView.toMapCameraPosition(logicalTiltHint: controller?.lastLogicalTilt) + let raw = mapView.toMapCameraPosition(logicalTiltHint: controller?.lastLogicalTilt) + let camera = controller?.reportedCamera(raw, mapView: mapView) ?? raw state.updateCameraPosition(camera) polylineController?.setCurrentCameraPosition(camera) + circleController?.setCurrentCameraPosition(camera) controller?.notifyCameraMove(camera) onCameraMove?(camera) Task { [weak self] in @@ -402,6 +466,7 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { if controller?.applyCameraRestrictionCorrectionIfNeeded(camera) == true { return } state.updateCameraPosition(camera) polylineController?.setCurrentCameraPosition(camera) + circleController?.setCurrentCameraPosition(camera) controller?.notifyCameraMoveEnd(camera) onCameraMoveEnd?(camera) Task { [weak self] in @@ -424,6 +489,7 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { // Ensure polyline hit-testing uses the current zoom even if no region-change callbacks have fired yet. polylineController?.setCurrentCameraPosition(currentCameraPosition(from: mapView)) + circleController?.setCurrentCameraPosition(currentCameraPosition(from: mapView)) // If the user tapped a marker/annotation view, do not also fire map click. // (A tap gesture recognizer attached to MKMapView can still recognize taps on subviews.) @@ -481,17 +547,20 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { let mapConductorAnnotation = pointAnnotation as? MapConductorPointAnnotation let markerIdString = mapConductorAnnotation?.markerId ?? pointAnnotation.title ?? "" let markerState = markerController?.getMarkerState(for: markerIdString) - ?? markerStates[markerIdString] + ?? markerController?.syncedMarkerState(for: markerIdString) ?? strategyManager.controller?.markerManager.getEntity(markerIdString)?.state ?? mapConductorAnnotation?.markerState - let cachedIcon = markerIcons[markerIdString] ?? mapConductorAnnotation?.initialBitmapIcon - ?? strategyMarkerIcons[markerIdString] + // アイコンは state の今の値から引く(`toBitmapIcon()` はアイコンごとに描いた絵を + // 覚えているので軽い)。in-place で差し替えたアイコンも、ビューが作り直されたときに + // 古い絵へ戻らない。 + let stateIcon = markerState.map { $0.icon?.toBitmapIcon() ?? defaultBitmapIcon } + let fallbackIcon = mapConductorAnnotation?.initialBitmapIcon ?? strategyMarkerIcons[markerIdString] // If this isn't one of our markers, allow MapKit's default behavior. - if markerState == nil, cachedIcon == nil { return nil } + if markerState == nil, fallbackIcon == nil { return nil } // Avoid returning nil here; returning nil makes MapKit fall back to the default pin annotation. - let resolvedIcon = cachedIcon ?? (markerState?.icon ?? DefaultMarkerIcon()).toBitmapIcon() + let resolvedIcon = stateIcon ?? fallbackIcon ?? defaultBitmapIcon let identifier = "MapKitMarker" let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) @@ -499,7 +568,8 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { annotationView.annotation = annotation if let markerState { - if markerController?.getMarkerState(for: markerIdString) != nil || markerStates[markerIdString] != nil { + if markerController?.getMarkerState(for: markerIdString) != nil + || markerController?.syncedMarkerState(for: markerIdString) != nil { markerController?.renderer.configureAnnotationView(annotationView, for: markerState, bitmapIcon: resolvedIcon) } else { strategyManager.renderer?.configureAnnotationView(annotationView, for: markerState, bitmapIcon: resolvedIcon) @@ -514,6 +584,8 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { y: -(resolvedIcon.anchor.y - 0.5) * resolvedIcon.bitmap.size.height ) annotationView.alpha = 1 + // 使い回したビューに前のマーカーの順位を残さない。 + annotationView.zPriority = .defaultUnselected } return annotationView @@ -527,7 +599,7 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { guard let pointAnnotation = view.annotation as? MKPointAnnotation, let markerId = pointAnnotation.title, let markerState = markerController?.getMarkerState(for: markerId) - ?? markerStates[markerId] + ?? markerController?.syncedMarkerState(for: markerId) ?? strategyManager.controller?.markerManager.getEntity(markerId)?.state else { return } @@ -548,7 +620,7 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { guard let pointAnnotation = view.annotation as? MKPointAnnotation, let markerId = pointAnnotation.title, let markerState = markerController?.getMarkerState(for: markerId) - ?? markerStates[markerId] else { + ?? markerController?.syncedMarkerState(for: markerId) else { return } @@ -696,10 +768,11 @@ private struct MapKitMapViewRepresentable: UIViewRepresentable { farRight: geoPoint(at: CGPoint(x: mapView.bounds.maxX, y: 0), mapView: mapView) ) - return mapView.toMapCameraPosition( + let raw = mapView.toMapCameraPosition( logicalTiltHint: controller?.lastLogicalTilt, visibleRegion: visibleRegion ) + return controller?.reportedCamera(raw, mapView: mapView) ?? raw } private func geoPoint(at point: CGPoint, mapView: MKMapView) -> GeoPoint? { diff --git a/Sources/MapConductorForMapKit/MapKitOverlayStacking.swift b/Sources/MapConductorForMapKit/MapKitOverlayStacking.swift new file mode 100644 index 0000000..1b9a9ef --- /dev/null +++ b/Sources/MapConductorForMapKit/MapKitOverlayStacking.swift @@ -0,0 +1,62 @@ +import Foundation +import MapKit +@_spi(MapConductorDriver) import MapConductorCore + +/// オーバーレイを、重なり順の帯(``OverlayBand``)の位置へ差し込む。 +/// +/// 下から ラスター < グラウンドイメージ < ポリゴン < サークル < ポリライン < マーカーのタイル。 +/// MapKit は同じ level の中では足した順に重ねるので、以前は後から足したもの +/// (clearOverlays の後に送り直したグラウンドイメージなど)が上に来ていた。 +/// ここでは level の中の並びで帯の位置を計算して `insertOverlay(_:at:level:)` する。 +/// +/// ## level とラベル +/// +/// `addOverlay(_:)` の既定の level は `.aboveRoads`(ラベルの下)で、ポリゴン・サークル・ +/// ポリラインは以前からラベルの下にあった。一方ラスター・グラウンドイメージ・マーカーのタイルは +/// `.aboveLabels` で足していたので、**ラスターがポリゴン等より上**に描かれていた。 +/// 帯の順を守るには、ラスターとグラウンドイメージをポリゴン等と同じ level に置く必要がある。 +/// ここではポリゴン等のラベルとの関係を変えない方を選び、マーカーの帯以外はすべて +/// `.aboveRoads`、マーカーのタイルだけ `.aboveLabels` に置く。 +/// その結果ラスター(GL 系と同じくラベルの下になる)とグラウンドイメージ(以前はラベルの上)が +/// ラベルの下へ移る。 +/// +/// - マーカー(`MKAnnotation`)は MapKit が常にオーバーレイより上に描くので、帯の条件を満たす。 +/// - 帯の中の zIndex は足した時点の値で並べる(MapKit の描画担当は zIndex の変更を受けて +/// 並べ直さない。従来から未対応)。 +@MainActor +enum MapKitOverlayStacking { + static func level(for key: OverlayStackKey) -> MKOverlayLevel { + key.band == .marker ? .aboveLabels : .aboveRoads + } + + static func add(_ overlay: MKOverlay, _ key: OverlayStackKey, to mapView: MKMapView) { + let level = level(for: key) + let registry = keys(of: mapView) + registry.setObject(KeyBox(key), forKey: overlay) + let existing = mapView.overlays(in: level) + let keys = existing.map { (registry.object(forKey: $0) as KeyBox?)?.key } + let index = OverlayStacking.insertionIndex(for: key, among: keys) + if index >= existing.count { + mapView.addOverlay(overlay, level: level) + } else { + mapView.insertOverlay(overlay, at: index, level: level) + } + } + + private final class KeyBox: NSObject { + let key: OverlayStackKey + init(_ key: OverlayStackKey) { self.key = key } + } + + private static var registryKey: UInt8 = 0 + + /// 地図ごとの「オーバーレイ → 帯のキー」。オーバーレイは弱参照で持つので、外したものは自然に消える。 + private static func keys(of mapView: MKMapView) -> NSMapTable { + if let table = objc_getAssociatedObject(mapView, ®istryKey) as? NSMapTable { + return table + } + let table = NSMapTable.weakToStrongObjects() + objc_setAssociatedObject(mapView, ®istryKey, table, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + return table + } +} diff --git a/Sources/MapConductorForMapKit/circle/MapKitCircleOverlayRenderer.swift b/Sources/MapConductorForMapKit/circle/MapKitCircleOverlayRenderer.swift index 6a253bb..fc96261 100644 --- a/Sources/MapConductorForMapKit/circle/MapKitCircleOverlayRenderer.swift +++ b/Sources/MapConductorForMapKit/circle/MapKitCircleOverlayRenderer.swift @@ -1,6 +1,6 @@ import CoreLocation import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore import UIKit @MainActor @@ -36,7 +36,7 @@ final class MapKitCircleOverlayRenderer: AbstractCircleOverlayRenderer Void)? + func clearOverlays() async { - guard let mapView = mapView else { return } - mapView.removeAnnotations(mapView.annotations) - mapView.removeOverlays(mapView.overlays) + await clearOverlaysHandler?() } func setCameraMoveStartListener(listener: OnCameraMoveHandler?) { @@ -94,9 +101,11 @@ final class MapKitViewController: MapViewControllerProtocol { mapInitializedListener = listener } - func moveCamera(position: MapCameraPosition) { + func moveCamera(position requested: MapCameraPosition) { cancelCameraAnimation() guard let mapView = mapView else { return } + lastPaddings = requested.paddings + let position = paddingApplied(requested, mapView: mapView) lastLogicalTilt = position.tilt if abs(position.tilt) < 0.01, mapView.bounds.isEmpty { DispatchQueue.main.async { [weak self, weak mapView] in @@ -105,20 +114,26 @@ final class MapKitViewController: MapViewControllerProtocol { } } if applyTopDownZoom(position: position, mapView: mapView, animated: false) { + correctPaddedTarget(requested, mapView: mapView) return } let camera = position.toMKMapCamera(on: mapView) mapView.setCamera(camera, animated: false) + correctPaddedTarget(requested, mapView: mapView) } - func animateCamera(position: MapCameraPosition, duration: Long) { + func animateCamera(position requested: MapCameraPosition, duration: Long) { cancelCameraAnimation() guard let mapView = mapView else { return } let durationSeconds = Double(duration) / 1000.0 guard durationSeconds > 0 else { - moveCamera(position: position) + moveCamera(position: requested) return } + lastPaddings = requested.paddings + // 補間は「画面中心」の空間で行う(from も中心のまま読む)。 + let position = paddingApplied(requested, mapView: mapView) + cameraAnimationRequested = requested let from = mapView.toMapCameraPosition(logicalTiltHint: lastLogicalTilt) lastLogicalTilt = position.tilt @@ -228,12 +243,12 @@ final class MapKitViewController: MapViewControllerProtocol { // Use UIView.animate to respect the specified duration UIView.animate(withDuration: duration) { mapView.setVisibleMapRect(rect, edgePadding: .zero, animated: false) - Self.applyHeading(position.bearing, center: centerCoordinate, to: mapView, animated: false) + Self.applyHeading(CameraBearing.toNativeHeading(position.bearing), center: centerCoordinate, to: mapView, animated: false) } } else { // Use MapKit's default animation or no animation mapView.setVisibleMapRect(rect, edgePadding: .zero, animated: animated) - Self.applyHeading(position.bearing, center: centerCoordinate, to: mapView, animated: animated) + Self.applyHeading(CameraBearing.toNativeHeading(position.bearing), center: centerCoordinate, to: mapView, animated: animated) } return true @@ -263,6 +278,7 @@ final class MapKitViewController: MapViewControllerProtocol { } private func cancelCameraAnimation() { + cameraAnimationRequested = nil cameraAnimationDisplayLink?.invalidate() cameraAnimationDisplayLink = nil cameraAnimationFrames.removeAll() @@ -293,12 +309,63 @@ final class MapKitViewController: MapViewControllerProtocol { let frame = cameraAnimationFrames[targetIndex] applyCameraFrame(frame, mapView: mapView) } + if progress >= 1.0, let requested = cameraAnimationRequested { + cameraAnimationRequested = nil + correctPaddedTarget(requested, mapView: mapView) + } if progress >= 1.0 { cancelCameraAnimation() } } + /// MapKit へ渡すカメラ。パディングの分だけ中心をずらす。 + private func paddingApplied(_ position: MapCameraPosition, mapView: MKMapView) -> MapCameraPosition { + CameraPaddingEmulation.applied(to: position, fov: mapKitVerticalFieldOfView, viewportSize: mapView.bounds.size) + } + + /// MapKit から読み戻したカメラ(画面中心)を、ターゲット・パディング・視野角を持つカメラへ戻す。 + /// ターゲットはパディングの残りの中央にある地点を地図に直接聞く。 + func reportedCamera(_ camera: MapCameraPosition, mapView: MKMapView) -> MapCameraPosition { + CameraPaddingEmulation.restored( + camera, + paddings: lastPaddings, + fov: mapKitVerticalFieldOfView, + viewportSize: mapView.bounds.size, + unproject: { [weak mapView] point in + guard let mapView else { return nil } + let coordinate = mapView.convert(point, toCoordinateFrom: mapView) + return GeoPoint(latitude: coordinate.latitude, longitude: coordinate.longitude) + } + ) + } + + /// 計算で置いた中心だと、MapKit の縮尺のずれや pitch の上限(高度で変わる)でターゲットが + /// ずれる。地図の投影で実際の位置を測り、パディングの残りの中央に来るまで中心だけを動かし直す。 + private func correctPaddedTarget(_ requested: MapCameraPosition, mapView: MKMapView, remaining: Int = 3) { + guard remaining > 0 else { return } + let target = CLLocationCoordinate2D(latitude: requested.position.latitude, longitude: requested.position.longitude) + guard let center = CameraPaddingEmulation.correctedCenter( + target: requested.position, + paddings: requested.paddings, + viewportSize: mapView.bounds.size, + project: { _ in mapView.convert(target, toPointTo: mapView) }, + unproject: { point in + let coordinate = mapView.convert(point, toCoordinateFrom: mapView) + return GeoPoint(latitude: coordinate.latitude, longitude: coordinate.longitude) + } + ) else { return } + // 1 回ずつ次のランループで当てる。同じランループで続けて setCamera すると MapKit は + // 領域変更の通知をまとめてしまい、state に途中のカメラが残る。 + DispatchQueue.main.async { [weak self, weak mapView] in + guard let self, let mapView else { return } + let camera = mapView.camera.copy() as! MKMapCamera + camera.centerCoordinate = CLLocationCoordinate2D(latitude: center.latitude, longitude: center.longitude) + mapView.setCamera(camera, animated: false) + self.correctPaddedTarget(requested, mapView: mapView, remaining: remaining - 1) + } + } + private func applyCameraFrame(_ position: MapCameraPosition, mapView: MKMapView) { lastLogicalTilt = position.tilt // One-step move (no MapKit internal animation). This is the basis for our custom duration-controlled animation. diff --git a/Sources/MapConductorForMapKit/groundimage/MapKitGroundImageOverlayRenderer.swift b/Sources/MapConductorForMapKit/groundimage/MapKitGroundImageOverlayRenderer.swift index 44870e7..de2f3e0 100644 --- a/Sources/MapConductorForMapKit/groundimage/MapKitGroundImageOverlayRenderer.swift +++ b/Sources/MapConductorForMapKit/groundimage/MapKitGroundImageOverlayRenderer.swift @@ -1,6 +1,6 @@ import CoreLocation import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore import UIKit // Custom MKOverlay for ground images @@ -98,7 +98,7 @@ final class MapKitGroundImageOverlayRenderer: AbstractGroundImageOverlayRenderer renderersByStateId[state.id] = renderer overlaysByStateId[state.id] = overlay - mapView.addOverlay(overlay, level: .aboveLabels) + MapKitOverlayStacking.add(overlay, OverlayStackKey(.groundImage), to: mapView) return overlay } diff --git a/Sources/MapConductorForMapKit/marker/MapKitMarkerController.swift b/Sources/MapConductorForMapKit/marker/MapKitMarkerController.swift index c5d5d3b..9b19818 100644 --- a/Sources/MapConductorForMapKit/marker/MapKitMarkerController.swift +++ b/Sources/MapConductorForMapKit/marker/MapKitMarkerController.swift @@ -1,7 +1,7 @@ import Combine import CoreLocation import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore @MainActor final class MapKitMarkerController: AbstractMarkerController { @@ -21,8 +21,18 @@ final class MapKitMarkerController: AbstractMarkerController MarkerState? { + markerStatesById[id] + } + func getIcon(for state: MarkerState) -> BitmapIcon { let resolvedIcon = state.icon ?? DefaultMarkerIcon() return resolvedIcon.toBitmapIcon() @@ -107,6 +122,9 @@ final class MapKitMarkerController: AbstractMarkerController? private var tileRouteId: String? private var tiledMarkerIds: Set = [] + /// タイル URL の版。マーカーが変わるたびに上げ、地図に描画済みのタイルを取り直させる。 + private var tileVersion: Int64 = 0 + private var tileRefreshScheduled = false private var tileOverlay: MKTileOverlay? private var lastServerBaseUrl: String = "" private let defaultMarkerIconForTiling: BitmapIcon = DefaultMarkerIcon().toBitmapIcon() @@ -128,13 +146,43 @@ final class MapKitMarkerController: AbstractMarkerController Bool { MCLog.marker("MapKitMarkerController.handleTiledMarkerTap point=\(screenPoint) tiledCount=\(tiledMarkerIds.count)") guard !tiledMarkerIds.isEmpty, let mapView else { return false } - var bestState: MarkerState? = nil - var bestDist = CGFloat.infinity - - for id in tiledMarkerIds { - guard let entity = markerManager.getEntity(id), entity.state.clickable else { continue } - let coord = CLLocationCoordinate2D( - latitude: entity.state.position.latitude, - longitude: entity.state.position.longitude - ) - let markerPoint = mapView.convert(coord, toPointTo: mapView) - // アイコン矩形 + tapTolerance で判定する(android の `find()` と同じ)。 - // 以前は 44pt の固定半径で、アイコンの大きさを一切見ていなかったため、 - // 大きいアイコンは端をタップしても反応せず、小さいアイコンは離れていても反応していた。 - guard MarkerHitTest.hitsIcon( - touchScreen: screenPoint, - markerScreen: markerPoint, - state: entity.state - ) else { continue } - // 重なったマーカー同士は、アンカーがタップに近い方を優先する。 - let dist = hypot(screenPoint.x - markerPoint.x, screenPoint.y - markerPoint.y) - if dist < bestDist { - bestDist = dist - bestState = entity.state + // 選び方はコアの MarkerHitTest.pick と同じ。指の下にアイコン(ラベル込み)が描かれている + // マーカーを、アンカーの近い別のマーカーより優先する。 + let candidates = tiledMarkerIds.compactMap { markerManager.getEntity($0)?.state }.filter(\.clickable) + let bestState = MarkerHitTest.pick( + touchScreen: screenPoint, + candidates: candidates, + state: { $0 }, + project: { + mapView.convert( + CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude), + toPointTo: mapView + ) } - } + ) if let state = bestState { - MCLog.marker("MapKitMarkerController.handleTiledMarkerTap hit id=\(state.id) dist=\(bestDist)") + MCLog.marker("MapKitMarkerController.handleTiledMarkerTap hit id=\(state.id)") dispatchClick(state: state) return true } diff --git a/Sources/MapConductorForMapKit/marker/MapKitMarkerRenderer.swift b/Sources/MapConductorForMapKit/marker/MapKitMarkerRenderer.swift index b325ab9..a1ad08f 100644 --- a/Sources/MapConductorForMapKit/marker/MapKitMarkerRenderer.swift +++ b/Sources/MapConductorForMapKit/marker/MapKitMarkerRenderer.swift @@ -1,16 +1,18 @@ import CoreGraphics import CoreLocation import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore @MainActor -final class MapKitMarkerRenderer: MarkerOverlayRendererProtocol { +final class MapKitMarkerRenderer: MarkerOverlayRendererProtocol, MarkerDrawOrderFrameReceiver { typealias ActualMarker = MKPointAnnotation private static let maxConcurrentAnimations = 30 private static let minAnimationUpdateInterval: CFTimeInterval = 1.0 / 4.0 weak var mapView: MKMapView? + /// 重なり順を出すときの地図の向き(``MarkerDrawOrder``)。回すとコントローラが差し替える。 + private var drawOrderFrame: MarkerDrawOrder.Frame = .northUp private let markerManager: MarkerManager private var markerAnnotationViews: [String: MKAnnotationView] = [:] private var markerAnimationRunners: [String: MarkerAnimationRunner] = [:] @@ -283,6 +285,36 @@ final class MapKitMarkerRenderer: MarkerOverlayRendererProtocol { mapView = nil } + /// ``MarkerDrawOrder`` を MapKit の `zPriority`(Float、0...1000、既定 500、大きいほど手前)へ写す。 + /// + /// `500 + 5 × key`。zIndex は ±``zPriorityZIndexSpan`` に丸める(それを超える zIndex どうしは + /// 区別しない)。1 段を 5 にするのは、同じ zIndex の中の画面上の順位(key の小数部)を + /// Float でも数百 m 程度まで区別できるようにするため。選択中のビューは MapKit が + /// `selectedZPriority`(1000)へ上げる。 + static func zPriority( + for state: MarkerState, + frame: MarkerDrawOrder.Frame = .northUp + ) -> MKAnnotationViewZPriority { + let zIndex = state.zIndex.map { min(max($0, -zPriorityZIndexSpan), zPriorityZIndexSpan) } + let key = MarkerDrawOrder.key(zIndex: zIndex, position: state.position, frame: frame) + return MKAnnotationViewZPriority(rawValue: Float(500.0 + 5.0 * key)) + } + + /// 回したら、同じ zIndex の中の順位(画面で下ほど手前)を付け直す。画面外でビューの無い + /// マーカーは、ビューが付くときに ``configureAnnotationView(_:for:bitmapIcon:)`` が新しい向きで書く。 + func onDrawOrderFrameChanged(_ frame: MarkerDrawOrder.Frame, entities: [MarkerEntity]) async { + drawOrderFrame = frame + guard let mapView else { return } + for entity in entities { + guard let annotation = entity.marker, let view = mapView.view(for: annotation) else { continue } + let priority = Self.zPriority(for: entity.state, frame: frame) + if view.zPriority != priority { view.zPriority = priority } + } + } + + /// ``zPriority(for:)`` が区別する zIndex の絶対値の上限。 + static let zPriorityZIndexSpan = 99 + func configureAnnotationView(_ view: MKAnnotationView, for state: MarkerState, bitmapIcon: BitmapIcon) { view.image = bitmapIcon.bitmap view.isDraggable = state.draggable @@ -294,6 +326,9 @@ final class MapKitMarkerRenderer: MarkerOverlayRendererProtocol { // Store for later reference markerAnnotationViews[state.id] = view + // 重なり順。ビューは使い回されるので、毎回書く(書かないと前のマーカーの値が残る)。 + view.zPriority = Self.zPriority(for: state, frame: drawOrderFrame) + // Set anchor point based on icon anchor // MapKit's centerOffset is from the annotation coordinate to the view center // So y-axis needs to be inverted diff --git a/Sources/MapConductorForMapKit/polygon/MapKitPolygonOverlayRenderer.swift b/Sources/MapConductorForMapKit/polygon/MapKitPolygonOverlayRenderer.swift index 65e4726..3bfe79d 100644 --- a/Sources/MapConductorForMapKit/polygon/MapKitPolygonOverlayRenderer.swift +++ b/Sources/MapConductorForMapKit/polygon/MapKitPolygonOverlayRenderer.swift @@ -1,5 +1,5 @@ import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore import UIKit /// MapKit は穴(inner rings)をネイティブに描画できるため、ラスタタイルマスクは使わない @@ -48,7 +48,7 @@ final class MapKitPolygonOverlayRenderer: AbstractPolygonOverlayRenderer [CLLocationCoordinate2D] { - let geoPoints: [GeoPointProtocol] = geodesic - ? WGS84Geodesic.createInterpolatePoints(points) - : Planar.createInterpolatePoints(points) - return geoPoints.map { CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude) } + // 閉じる辺(末尾 → 先頭)も他の辺と同じく補間する(塗りと輪郭が同じ MKPolygon)。 + // geodesic は大圏、geodesic=false は緯度経度の線形補間(ポリラインの false と同じ線)。 + densifyPolygonRing(points, geodesic: geodesic).map { CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude) } } } diff --git a/Sources/MapConductorForMapKit/polyline/MapKitPolylineOverlayRenderer.swift b/Sources/MapConductorForMapKit/polyline/MapKitPolylineOverlayRenderer.swift index e37bbb3..e65c05f 100644 --- a/Sources/MapConductorForMapKit/polyline/MapKitPolylineOverlayRenderer.swift +++ b/Sources/MapConductorForMapKit/polyline/MapKitPolylineOverlayRenderer.swift @@ -1,5 +1,5 @@ import MapKit -import MapConductorCore +@_spi(MapConductorDriver) import MapConductorCore import UIKit @MainActor @@ -27,7 +27,7 @@ final class MapKitPolylineOverlayRenderer: AbstractPolylineOverlayRenderer { @@ -14,7 +14,7 @@ final class MapKitRasterLayerOverlayRenderer: AbstractRasterLayerOverlayRenderer override func createLayer(state: RasterLayerState) async -> MKTileOverlay? { guard let mapView else { return nil } - guard let overlay = await makeTileOverlay(from: state) else { return nil } + guard let overlay = await makeTileOverlay(from: state, displayScale: mapView.traitCollection.displayScale) else { return nil } overlayStates[overlay] = state let renderer = MKTileOverlayRenderer(tileOverlay: overlay) @@ -24,7 +24,7 @@ final class MapKitRasterLayerOverlayRenderer: AbstractRasterLayerOverlayRenderer // Important: MapKit may request a renderer immediately as part of addOverlay(). // Ensure we have the renderer registered before adding the overlay to the map. if state.visible { - mapView.addOverlay(overlay, level: .aboveLabels) + MapKitOverlayStacking.add(overlay, OverlayStacking.rasterKey(stateId: state.id, zIndex: state.zIndex), to: mapView) } return overlay @@ -56,7 +56,7 @@ final class MapKitRasterLayerOverlayRenderer: AbstractRasterLayerOverlayRenderer if finger.visible != prevFinger.visible { if current.state.visible { if layer.isKind(of: MKTileOverlay.self) && !mapView.overlays.contains(where: { $0 === layer }) { - mapView.addOverlay(layer, level: .aboveLabels) + MapKitOverlayStacking.add(layer, OverlayStacking.rasterKey(stateId: current.state.id, zIndex: current.state.zIndex), to: mapView) } } else { mapView.removeOverlay(layer) @@ -97,14 +97,18 @@ final class MapKitRasterLayerOverlayRenderer: AbstractRasterLayerOverlayRenderer mapView = nil } - private func makeTileOverlay(from state: RasterLayerState) async -> MKTileOverlay? { + private func makeTileOverlay(from state: RasterLayerState, displayScale: CGFloat) async -> MKTileOverlay? { let source = await resolveSource(state: state) switch source { case let .urlTemplate(template, tileSize, minZoom, maxZoom, _, scheme): + // RasterLayerSource expresses display size in points; MKTileOverlay + // expects pixels. Without the screen scale, Retina maps select a + // finer tile level and shrink the style's labels and road widths. + let pixelSize = max(1, Int((CGFloat(tileSize) * max(1, displayScale)).rounded())) let overlay = CustomURLTileOverlay( urlTemplate: template, - tileSize: tileSize, + tileSize: pixelSize, minZoom: minZoom, maxZoom: maxZoom, scheme: scheme, diff --git a/api/MapConductorForMapKit.api.swift b/api/MapConductorForMapKit.api.swift index 2dfbbb1..b909ad1 100644 --- a/api/MapConductorForMapKit.api.swift +++ b/api/MapConductorForMapKit.api.swift @@ -12,70 +12,70 @@ import _Concurrency import _MapKit_SwiftUI import _StringProcessing import _SwiftConcurrencyShims -extension MapConductorCore.MapCameraPosition { - final public func toMKMapCamera(on mapView: MapKit.MKMapView? = nil) -> MapKit.MKMapCamera +extension MapConductorCore::MapCameraPosition { + final public func toMKMapCamera(on mapView: MapKit::MKMapView? = nil) -> MapKit::MKMapCamera } -extension MapKit.MKMapView { - @_Concurrency.MainActor @preconcurrency public func toMapCameraPosition(logicalTiltHint: Swift.Double? = nil, visibleRegion: MapConductorCore.VisibleRegion? = nil) -> MapConductorCore.MapCameraPosition +extension MapKit::MKMapView { + @_Concurrency::MainActor @preconcurrency public func toMapCameraPosition(logicalTiltHint: Swift::Double? = nil, visibleRegion: MapConductorCore::VisibleRegion? = nil) -> MapConductorCore::MapCameraPosition } -public protocol MapKitMapDesignTypeProtocol : MapConductorCore.MapDesignTypeProtocol where Self.Identifier == MapKit.MKMapType { +public protocol MapKitMapDesignTypeProtocol : MapConductorCore::MapDesignTypeProtocol where Self.Identifier == MapKit::MKMapType { } -public typealias MapKitMapDesignType = any MapConductorForMapKit.MapKitMapDesignTypeProtocol -public struct MapKitMapDesign : MapConductorForMapKit.MapKitMapDesignTypeProtocol, Swift.Hashable { - public let id: MapKit.MKMapType - public let attributionRules: [MapConductorCore.AttributionRule] - public init(id: MapKit.MKMapType, attributionRules: [MapConductorCore.AttributionRule] = []) - public func getValue() -> MapKit.MKMapType - public static let Standard: MapConductorForMapKit.MapKitMapDesign - public static let Satellite: MapConductorForMapKit.MapKitMapDesign - public static let Hybrid: MapConductorForMapKit.MapKitMapDesign - public static let SatelliteFlyover: MapConductorForMapKit.MapKitMapDesign - public static let HybridFlyover: MapConductorForMapKit.MapKitMapDesign - public static let MutedStandard: MapConductorForMapKit.MapKitMapDesign - public static func Create(id: MapKit.MKMapType) -> MapConductorForMapKit.MapKitMapDesign - public static func toMapDesignType(id: MapKit.MKMapType) -> MapConductorForMapKit.MapKitMapDesignType - public static func == (a: MapConductorForMapKit.MapKitMapDesign, b: MapConductorForMapKit.MapKitMapDesign) -> Swift.Bool - public typealias Identifier = MapKit.MKMapType - public func hash(into hasher: inout Swift.Hasher) - public var hashValue: Swift.Int { +public typealias MapKitMapDesignType = any MapConductorForMapKit::MapKitMapDesignTypeProtocol +public struct MapKitMapDesign : MapConductorForMapKit::MapKitMapDesignTypeProtocol, Swift::Hashable { + public let id: MapKit::MKMapType + public let attributionRules: [MapConductorCore::AttributionRule] + public init(id: MapKit::MKMapType, attributionRules: [MapConductorCore::AttributionRule] = []) + public func getValue() -> MapKit::MKMapType + public static let Standard: MapConductorForMapKit::MapKitMapDesign + public static let Satellite: MapConductorForMapKit::MapKitMapDesign + public static let Hybrid: MapConductorForMapKit::MapKitMapDesign + public static let SatelliteFlyover: MapConductorForMapKit::MapKitMapDesign + public static let HybridFlyover: MapConductorForMapKit::MapKitMapDesign + public static let MutedStandard: MapConductorForMapKit::MapKitMapDesign + public static func Create(id: MapKit::MKMapType) -> MapConductorForMapKit::MapKitMapDesign + public static func toMapDesignType(id: MapKit::MKMapType) -> MapConductorForMapKit::MapKitMapDesignType + public static func == (a: MapConductorForMapKit::MapKitMapDesign, b: MapConductorForMapKit::MapKitMapDesign) -> Swift::Bool + public typealias Identifier = MapKit::MKMapType + public func hash(into hasher: inout Swift::Hasher) + public var hashValue: Swift::Int { get } } -@_Concurrency.MainActor @preconcurrency public struct MapKitMapView : SwiftUICore.View { - @_Concurrency.MainActor @preconcurrency public init(state: MapConductorForMapKit.MapKitViewState, cameraRestriction: MapConductorCore.CameraRestriction? = nil, onMapLoaded: MapConductorCore.OnMapLoadedHandler? = nil, onMapClick: MapConductorCore.OnMapEventHandler? = nil, onMapLongClick: MapConductorCore.OnMapEventHandler? = nil, onCameraMoveStart: MapConductorCore.OnCameraMoveHandler? = nil, onCameraMove: MapConductorCore.OnCameraMoveHandler? = nil, onCameraMoveEnd: MapConductorCore.OnCameraMoveHandler? = nil, sdkInitialize: (() -> Swift.Void)? = nil, @MapConductorCore.MapViewContentBuilder content: @escaping () -> MapConductorCore.MapViewContent = { MapViewContent() }) - @_Concurrency.MainActor @preconcurrency public var body: some SwiftUICore.View { +@_Concurrency::MainActor @preconcurrency public struct MapKitMapView : SwiftUICore::View { + @_Concurrency::MainActor @preconcurrency public init(state: MapConductorForMapKit::MapKitViewState, cameraRestriction: MapConductorCore::CameraRestriction? = nil, onMapLoaded: MapConductorCore::OnMapLoadedHandler? = nil, onMapClick: MapConductorCore::OnMapEventHandler? = nil, onMapLongClick: MapConductorCore::OnMapEventHandler? = nil, onCameraMoveStart: MapConductorCore::OnCameraMoveHandler? = nil, onCameraMove: MapConductorCore::OnCameraMoveHandler? = nil, onCameraMoveEnd: MapConductorCore::OnCameraMoveHandler? = nil, sdkInitialize: (() -> Swift::Void)? = nil, style: (any MapConductorCore::MapViewStyle)? = nil, onStyleDiagnostics: (([Swift::String]) -> Swift::Void)? = nil, @MapConductorCore::MapViewContentBuilder content: @escaping () -> MapConductorCore::MapViewContent = { MapViewContent() }) + @_Concurrency::MainActor @preconcurrency public var body: some SwiftUICore::View { get } public typealias Body = @_opaqueReturnTypeOf("$s015MapConductorForA3Kit0adA4ViewV4bodyQrvp", 0) __ } -public typealias MapKitActualMarker = MapKit.MKPointAnnotation -public typealias MapKitActualPolyline = MapKit.MKPolyline -public typealias MapKitActualCircle = MapKit.MKCircle -public typealias MapKitActualPolygon = MapKit.MKPolygon -final public class MapKitViewState : MapConductorCore.MapViewState { - final public var mapViewHolder: MapConductorForMapKit.MapKitViewHolder? { +public typealias MapKitActualMarker = MapKit::MKPointAnnotation +public typealias MapKitActualPolyline = MapKit::MKPolyline +public typealias MapKitActualCircle = MapKit::MKCircle +public typealias MapKitActualPolygon = MapKit::MKPolygon +final public class MapKitViewState : MapConductorCore::MapViewState { + final public var mapViewHolder: MapConductorForMapKit::MapKitViewHolder? { get } - override final public var mapDesignType: MapConductorForMapKit.MapKitMapDesignType { + override final public var mapDesignType: MapConductorForMapKit::MapKitMapDesignType { get set } - public init(id: Swift.String, mapDesignType: MapConductorForMapKit.MapKitMapDesignType = MapKitMapDesign.Standard, cameraPosition: MapConductorCore.MapCameraPosition = .Default, uiSettings: MapConductorCore.MapUISettings = MapUISettings()) - convenience public init(mapDesignType: MapConductorForMapKit.MapKitMapDesignType = MapKitMapDesign.Standard, cameraPosition: MapConductorCore.MapCameraPosition = .Default, uiSettings: MapConductorCore.MapUISettings = MapUISettings()) - override final public func getMapViewHolder() -> MapConductorCore.AnyMapViewHolder? + public init(id: Swift::String, mapDesignType: MapConductorForMapKit::MapKitMapDesignType = MapKitMapDesign.Standard, cameraPosition: MapConductorCore::MapCameraPosition = .Default, uiSettings: MapConductorCore::MapUISettings = MapUISettings()) + convenience public init(mapDesignType: MapConductorForMapKit::MapKitMapDesignType = MapKitMapDesign.Standard, cameraPosition: MapConductorCore::MapCameraPosition = .Default, uiSettings: MapConductorCore::MapUISettings = MapUISettings()) + override final public func getMapViewHolder() -> MapConductorCore::AnyMapViewHolder? @objc deinit } -public class MapKitZoomAltitudeConverter : MapConductorCore.WebMercatorZoomAltitudeConverter { - public init(zoom0Altitude: Swift.Double = AbstractZoomAltitudeConverter.defaultZoom0Altitude) +public class MapKitZoomAltitudeConverter : MapConductorCore::WebMercatorZoomAltitudeConverter { + public init(zoom0Altitude: Swift::Double = AbstractZoomAltitudeConverter.defaultZoom0Altitude) @objc deinit } -@_hasMissingDesignatedInitializers final public class MapKitViewHolder : MapConductorCore.MapViewHolderProtocol { - final public let mapView: MapKit.MKMapView - final public let map: MapKit.MKMapView - final public func toScreenOffset(position: any MapConductorCore.GeoPointProtocol) -> CoreFoundation.CGPoint? - final public func fromScreenOffsetSync(offset: CoreFoundation.CGPoint) -> MapConductorCore.GeoPoint? - public typealias ActualMap = MapKit.MKMapView - public typealias ActualMapView = MapKit.MKMapView +@_hasMissingDesignatedInitializers final public class MapKitViewHolder : MapConductorCore::MapViewHolderProtocol { + final public let mapView: MapKit::MKMapView + final public let map: MapKit::MKMapView + final public func toScreenOffset(position: any MapConductorCore::GeoPointProtocol) -> CoreFoundation::CGPoint? + final public func fromScreenOffsetSync(offset: CoreFoundation::CGPoint) -> MapConductorCore::GeoPoint? + public typealias ActualMap = MapKit::MKMapView + public typealias ActualMapView = MapKit::MKMapView @objc deinit } -extension MapConductorForMapKit.MapKitMapView : Swift.Sendable {} +extension MapConductorForMapKit::MapKitMapView : Swift::Sendable {}