@nativescript-community/ui-mapbox 6.2.31 → 7.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/common.d.ts +56 -26
  3. package/common.js +44 -28
  4. package/expression/expression-parser.android.d.ts +2 -2
  5. package/expression/expression-parser.android.js +4 -3
  6. package/expression/expression-parser.ios.d.ts +2 -2
  7. package/expression/expression-parser.ios.js +28 -13
  8. package/index.android.d.ts +59 -66
  9. package/index.android.js +1388 -1244
  10. package/index.d.ts +36 -5
  11. package/index.ios.d.ts +72 -243
  12. package/index.ios.js +1161 -1999
  13. package/layers/layer-factory.android.d.ts +7 -5
  14. package/layers/layer-factory.android.js +71 -41
  15. package/layers/layer-factory.d.ts +2 -1
  16. package/layers/layer-factory.ios.d.ts +8 -8
  17. package/layers/layer-factory.ios.js +46 -100
  18. package/layers/parser/property-parser.android.d.ts +3 -1
  19. package/layers/parser/property-parser.android.js +25 -24
  20. package/layers/parser/property-parser.d.ts +1 -1
  21. package/layers/parser/property-parser.ios.d.ts +0 -2
  22. package/layers/parser/property-parser.ios.js +0 -149
  23. package/markers/Marker.android.d.ts +28 -0
  24. package/markers/Marker.android.js +54 -0
  25. package/markers/Marker.common.d.ts +2 -0
  26. package/markers/Marker.common.js +31 -0
  27. package/markers/MarkerManager.android.d.ts +35 -0
  28. package/markers/MarkerManager.android.js +220 -0
  29. package/package.json +7 -6
  30. package/platforms/android/include.gradle +31 -27
  31. package/platforms/android/ui_mapbox.aar +0 -0
  32. package/platforms/ios/Podfile +3 -1
  33. package/platforms/ios/Resources/default_pin.png +0 -0
  34. package/platforms/ios/src/MapboxBridge.swift +1479 -0
  35. package/platforms/ios/src/NativeExpressionParser.swift +33 -0
  36. package/platforms/ios/src/NativeLayerFactory.swift +108 -0
  37. package/tsconfig.tsbuildinfo +1 -0
  38. package/typings/Mapbox.ios.d.ts +2 -3242
  39. package/typings/geojson.android.d.ts +689 -0
  40. package/typings/index.android.d.ts +46 -0
  41. package/typings/mapbox.android.d.ts +39968 -12560
  42. package/typings/mapbox.bridge.ios.d.ts +129 -0
