@granite-js/naver-map 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/GraniteNaverMap.podspec +81 -0
- package/android/build.gradle +160 -0
- package/android/gradle.properties +5 -0
- package/android/src/builtinProvider/java/run/granite/navermap/builtinProvider/BuiltInGraniteNaverMapProvider.kt +549 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/run/granite/navermap/GraniteNaverMapEvents.kt +91 -0
- package/android/src/main/java/run/granite/navermap/GraniteNaverMapPackage.kt +16 -0
- package/android/src/main/java/run/granite/navermap/GraniteNaverMapProvider.kt +242 -0
- package/android/src/main/java/run/granite/navermap/GraniteNaverMapRegistry.kt +116 -0
- package/android/src/main/java/run/granite/navermap/GraniteNaverMapView.kt +732 -0
- package/android/src/newarch/java/run/granite/navermap/GraniteNaverMapViewManager.kt +446 -0
- package/android/src/oldarch/java/run/granite/navermap/GraniteNaverMapViewManager.kt +249 -0
- package/dist/module/NaverMapView.js +110 -0
- package/dist/module/NaverMapView.js.map +1 -0
- package/dist/module/index.js +6 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/internals/colorUtils.js +624 -0
- package/dist/module/internals/colorUtils.js.map +1 -0
- package/dist/module/internals/context.js +8 -0
- package/dist/module/internals/context.js.map +1 -0
- package/dist/module/internals/id.js +10 -0
- package/dist/module/internals/id.js.map +1 -0
- package/dist/module/internals/useMapOverlay.js +44 -0
- package/dist/module/internals/useMapOverlay.js.map +1 -0
- package/dist/module/internals/usePreservedReference.js +36 -0
- package/dist/module/internals/usePreservedReference.js.map +1 -0
- package/dist/module/overlays/ArrowheadPath.js +37 -0
- package/dist/module/overlays/ArrowheadPath.js.map +1 -0
- package/dist/module/overlays/Circle.js +35 -0
- package/dist/module/overlays/Circle.js.map +1 -0
- package/dist/module/overlays/GroundOverlay.js +30 -0
- package/dist/module/overlays/GroundOverlay.js.map +1 -0
- package/dist/module/overlays/InfoWindow.js +32 -0
- package/dist/module/overlays/InfoWindow.js.map +1 -0
- package/dist/module/overlays/Marker.js +37 -0
- package/dist/module/overlays/Marker.js.map +1 -0
- package/dist/module/overlays/Path.js +41 -0
- package/dist/module/overlays/Path.js.map +1 -0
- package/dist/module/overlays/Polygon.js +51 -0
- package/dist/module/overlays/Polygon.js.map +1 -0
- package/dist/module/overlays/Polyline.js +60 -0
- package/dist/module/overlays/Polyline.js.map +1 -0
- package/dist/module/overlays/index.js +11 -0
- package/dist/module/overlays/index.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/specs/GraniteNaverMapViewNativeComponent.ts +352 -0
- package/dist/module/types/Coord.js +2 -0
- package/dist/module/types/Coord.js.map +1 -0
- package/dist/module/types/index.js +29 -0
- package/dist/module/types/index.js.map +1 -0
- package/dist/typescript/NaverMapView.d.ts +41 -0
- package/dist/typescript/index.d.ts +3 -0
- package/dist/typescript/internals/colorUtils.d.ts +10 -0
- package/dist/typescript/internals/context.d.ts +8 -0
- package/dist/typescript/internals/id.d.ts +1 -0
- package/dist/typescript/internals/useMapOverlay.d.ts +15 -0
- package/dist/typescript/internals/usePreservedReference.d.ts +6 -0
- package/dist/typescript/overlays/ArrowheadPath.d.ts +11 -0
- package/dist/typescript/overlays/Circle.d.ts +10 -0
- package/dist/typescript/overlays/GroundOverlay.d.ts +11 -0
- package/dist/typescript/overlays/InfoWindow.d.ts +14 -0
- package/dist/typescript/overlays/Marker.d.ts +16 -0
- package/dist/typescript/overlays/Path.d.ts +15 -0
- package/dist/typescript/overlays/Polygon.d.ts +10 -0
- package/dist/typescript/overlays/Polyline.d.ts +11 -0
- package/dist/typescript/overlays/index.d.ts +16 -0
- package/dist/typescript/specs/GraniteNaverMapViewNativeComponent.d.ts +92 -0
- package/dist/typescript/types/Coord.d.ts +4 -0
- package/dist/typescript/types/index.d.ts +55 -0
- package/ios/GraniteNaverMap-Bridging-Header.h +20 -0
- package/ios/GraniteNaverMapProvider.swift +312 -0
- package/ios/GraniteNaverMapRegistry.swift +91 -0
- package/ios/GraniteNaverMapView.h +15 -0
- package/ios/GraniteNaverMapView.mm +390 -0
- package/ios/GraniteNaverMapViewImpl.swift +496 -0
- package/ios/GraniteNaverMapViewManager.m +67 -0
- package/ios/GraniteNaverMapViewManager.swift +133 -0
- package/ios/GraniteNaverMapViewWrapper.swift +215 -0
- package/ios/builtinProvider/BuiltInNaverMapProvider.swift +489 -0
- package/ios/builtinProvider/GraniteNaverMapMarkerData.swift +66 -0
- package/ios/builtinProvider/NMFMarker+Extension.swift +65 -0
- package/ios/builtinProvider/RCTConvert+NMFMapView.h +17 -0
- package/ios/builtinProvider/RCTConvert+NMFMapView.m +67 -0
- package/package.json +103 -0
- package/src/NaverMapView.tsx +168 -0
- package/src/index.tsx +3 -0
- package/src/internals/colorUtils.ts +697 -0
- package/src/internals/context.ts +14 -0
- package/src/internals/id.ts +9 -0
- package/src/internals/useMapOverlay.ts +59 -0
- package/src/internals/usePreservedReference.ts +41 -0
- package/src/overlays/ArrowheadPath.ts +71 -0
- package/src/overlays/Circle.ts +68 -0
- package/src/overlays/GroundOverlay.ts +62 -0
- package/src/overlays/InfoWindow.ts +68 -0
- package/src/overlays/Marker.ts +83 -0
- package/src/overlays/Path.ts +87 -0
- package/src/overlays/Polygon.ts +83 -0
- package/src/overlays/Polyline.ts +93 -0
- package/src/overlays/index.ts +23 -0
- package/src/specs/GraniteNaverMapViewNativeComponent.ts +352 -0
- package/src/types/Coord.ts +4 -0
- package/src/types/index.ts +78 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
//
|
|
2
|
+
// GraniteNaverMapViewImpl.swift
|
|
3
|
+
// granite-naver-map
|
|
4
|
+
//
|
|
5
|
+
// Provider-based implementation of NaverMapView (no direct NMapsMap dependency)
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import UIKit
|
|
9
|
+
|
|
10
|
+
@objc public protocol GraniteNaverMapViewDelegate: AnyObject {
|
|
11
|
+
@objc func mapViewDidInitialize()
|
|
12
|
+
@objc func mapViewDidChangeCamera(latitude: Double, longitude: Double, zoom: Double)
|
|
13
|
+
@objc func mapViewDidTouch(reason: Int, animated: Bool)
|
|
14
|
+
@objc func mapViewDidClick(x: Double, y: Double, latitude: Double, longitude: Double)
|
|
15
|
+
@objc func mapViewDidClickMarker(id: String)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@objc public class GraniteNaverMapViewImpl: UIView {
|
|
19
|
+
@objc public weak var eventDelegate: GraniteNaverMapViewDelegate?
|
|
20
|
+
|
|
21
|
+
private var provider: GraniteNaverMapProvidable?
|
|
22
|
+
private var mapContentView: UIView?
|
|
23
|
+
private var isInitialized = false
|
|
24
|
+
|
|
25
|
+
public override init(frame: CGRect) {
|
|
26
|
+
super.init(frame: frame)
|
|
27
|
+
setupProvider()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
required init?(coder: NSCoder) {
|
|
31
|
+
fatalError("init(coder:) has not been implemented")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private func setupProvider() {
|
|
35
|
+
// Create a new provider instance for this view
|
|
36
|
+
guard let provider = GraniteNaverMapRegistry.shared.createProvider() else {
|
|
37
|
+
// No provider factory available - show placeholder or error
|
|
38
|
+
let label = UILabel(frame: bounds)
|
|
39
|
+
label.text = "NaverMap provider not registered"
|
|
40
|
+
label.textAlignment = .center
|
|
41
|
+
label.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
42
|
+
addSubview(label)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
self.provider = provider
|
|
47
|
+
provider.setDelegate(self)
|
|
48
|
+
|
|
49
|
+
let mapView = provider.createMapView(frame: bounds)
|
|
50
|
+
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
51
|
+
addSubview(mapView)
|
|
52
|
+
self.mapContentView = mapView
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public override func layoutSubviews() {
|
|
56
|
+
super.layoutSubviews()
|
|
57
|
+
if !isInitialized && bounds.width > 0 && bounds.height > 0 {
|
|
58
|
+
isInitialized = true
|
|
59
|
+
eventDelegate?.mapViewDidInitialize()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// MARK: - Property Setters
|
|
64
|
+
|
|
65
|
+
@objc public func setCenter(latitude: Double, longitude: Double, zoom: Double, tilt: Double, bearing: Double) {
|
|
66
|
+
let position = GraniteNaverMapCameraPosition(
|
|
67
|
+
target: GraniteNaverMapCoordinate(latitude: latitude, longitude: longitude),
|
|
68
|
+
zoom: zoom,
|
|
69
|
+
tilt: tilt,
|
|
70
|
+
bearing: bearing
|
|
71
|
+
)
|
|
72
|
+
provider?.moveCamera(to: position, animated: false)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@objc public func setMapType(_ type: Int) {
|
|
76
|
+
guard let mapType = GraniteNaverMapType(rawValue: type) else { return }
|
|
77
|
+
provider?.setMapType(mapType)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@objc public var mapPadding: UIEdgeInsets = .zero {
|
|
81
|
+
didSet {
|
|
82
|
+
provider?.setMapPadding(mapPadding)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@objc public var compass: Bool = true {
|
|
87
|
+
didSet {
|
|
88
|
+
provider?.setCompassEnabled(compass)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@objc public var scaleBar: Bool = true {
|
|
93
|
+
didSet {
|
|
94
|
+
provider?.setScaleBarEnabled(scaleBar)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@objc public var zoomControl: Bool = true {
|
|
99
|
+
didSet {
|
|
100
|
+
provider?.setZoomControlEnabled(zoomControl)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@objc public var buildingHeight: Float = 1.0 {
|
|
105
|
+
didSet {
|
|
106
|
+
provider?.setBuildingHeight(buildingHeight)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@objc public var nightMode: Bool = false {
|
|
111
|
+
didSet {
|
|
112
|
+
provider?.setNightModeEnabled(nightMode)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@objc public var minZoomLevel: Double = 0 {
|
|
117
|
+
didSet {
|
|
118
|
+
provider?.setMinZoomLevel(minZoomLevel)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@objc public var maxZoomLevel: Double = 21 {
|
|
123
|
+
didSet {
|
|
124
|
+
provider?.setMaxZoomLevel(maxZoomLevel)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@objc public var scrollGesturesEnabled: Bool = true {
|
|
129
|
+
didSet {
|
|
130
|
+
provider?.setScrollGesturesEnabled(scrollGesturesEnabled)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@objc public var tiltGesturesEnabled: Bool = true {
|
|
135
|
+
didSet {
|
|
136
|
+
provider?.setTiltGesturesEnabled(tiltGesturesEnabled)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@objc public var rotateGesturesEnabled: Bool = true {
|
|
141
|
+
didSet {
|
|
142
|
+
provider?.setRotateGesturesEnabled(rotateGesturesEnabled)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@objc public var stopGesturesEnabled: Bool = true {
|
|
147
|
+
didSet {
|
|
148
|
+
provider?.setStopGesturesEnabled(stopGesturesEnabled)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@objc public var locationTrackingMode: Int = 0 {
|
|
153
|
+
didSet {
|
|
154
|
+
guard let mode = GraniteNaverMapLocationTrackingMode(rawValue: locationTrackingMode) else { return }
|
|
155
|
+
provider?.setLocationTrackingMode(mode)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@objc public var showsMyLocationButton: Bool = false {
|
|
160
|
+
didSet {
|
|
161
|
+
provider?.setLocationButtonEnabled(showsMyLocationButton)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@objc public var zoomGesturesEnabled: Bool = true {
|
|
166
|
+
didSet {
|
|
167
|
+
provider?.setZoomGesturesEnabled(zoomGesturesEnabled)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// MARK: - Commands
|
|
172
|
+
|
|
173
|
+
@objc public func animateToCoordinate(latitude: Double, longitude: Double) {
|
|
174
|
+
let coord = GraniteNaverMapCoordinate(latitude: latitude, longitude: longitude)
|
|
175
|
+
provider?.animateToCoordinate(coord)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@objc public func animateToTwoCoordinates(lat1: Double, lng1: Double, lat2: Double, lng2: Double) {
|
|
179
|
+
let bounds = GraniteNaverMapBounds(
|
|
180
|
+
southWest: GraniteNaverMapCoordinate(latitude: min(lat1, lat2), longitude: min(lng1, lng2)),
|
|
181
|
+
northEast: GraniteNaverMapCoordinate(latitude: max(lat1, lat2), longitude: max(lng1, lng2))
|
|
182
|
+
)
|
|
183
|
+
provider?.animateToBounds(bounds, padding: 24.0)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@objc public func animateToRegion(latitude: Double, longitude: Double, latitudeDelta: Double, longitudeDelta: Double) {
|
|
187
|
+
let bounds = GraniteNaverMapBounds(
|
|
188
|
+
southWest: GraniteNaverMapCoordinate(latitude: latitude - latitudeDelta / 2, longitude: longitude - longitudeDelta / 2),
|
|
189
|
+
northEast: GraniteNaverMapCoordinate(latitude: latitude + latitudeDelta / 2, longitude: longitude + longitudeDelta / 2)
|
|
190
|
+
)
|
|
191
|
+
provider?.animateToBounds(bounds, padding: 0)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@objc public func setLayerGroupEnabled(group: String, enabled: Bool) {
|
|
195
|
+
provider?.setLayerGroupEnabled(group: group, enabled: enabled)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// MARK: - Marker Commands
|
|
199
|
+
|
|
200
|
+
@objc public func addMarker(identifier: String, latitude: Double, longitude: Double, width: Int, height: Int, zIndex: Int, rotation: Float, flat: Bool, alpha: Float, pinColor: Int, image: String) {
|
|
201
|
+
let data = ProviderMarkerData(
|
|
202
|
+
identifier: identifier,
|
|
203
|
+
coordinate: GraniteNaverMapCoordinate(latitude: latitude, longitude: longitude),
|
|
204
|
+
width: width,
|
|
205
|
+
height: height,
|
|
206
|
+
zIndex: zIndex,
|
|
207
|
+
rotation: rotation,
|
|
208
|
+
flat: flat,
|
|
209
|
+
alpha: alpha,
|
|
210
|
+
pinColor: pinColor,
|
|
211
|
+
image: image
|
|
212
|
+
)
|
|
213
|
+
provider?.addMarker(data)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@objc public func updateMarker(identifier: String, latitude: Double, longitude: Double, width: Int, height: Int, zIndex: Int, rotation: Float, flat: Bool, alpha: Float, pinColor: Int, image: String) {
|
|
217
|
+
let data = ProviderMarkerData(
|
|
218
|
+
identifier: identifier,
|
|
219
|
+
coordinate: GraniteNaverMapCoordinate(latitude: latitude, longitude: longitude),
|
|
220
|
+
width: width,
|
|
221
|
+
height: height,
|
|
222
|
+
zIndex: zIndex,
|
|
223
|
+
rotation: rotation,
|
|
224
|
+
flat: flat,
|
|
225
|
+
alpha: alpha,
|
|
226
|
+
pinColor: pinColor,
|
|
227
|
+
image: image
|
|
228
|
+
)
|
|
229
|
+
provider?.updateMarker(data)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@objc public func removeMarker(identifier: String) {
|
|
233
|
+
provider?.removeMarker(identifier: identifier)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// MARK: - Polyline Commands
|
|
237
|
+
|
|
238
|
+
private func parseCoordinates(_ json: String) -> [GraniteNaverMapCoordinate] {
|
|
239
|
+
guard let data = json.data(using: .utf8),
|
|
240
|
+
let coords = try? JSONSerialization.jsonObject(with: data) as? [[String: Double]] else {
|
|
241
|
+
return []
|
|
242
|
+
}
|
|
243
|
+
return coords.compactMap { coord in
|
|
244
|
+
guard let lat = coord["latitude"], let lng = coord["longitude"] else { return nil }
|
|
245
|
+
return GraniteNaverMapCoordinate(latitude: lat, longitude: lng)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private func parsePattern(_ json: String) -> [Int] {
|
|
250
|
+
guard let data = json.data(using: .utf8),
|
|
251
|
+
let pattern = try? JSONSerialization.jsonObject(with: data) as? [Int] else {
|
|
252
|
+
return []
|
|
253
|
+
}
|
|
254
|
+
return pattern
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@objc public func addPolyline(identifier: String, coordsJson: String, strokeWidth: Float, strokeColor: Int, zIndex: Int, lineCap: Int, lineJoin: Int, patternJson: String) {
|
|
258
|
+
let coords = parseCoordinates(coordsJson)
|
|
259
|
+
guard coords.count >= 2 else { return }
|
|
260
|
+
|
|
261
|
+
let data = ProviderPolylineData(
|
|
262
|
+
identifier: identifier,
|
|
263
|
+
coordinates: coords,
|
|
264
|
+
strokeWidth: strokeWidth,
|
|
265
|
+
strokeColor: strokeColor,
|
|
266
|
+
zIndex: zIndex,
|
|
267
|
+
lineCap: lineCap,
|
|
268
|
+
lineJoin: lineJoin,
|
|
269
|
+
pattern: parsePattern(patternJson)
|
|
270
|
+
)
|
|
271
|
+
provider?.addPolyline(data)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@objc public func updatePolyline(identifier: String, coordsJson: String, strokeWidth: Float, strokeColor: Int, zIndex: Int, lineCap: Int, lineJoin: Int, patternJson: String) {
|
|
275
|
+
let coords = parseCoordinates(coordsJson)
|
|
276
|
+
guard coords.count >= 2 else { return }
|
|
277
|
+
|
|
278
|
+
let data = ProviderPolylineData(
|
|
279
|
+
identifier: identifier,
|
|
280
|
+
coordinates: coords,
|
|
281
|
+
strokeWidth: strokeWidth,
|
|
282
|
+
strokeColor: strokeColor,
|
|
283
|
+
zIndex: zIndex,
|
|
284
|
+
lineCap: lineCap,
|
|
285
|
+
lineJoin: lineJoin,
|
|
286
|
+
pattern: parsePattern(patternJson)
|
|
287
|
+
)
|
|
288
|
+
provider?.updatePolyline(data)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@objc public func removePolyline(identifier: String) {
|
|
292
|
+
provider?.removePolyline(identifier: identifier)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// MARK: - Polygon Commands
|
|
296
|
+
|
|
297
|
+
private func parseHoles(_ json: String) -> [[GraniteNaverMapCoordinate]] {
|
|
298
|
+
guard let data = json.data(using: .utf8),
|
|
299
|
+
let holes = try? JSONSerialization.jsonObject(with: data) as? [[[String: Double]]] else {
|
|
300
|
+
return []
|
|
301
|
+
}
|
|
302
|
+
return holes.map { hole in
|
|
303
|
+
hole.compactMap { coord in
|
|
304
|
+
guard let lat = coord["latitude"], let lng = coord["longitude"] else { return nil }
|
|
305
|
+
return GraniteNaverMapCoordinate(latitude: lat, longitude: lng)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
@objc public func addPolygon(identifier: String, coordsJson: String, holesJson: String, fillColor: Int, strokeColor: Int, strokeWidth: Float, zIndex: Int) {
|
|
311
|
+
let coords = parseCoordinates(coordsJson)
|
|
312
|
+
guard coords.count >= 3 else { return }
|
|
313
|
+
|
|
314
|
+
let data = ProviderPolygonData(
|
|
315
|
+
identifier: identifier,
|
|
316
|
+
coordinates: coords,
|
|
317
|
+
holes: parseHoles(holesJson),
|
|
318
|
+
fillColor: fillColor,
|
|
319
|
+
strokeColor: strokeColor,
|
|
320
|
+
strokeWidth: strokeWidth,
|
|
321
|
+
zIndex: zIndex
|
|
322
|
+
)
|
|
323
|
+
provider?.addPolygon(data)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@objc public func updatePolygon(identifier: String, coordsJson: String, holesJson: String, fillColor: Int, strokeColor: Int, strokeWidth: Float, zIndex: Int) {
|
|
327
|
+
let coords = parseCoordinates(coordsJson)
|
|
328
|
+
guard coords.count >= 3 else { return }
|
|
329
|
+
|
|
330
|
+
let data = ProviderPolygonData(
|
|
331
|
+
identifier: identifier,
|
|
332
|
+
coordinates: coords,
|
|
333
|
+
holes: parseHoles(holesJson),
|
|
334
|
+
fillColor: fillColor,
|
|
335
|
+
strokeColor: strokeColor,
|
|
336
|
+
strokeWidth: strokeWidth,
|
|
337
|
+
zIndex: zIndex
|
|
338
|
+
)
|
|
339
|
+
provider?.updatePolygon(data)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
@objc public func removePolygon(identifier: String) {
|
|
343
|
+
provider?.removePolygon(identifier: identifier)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// MARK: - Circle Commands
|
|
347
|
+
|
|
348
|
+
@objc public func addCircle(identifier: String, latitude: Double, longitude: Double, radius: Double, fillColor: Int, strokeColor: Int, strokeWidth: Float, zIndex: Int) {
|
|
349
|
+
let data = ProviderCircleData(
|
|
350
|
+
identifier: identifier,
|
|
351
|
+
center: GraniteNaverMapCoordinate(latitude: latitude, longitude: longitude),
|
|
352
|
+
radius: radius,
|
|
353
|
+
fillColor: fillColor,
|
|
354
|
+
strokeColor: strokeColor,
|
|
355
|
+
strokeWidth: strokeWidth,
|
|
356
|
+
zIndex: zIndex
|
|
357
|
+
)
|
|
358
|
+
provider?.addCircle(data)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@objc public func updateCircle(identifier: String, latitude: Double, longitude: Double, radius: Double, fillColor: Int, strokeColor: Int, strokeWidth: Float, zIndex: Int) {
|
|
362
|
+
let data = ProviderCircleData(
|
|
363
|
+
identifier: identifier,
|
|
364
|
+
center: GraniteNaverMapCoordinate(latitude: latitude, longitude: longitude),
|
|
365
|
+
radius: radius,
|
|
366
|
+
fillColor: fillColor,
|
|
367
|
+
strokeColor: strokeColor,
|
|
368
|
+
strokeWidth: strokeWidth,
|
|
369
|
+
zIndex: zIndex
|
|
370
|
+
)
|
|
371
|
+
provider?.updateCircle(data)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
@objc public func removeCircle(identifier: String) {
|
|
375
|
+
provider?.removeCircle(identifier: identifier)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// MARK: - Path Commands
|
|
379
|
+
|
|
380
|
+
@objc public func addPath(identifier: String, coordsJson: String, width: Float, outlineWidth: Float, color: Int, outlineColor: Int, passedColor: Int, passedOutlineColor: Int, patternImage: String, patternInterval: Int, progress: Float, zIndex: Int) {
|
|
381
|
+
let coords = parseCoordinates(coordsJson)
|
|
382
|
+
guard coords.count >= 2 else { return }
|
|
383
|
+
|
|
384
|
+
let data = ProviderPathData(
|
|
385
|
+
identifier: identifier,
|
|
386
|
+
coordinates: coords,
|
|
387
|
+
width: width,
|
|
388
|
+
outlineWidth: outlineWidth,
|
|
389
|
+
color: color,
|
|
390
|
+
outlineColor: outlineColor,
|
|
391
|
+
passedColor: passedColor,
|
|
392
|
+
passedOutlineColor: passedOutlineColor,
|
|
393
|
+
patternImage: patternImage,
|
|
394
|
+
patternInterval: patternInterval,
|
|
395
|
+
progress: progress,
|
|
396
|
+
zIndex: zIndex
|
|
397
|
+
)
|
|
398
|
+
provider?.addPath(data)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
@objc public func updatePath(identifier: String, coordsJson: String, width: Float, outlineWidth: Float, color: Int, outlineColor: Int, passedColor: Int, passedOutlineColor: Int, patternImage: String, patternInterval: Int, progress: Float, zIndex: Int) {
|
|
402
|
+
let coords = parseCoordinates(coordsJson)
|
|
403
|
+
guard coords.count >= 2 else { return }
|
|
404
|
+
|
|
405
|
+
let data = ProviderPathData(
|
|
406
|
+
identifier: identifier,
|
|
407
|
+
coordinates: coords,
|
|
408
|
+
width: width,
|
|
409
|
+
outlineWidth: outlineWidth,
|
|
410
|
+
color: color,
|
|
411
|
+
outlineColor: outlineColor,
|
|
412
|
+
passedColor: passedColor,
|
|
413
|
+
passedOutlineColor: passedOutlineColor,
|
|
414
|
+
patternImage: patternImage,
|
|
415
|
+
patternInterval: patternInterval,
|
|
416
|
+
progress: progress,
|
|
417
|
+
zIndex: zIndex
|
|
418
|
+
)
|
|
419
|
+
provider?.updatePath(data)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
@objc public func removePath(identifier: String) {
|
|
423
|
+
provider?.removePath(identifier: identifier)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// MARK: - ArrowheadPath Commands (delegated to Path for now)
|
|
427
|
+
|
|
428
|
+
@objc public func addArrowheadPath(identifier: String, coordsJson: String, width: Float, outlineWidth: Float, color: Int, outlineColor: Int, headSizeRatio: Float, zIndex: Int) {
|
|
429
|
+
// ArrowheadPath uses the same path API with default passed colors
|
|
430
|
+
addPath(identifier: identifier, coordsJson: coordsJson, width: width, outlineWidth: outlineWidth, color: color, outlineColor: outlineColor, passedColor: color, passedOutlineColor: outlineColor, patternImage: "", patternInterval: 0, progress: 0, zIndex: zIndex)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@objc public func updateArrowheadPath(identifier: String, coordsJson: String, width: Float, outlineWidth: Float, color: Int, outlineColor: Int, headSizeRatio: Float, zIndex: Int) {
|
|
434
|
+
updatePath(identifier: identifier, coordsJson: coordsJson, width: width, outlineWidth: outlineWidth, color: color, outlineColor: outlineColor, passedColor: color, passedOutlineColor: outlineColor, patternImage: "", patternInterval: 0, progress: 0, zIndex: zIndex)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
@objc public func removeArrowheadPath(identifier: String) {
|
|
438
|
+
removePath(identifier: identifier)
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// MARK: - GroundOverlay Commands (requires provider extension)
|
|
442
|
+
|
|
443
|
+
@objc public func addGroundOverlay(identifier: String, southWestLat: Double, southWestLng: Double, northEastLat: Double, northEastLng: Double, image: String, alpha: Float, zIndex: Int) {
|
|
444
|
+
// TODO: Add ground overlay support to provider protocol
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
@objc public func updateGroundOverlay(identifier: String, southWestLat: Double, southWestLng: Double, northEastLat: Double, northEastLng: Double, image: String, alpha: Float, zIndex: Int) {
|
|
448
|
+
// TODO: Add ground overlay support to provider protocol
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
@objc public func removeGroundOverlay(identifier: String) {
|
|
452
|
+
// TODO: Add ground overlay support to provider protocol
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// MARK: - InfoWindow Commands (requires provider extension)
|
|
456
|
+
|
|
457
|
+
@objc public func addInfoWindow(identifier: String, latitude: Double, longitude: Double, text: String, alpha: Float, zIndex: Int, offsetX: Int, offsetY: Int) {
|
|
458
|
+
// TODO: Add info window support to provider protocol
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
@objc public func updateInfoWindow(identifier: String, latitude: Double, longitude: Double, text: String, alpha: Float, zIndex: Int, offsetX: Int, offsetY: Int) {
|
|
462
|
+
// TODO: Add info window support to provider protocol
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
@objc public func removeInfoWindow(identifier: String) {
|
|
466
|
+
// TODO: Add info window support to provider protocol
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// MARK: - GraniteNaverMapProviderDelegate
|
|
471
|
+
|
|
472
|
+
extension GraniteNaverMapViewImpl: GraniteNaverMapProviderDelegate {
|
|
473
|
+
public func mapViewDidInitialize() {
|
|
474
|
+
eventDelegate?.mapViewDidInitialize()
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
public func mapViewDidChangeCamera(position: GraniteNaverMapCameraPosition) {
|
|
478
|
+
eventDelegate?.mapViewDidChangeCamera(
|
|
479
|
+
latitude: position.target.latitude,
|
|
480
|
+
longitude: position.target.longitude,
|
|
481
|
+
zoom: position.zoom
|
|
482
|
+
)
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
public func mapViewDidTouch(reason: Int, animated: Bool) {
|
|
486
|
+
eventDelegate?.mapViewDidTouch(reason: reason, animated: animated)
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
public func mapViewDidClick(x: Double, y: Double, latitude: Double, longitude: Double) {
|
|
490
|
+
eventDelegate?.mapViewDidClick(x: x, y: y, latitude: latitude, longitude: longitude)
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
public func mapViewDidClickMarker(id: String) {
|
|
494
|
+
eventDelegate?.mapViewDidClickMarker(id: id)
|
|
495
|
+
}
|
|
496
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// GraniteNaverMapViewManager.m
|
|
3
|
+
// granite-naver-map
|
|
4
|
+
//
|
|
5
|
+
// Old Architecture bridge (no direct NMapsMap dependency)
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTBridge.h>
|
|
9
|
+
#import <React/RCTViewManager.h>
|
|
10
|
+
|
|
11
|
+
@interface RCT_EXTERN_MODULE(GraniteNaverMapViewManager, RCTViewManager)
|
|
12
|
+
|
|
13
|
+
RCT_EXPORT_VIEW_PROPERTY(showsMyLocationButton, BOOL)
|
|
14
|
+
RCT_EXPORT_VIEW_PROPERTY(mapPadding, UIEdgeInsets)
|
|
15
|
+
RCT_EXPORT_VIEW_PROPERTY(mapType, int)
|
|
16
|
+
RCT_EXPORT_VIEW_PROPERTY(compass, BOOL)
|
|
17
|
+
RCT_EXPORT_VIEW_PROPERTY(scaleBar, BOOL)
|
|
18
|
+
RCT_EXPORT_VIEW_PROPERTY(zoomControl, BOOL)
|
|
19
|
+
RCT_EXPORT_VIEW_PROPERTY(buildingHeight, float)
|
|
20
|
+
RCT_EXPORT_VIEW_PROPERTY(nightMode, BOOL)
|
|
21
|
+
RCT_EXPORT_VIEW_PROPERTY(minZoomLevel, double)
|
|
22
|
+
RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, double)
|
|
23
|
+
RCT_EXPORT_VIEW_PROPERTY(scrollGesturesEnabled, BOOL)
|
|
24
|
+
RCT_EXPORT_VIEW_PROPERTY(zoomGesturesEnabled, BOOL)
|
|
25
|
+
RCT_EXPORT_VIEW_PROPERTY(tiltGesturesEnabled, BOOL)
|
|
26
|
+
RCT_EXPORT_VIEW_PROPERTY(rotateGesturesEnabled, BOOL)
|
|
27
|
+
RCT_EXPORT_VIEW_PROPERTY(stopGesturesEnabled, BOOL)
|
|
28
|
+
RCT_EXPORT_VIEW_PROPERTY(tilt, BOOL)
|
|
29
|
+
RCT_EXPORT_VIEW_PROPERTY(onInitialized, RCTDirectEventBlock)
|
|
30
|
+
RCT_EXPORT_VIEW_PROPERTY(onCameraChange, RCTDirectEventBlock)
|
|
31
|
+
RCT_EXPORT_VIEW_PROPERTY(onTouch, RCTDirectEventBlock)
|
|
32
|
+
RCT_EXPORT_VIEW_PROPERTY(onMapClick, RCTDirectEventBlock)
|
|
33
|
+
RCT_EXPORT_VIEW_PROPERTY(onMarkerClick, RCTDirectEventBlock)
|
|
34
|
+
RCT_EXPORT_VIEW_PROPERTY(locationTrackingMode, int)
|
|
35
|
+
|
|
36
|
+
RCT_EXTERN_METHOD(setLayerGroupEnabled:(nonnull NSNumber *)reactTag
|
|
37
|
+
withGroup:(NSString *)group
|
|
38
|
+
withEnabled:(BOOL)enabled)
|
|
39
|
+
|
|
40
|
+
RCT_EXTERN_METHOD(animateToCoordinate:(nonnull NSNumber *)reactTag
|
|
41
|
+
withLatitude:(double)latitude
|
|
42
|
+
withLongitude:(double)longitude)
|
|
43
|
+
|
|
44
|
+
RCT_EXTERN_METHOD(animateToTwoCoordinates:(nonnull NSNumber *)reactTag
|
|
45
|
+
withLat1:(double)lat1
|
|
46
|
+
withLng1:(double)lng1
|
|
47
|
+
withLat2:(double)lat2
|
|
48
|
+
withLng2:(double)lng2)
|
|
49
|
+
|
|
50
|
+
RCT_EXTERN_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
|
|
51
|
+
withLatitude:(double)latitude
|
|
52
|
+
withLongitude:(double)longitude
|
|
53
|
+
withLatitudeDelta:(double)latitudeDelta
|
|
54
|
+
withLongitudeDelta:(double)longitudeDelta)
|
|
55
|
+
|
|
56
|
+
RCT_EXTERN_METHOD(addMarker:(nonnull NSNumber *)reactTag
|
|
57
|
+
identifier:(NSString *)identifier
|
|
58
|
+
markerData:(NSDictionary *)markerData)
|
|
59
|
+
|
|
60
|
+
RCT_EXTERN_METHOD(updateMarker:(nonnull NSNumber *)reactTag
|
|
61
|
+
identifier:(NSString *)identifier
|
|
62
|
+
markerData:(NSDictionary *)markerData)
|
|
63
|
+
|
|
64
|
+
RCT_EXTERN_METHOD(removeMarker:(nonnull NSNumber *)reactTag
|
|
65
|
+
identifier:(NSString *)identifier)
|
|
66
|
+
|
|
67
|
+
@end
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
//
|
|
2
|
+
// GraniteNaverMapViewManager.swift
|
|
3
|
+
// granite-naver-map
|
|
4
|
+
//
|
|
5
|
+
// Old Architecture ViewManager (no direct NMapsMap dependency)
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import React
|
|
9
|
+
import UIKit
|
|
10
|
+
|
|
11
|
+
@objc(GraniteNaverMapViewManager)
|
|
12
|
+
class GraniteNaverMapViewManager: RCTViewManager {
|
|
13
|
+
|
|
14
|
+
override func view() -> UIView! {
|
|
15
|
+
let mapView = GraniteNaverMapView(frame: CGRect(x: 0, y: 0, width: 200, height: 300))
|
|
16
|
+
mapView.bridge = bridge
|
|
17
|
+
return mapView
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
21
|
+
false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@objc static func performActionWithView(
|
|
25
|
+
reactTag: NSNumber,
|
|
26
|
+
bridge: RCTBridge,
|
|
27
|
+
action: @escaping (GraniteNaverMapView) -> Void
|
|
28
|
+
) {
|
|
29
|
+
bridge.uiManager.addUIBlock { (_, viewRegistry) in
|
|
30
|
+
guard let view = viewRegistry?[reactTag] as? GraniteNaverMapView else {
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
action(view)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static let layerGroups: [String: String] = [
|
|
38
|
+
"building": "building",
|
|
39
|
+
"ctt": "traffic",
|
|
40
|
+
"transit": "transit",
|
|
41
|
+
"bike": "bicycle",
|
|
42
|
+
"mountain": "mountain",
|
|
43
|
+
"landparcel": "cadastral"
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
@objc(setLayerGroupEnabled:withGroup:withEnabled:)
|
|
47
|
+
func setLayerGroupEnabled(_ reactTag: NSNumber, withGroup group: String, withEnabled enabled: Bool) {
|
|
48
|
+
Self.performActionWithView(reactTag: reactTag, bridge: bridge) { view in
|
|
49
|
+
view.setLayerGroupEnabled(group: group, enabled: enabled)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@objc(animateToCoordinate:withLatitude:withLongitude:)
|
|
54
|
+
func animateToCoordinate(_ reactTag: NSNumber, withLatitude latitude: Double, withLongitude longitude: Double) {
|
|
55
|
+
Self.performActionWithView(reactTag: reactTag, bridge: bridge) { view in
|
|
56
|
+
let coord = GraniteNaverMapCoordinate(latitude: latitude, longitude: longitude)
|
|
57
|
+
view.animateToCoordinate(coord)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@objc(animateToTwoCoordinates:withLat1:withLng1:withLat2:withLng2:)
|
|
62
|
+
func animateToTwoCoordinates(_ reactTag: NSNumber, withLat1 lat1: Double, withLng1 lng1: Double, withLat2 lat2: Double, withLng2 lng2: Double) {
|
|
63
|
+
Self.performActionWithView(reactTag: reactTag, bridge: bridge) { view in
|
|
64
|
+
let bounds = GraniteNaverMapBounds(
|
|
65
|
+
southWest: GraniteNaverMapCoordinate(latitude: min(lat1, lat2), longitude: min(lng1, lng2)),
|
|
66
|
+
northEast: GraniteNaverMapCoordinate(latitude: max(lat1, lat2), longitude: max(lng1, lng2))
|
|
67
|
+
)
|
|
68
|
+
view.animateToBounds(bounds, padding: 24.0)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@objc(animateToRegion:withLatitude:withLongitude:withLatitudeDelta:withLongitudeDelta:)
|
|
73
|
+
func animateToRegion(_ reactTag: NSNumber, withLatitude latitude: Double, withLongitude longitude: Double, withLatitudeDelta latitudeDelta: Double, withLongitudeDelta longitudeDelta: Double) {
|
|
74
|
+
Self.performActionWithView(reactTag: reactTag, bridge: bridge) { view in
|
|
75
|
+
let bounds = GraniteNaverMapBounds(
|
|
76
|
+
southWest: GraniteNaverMapCoordinate(latitude: latitude - latitudeDelta / 2, longitude: longitude - longitudeDelta / 2),
|
|
77
|
+
northEast: GraniteNaverMapCoordinate(latitude: latitude + latitudeDelta / 2, longitude: longitude + longitudeDelta / 2)
|
|
78
|
+
)
|
|
79
|
+
view.animateToBounds(bounds, padding: 0)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@objc(addMarker:identifier:markerData:)
|
|
84
|
+
func addMarker(_ reactTag: NSNumber, identifier: String, markerData: [String: Any]) {
|
|
85
|
+
Self.performActionWithView(reactTag: reactTag, bridge: bridge) { view in
|
|
86
|
+
let data = ProviderMarkerData(
|
|
87
|
+
identifier: identifier,
|
|
88
|
+
coordinate: GraniteNaverMapCoordinate(
|
|
89
|
+
latitude: markerData["latitude"] as? Double ?? 0,
|
|
90
|
+
longitude: markerData["longitude"] as? Double ?? 0
|
|
91
|
+
),
|
|
92
|
+
width: markerData["width"] as? Int ?? 0,
|
|
93
|
+
height: markerData["height"] as? Int ?? 0,
|
|
94
|
+
zIndex: markerData["zIndex"] as? Int ?? 0,
|
|
95
|
+
rotation: markerData["rotation"] as? Float ?? 0,
|
|
96
|
+
flat: markerData["flat"] as? Bool ?? false,
|
|
97
|
+
alpha: markerData["alpha"] as? Float ?? 1,
|
|
98
|
+
pinColor: markerData["pinColor"] as? Int ?? 0,
|
|
99
|
+
image: markerData["image"] as? String ?? ""
|
|
100
|
+
)
|
|
101
|
+
view.addMarker(data)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@objc(updateMarker:identifier:markerData:)
|
|
106
|
+
func updateMarker(_ reactTag: NSNumber, identifier: String, markerData: [String: Any]) {
|
|
107
|
+
Self.performActionWithView(reactTag: reactTag, bridge: bridge) { view in
|
|
108
|
+
let data = ProviderMarkerData(
|
|
109
|
+
identifier: identifier,
|
|
110
|
+
coordinate: GraniteNaverMapCoordinate(
|
|
111
|
+
latitude: markerData["latitude"] as? Double ?? 0,
|
|
112
|
+
longitude: markerData["longitude"] as? Double ?? 0
|
|
113
|
+
),
|
|
114
|
+
width: markerData["width"] as? Int ?? 0,
|
|
115
|
+
height: markerData["height"] as? Int ?? 0,
|
|
116
|
+
zIndex: markerData["zIndex"] as? Int ?? 0,
|
|
117
|
+
rotation: markerData["rotation"] as? Float ?? 0,
|
|
118
|
+
flat: markerData["flat"] as? Bool ?? false,
|
|
119
|
+
alpha: markerData["alpha"] as? Float ?? 1,
|
|
120
|
+
pinColor: markerData["pinColor"] as? Int ?? 0,
|
|
121
|
+
image: markerData["image"] as? String ?? ""
|
|
122
|
+
)
|
|
123
|
+
view.updateMarker(data)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@objc(removeMarker:identifier:)
|
|
128
|
+
func removeMarker(_ reactTag: NSNumber, identifier: String) {
|
|
129
|
+
Self.performActionWithView(reactTag: reactTag, bridge: bridge) { view in
|
|
130
|
+
view.removeMarker(identifier: identifier)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|