@@ -0,0 +1,33 @@
1
+ import Foundation
2
+ import MapboxMaps
3
+
4
+ @objcMembers
5
+ public class NativeExpressionParser: NSObject {
6
+
7
+ /// Parse a Mapbox-style expression provided as a JSON string into a native Expression instance.
8
+ /// - Parameter jsonString: NSString containing the JSON array for the expression (e.g. '["==", ["get","foo"], "bar"]')
9
+ /// - Returns: an opaque native Expression (as Any) on success, or nil on failure.
10
+ @objc public static func parseJson(_ jsonString: NSString) -> Any? {
11
+ // Convert string -> Data -> JSON object (NSArray expected)
12
+ guard let data = (jsonString as String).data(using: .utf8) else { return nil }
13
+ do {
14
+ return try JSONDecoder().decode(Exp.self, from: data)
15
+ } catch {
16
+ // parsing or Expression init failed
17
+ return nil
18
+ }
19
+ }
20
+
21
+ /// Convert a native Expression (opaque) back into a JSON string.
22
+ /// - Parameter expression: the native Expression (as returned by parseJson) or nil
23
+ /// - Returns: NSString containing the JSON array representation, or nil on failure.
24
+ @objc public static func toJson(_ expression: Any?) -> NSString? {
25
+ guard let expr = expression as? Exp else { return nil }
26
+ do {
27
+ let data = try JSONEncoder().encode(expr)
28
+ return String(data: data, encoding: .utf8) as NSString?
29
+ } catch {
30
+ return nil
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,108 @@
1
+ import Foundation
2
+ import UIKit
3
+ import MapboxMaps
4
+
5
+ @objcMembers
6
+ public class NativeLayerFactory: NSObject {
7
+
8
+ // Create a layer from JSON. Returns true on success.
9
+ @objc public static func createLayer(_ mapboxView: MapView, _ layerId: String, _ jsonString: String, _ belowLayerId: String?) -> Bool {
10
+ guard let mapboxMap = mapboxView.mapboxMap, let data = jsonString.data(using: .utf8) else { return false }
11
+ do {
12
+ // Parse to a JSON dictionary
13
+ guard let jsonObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else {
14
+ throw NSError(domain: "LayerError", code: 0, userInfo: [NSLocalizedDescriptionKey: "Invalid JSON"])
15
+ }
16
+
17
+ guard let typeString = jsonObject["type"] as? String,
18
+ let type = LayerType(rawValue: typeString).layerType else {
19
+ throw TypeConversionError.invalidObject
20
+ }
21
+
22
+ let layer = try type.init(jsonObject: jsonObject)
23
+ if (belowLayerId != nil) {
24
+ try mapboxMap.addLayer(layer, layerPosition: .below(belowLayerId!))
25
+ } else {
26
+ try mapboxMap.addLayer(layer)
27
+ }
28
+ return true
29
+ } catch {
30
+ return false
31
+ }
32
+ }
33
+
34
+ /// Apply a set of properties to an existing layer by calling setLayerProperty for each key.
35
+ /// This avoids removing/adding the layer and uses the style API to set properties in-place.
36
+ @objc public static func applyLayerProperties(_ mapboxView: MapView, _ layerId: String, _ properties: NSDictionary) -> Bool {
37
+ guard mapboxView.mapboxMap != nil else { return false }
38
+ // Iterate keys and call style.setLayerProperty(for:property:value:)
39
+ var succeeded = true
40
+ for (k, v) in properties {
41
+ guard let key = k as? String else { continue }
42
+ let ok = setLayerProperty(mapboxView, layerId, key, v as Any)
43
+ if !ok { succeeded = false }
44
+ }
45
+ return succeeded
46
+ }
47
+
48
+ /// Set a single layer property in-place using the style API.
49
+ /// Example property paths: "paint.fill-color", "layout.visibility", etc.
50
+ @objc public static func setLayerProperty(_ mapboxView: MapView, _ layerId: String, _ name: String, _ value: Any) -> Bool {
51
+ guard let mapboxMap = mapboxView.mapboxMap else { return false }
52
+ do {
53
+ // MapboxMaps (11.x) exposes setLayerProperty(for:property:value:)
54
+ // Use the API directly and propagate errors.
55
+ try mapboxMap.setLayerProperty(for: layerId, property: name, value: value)
56
+ return true
57
+ } catch {
58
+ // Some SDK variants may expect different types (e.g., NSNumber vs String). Try best-effort conversions for common types.
59
+ // If value is NSString representing a color (e.g. "#ff0000"), it's usually accepted by the SDK.
60
+ return false
61
+ }
62
+ }
63
+
64
+ // Set layer visibility
65
+ @objc public static func setLayerVisibility(_ mapboxView: MapView, _ layerId: String, _ visible: Bool) -> Bool {
66
+ return setLayerProperty(mapboxView, layerId, "layout.visibility", visible ? "visible" : "none")
67
+ }
68
+ // Set layer visibility
69
+ @objc public static func getLayerProperty(_ mapboxView: MapView, _ layerId: String, _ name: String) -> Any? {
70
+ guard let mapboxMap = mapboxView.mapboxMap else { return nil }
71
+ return mapboxMap.layerProperty(for: layerId, property: name)
72
+ }
73
+ // -------------------------------
74
+ // Native getters for layer ids/info
75
+ // -------------------------------
76
+
77
+ /// Return the layer id if the layer exists, otherwise nil.
78
+ /// JS can call this to validate layer presence.
79
+ @objc public static func getLayer(_ mapboxView: MapView, _ layerId: String) -> NSString? {
80
+ guard let mapboxMap = mapboxView.mapboxMap else { return nil }
81
+ do {
82
+ // Try to fetch the layer; if it exists return the id string (opaque success marker)
83
+ _ = try mapboxMap.layer(withId: layerId)
84
+ return layerId as NSString
85
+ } catch {
86
+ return nil
87
+ }
88
+ }
89
+
90
+ /// Return an array (JSON string) of layer ids in the current style.
91
+ @objc public static func getLayers(_ mapboxView: MapView) -> NSString? {
92
+ guard let mapboxMap = mapboxView.mapboxMap else { return nil }
93
+ var ids: [String] = []
94
+ for info in mapboxMap.allLayerIdentifiers {
95
+ ids.append(info.id)
96
+ }
97
+ if let data = try? JSONSerialization.data(withJSONObject: ids, options: []),
98
+ let s = String(data: data, encoding: .utf8) {
99
+ return s as NSString
100
+ }
101
+ return nil
102
+ }
103
+
104
+ /// Return the layer 'type' string for the given layer id (e.g. "fill", "line", "symbol"), or nil.
105
+ @objc public static func getLayerType(_ mapboxView: MapView, _ layerId: String) -> NSString? {
106
+ return getLayerProperty(mapboxView, layerId, "type") as? NSString
107
+ }
108
+ }
@@ -0,0 +1 @@
1
+ {"root":["../../src/ui-mapbox/common.ts","../../src/ui-mapbox/geo.utils.ts","../../src/ui-mapbox/index.android.ts","../../src/ui-mapbox/index.d.ts","../../src/ui-mapbox/index.ios.ts","../../src/ui-mapbox/references.d.ts","../../src/ui-mapbox/expression/expression-parser.android.ts","../../src/ui-mapbox/expression/expression-parser.d.ts","../../src/ui-mapbox/expression/expression-parser.ios.ts","../../src/ui-mapbox/layers/layer-factory.android.ts","../../src/ui-mapbox/layers/layer-factory.d.ts","../../src/ui-mapbox/layers/layer-factory.ios.ts","../../src/ui-mapbox/layers/parser/property-parser.android.ts","../../src/ui-mapbox/layers/parser/property-parser.d.ts","../../src/ui-mapbox/layers/parser/property-parser.ios.ts","../../src/ui-mapbox/markers/marker.android.ts","../../src/ui-mapbox/markers/marker.common.ts","../../src/ui-mapbox/markers/markermanager.android.ts","../../src/ui-mapbox/typings/mapbox.ios.d.ts","../../src/ui-mapbox/typings/geojson.android.d.ts","../../src/ui-mapbox/typings/index.android.d.ts","../../src/ui-mapbox/typings/mapbox.android.d.ts","../../src/ui-mapbox/typings/mapbox.bridge.ios.d.ts","../../references.d.ts","../../tools/references.d.ts"],"version":"5.8.3"}