@maplibre/maplibre-react-native 10.0.0-beta.3 → 10.0.0-beta.7

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 (92) hide show
  1. package/android/build.gradle +98 -51
  2. package/android/gradle.properties +7 -0
  3. package/android/src/main/AndroidManifest.xml +4 -2
  4. package/android/src/main/AndroidManifestNew.xml +5 -0
  5. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java +0 -5
  6. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java +0 -66
  7. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java +0 -28
  8. package/ios/MLRN/MLRNBackgroundLayer.h +0 -1
  9. package/ios/MLRN/MLRNFillExtrusionLayer.h +0 -1
  10. package/ios/MLRN/MLRNFillLayer.h +0 -1
  11. package/ios/MLRN/MLRNFillLayer.m +1 -0
  12. package/ios/MLRN/MLRNLineLayer.h +0 -1
  13. package/ios/MLRN/MLRNRasterLayer.h +0 -1
  14. package/ios/MLRN/MLRNShapeSource.h +0 -11
  15. package/ios/MLRN/MLRNShapeSource.m +0 -38
  16. package/ios/MLRN/MLRNShapeSourceManager.m +0 -68
  17. package/ios/MLRN/MLRNSymbolLayer.h +1 -7
  18. package/ios/MLRN/MLRNSymbolLayer.m +1 -89
  19. package/ios/MLRN/MLRNSymbolLayerManager.m +0 -1
  20. package/lib/commonjs/MapLibreRN.js +1 -13
  21. package/lib/commonjs/MapLibreRN.js.map +1 -1
  22. package/lib/commonjs/components/Images.js +1 -5
  23. package/lib/commonjs/components/Images.js.map +1 -1
  24. package/lib/commonjs/components/MapView.js +0 -7
  25. package/lib/commonjs/components/MapView.js.map +1 -1
  26. package/lib/commonjs/components/ShapeSource.js +6 -38
  27. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  28. package/lib/commonjs/components/SymbolLayer.js +2 -17
  29. package/lib/commonjs/components/SymbolLayer.js.map +1 -1
  30. package/lib/commonjs/components/VectorSource.js +1 -11
  31. package/lib/commonjs/components/VectorSource.js.map +1 -1
  32. package/lib/module/MapLibreRN.js +0 -4
  33. package/lib/module/MapLibreRN.js.map +1 -1
  34. package/lib/module/components/Images.js +1 -5
  35. package/lib/module/components/Images.js.map +1 -1
  36. package/lib/module/components/MapView.js +0 -7
  37. package/lib/module/components/MapView.js.map +1 -1
  38. package/lib/module/components/ShapeSource.js +5 -37
  39. package/lib/module/components/ShapeSource.js.map +1 -1
  40. package/lib/module/components/SymbolLayer.js +3 -18
  41. package/lib/module/components/SymbolLayer.js.map +1 -1
  42. package/lib/module/components/VectorSource.js +1 -11
  43. package/lib/module/components/VectorSource.js.map +1 -1
  44. package/lib/typescript/commonjs/src/MapLibreRN.d.ts +0 -4
  45. package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/components/Camera.d.ts +1 -1
  47. package/lib/typescript/commonjs/src/components/Images.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/components/MapView.d.ts +0 -1
  49. package/lib/typescript/commonjs/src/components/MapView.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +0 -1
  51. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts +0 -6
  53. package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/src/components/VectorSource.d.ts.map +1 -1
  55. package/lib/typescript/module/src/MapLibreRN.d.ts +0 -4
  56. package/lib/typescript/module/src/MapLibreRN.d.ts.map +1 -1
  57. package/lib/typescript/module/src/components/Camera.d.ts +1 -1
  58. package/lib/typescript/module/src/components/Images.d.ts.map +1 -1
  59. package/lib/typescript/module/src/components/MapView.d.ts +0 -1
  60. package/lib/typescript/module/src/components/MapView.d.ts.map +1 -1
  61. package/lib/typescript/module/src/components/ShapeSource.d.ts +0 -1
  62. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  63. package/lib/typescript/module/src/components/SymbolLayer.d.ts +0 -6
  64. package/lib/typescript/module/src/components/SymbolLayer.d.ts.map +1 -1
  65. package/lib/typescript/module/src/components/VectorSource.d.ts.map +1 -1
  66. package/package.json +1 -1
  67. package/src/MapLibreRN.ts +0 -6
  68. package/src/components/Camera.tsx +1 -1
  69. package/src/components/Images.tsx +1 -10
  70. package/src/components/MapView.tsx +0 -11
  71. package/src/components/ShapeSource.tsx +5 -73
  72. package/src/components/SymbolLayer.tsx +5 -33
  73. package/src/components/VectorSource.tsx +4 -20
  74. package/android/src/main/res/values/strings.xml +0 -3
  75. package/lib/commonjs/components/Style.js +0 -266
  76. package/lib/commonjs/components/Style.js.map +0 -1
  77. package/lib/commonjs/utils/deprecation.js +0 -31
  78. package/lib/commonjs/utils/deprecation.js.map +0 -1
  79. package/lib/module/components/Style.js +0 -261
  80. package/lib/module/components/Style.js.map +0 -1
  81. package/lib/module/utils/deprecation.js +0 -27
  82. package/lib/module/utils/deprecation.js.map +0 -1
  83. package/lib/typescript/commonjs/src/components/Style.d.ts +0 -81
  84. package/lib/typescript/commonjs/src/components/Style.d.ts.map +0 -1
  85. package/lib/typescript/commonjs/src/utils/deprecation.d.ts +0 -6
  86. package/lib/typescript/commonjs/src/utils/deprecation.d.ts.map +0 -1
  87. package/lib/typescript/module/src/components/Style.d.ts +0 -81
  88. package/lib/typescript/module/src/components/Style.d.ts.map +0 -1
  89. package/lib/typescript/module/src/utils/deprecation.d.ts +0 -6
  90. package/lib/typescript/module/src/utils/deprecation.d.ts.map +0 -1
  91. package/src/components/Style.tsx +0 -371
  92. package/src/utils/deprecation.ts +0 -31
@@ -1,69 +1,116 @@
1
- apply plugin: 'com.android.library'
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["MapLibreReactNative_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
2
16
 
3
- def safeExtGet(prop, fallback) {
4
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
17
+ def reactNativeArchitectures() {
18
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
19
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
5
20
  }
6
21
 
7
22
  def isNewArchitectureEnabled() {
8
- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
23
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
9
24
  }
10
25
 
11
- buildscript {
12
- ext {
13
- buildToolsVersion = "33.0.0"
14
- minSdkVersion = 16
15
- compileSdkVersion = 34
16
- targetSdkVersion = 33
17
- supportLibVersion = "28.0.0"
18
- }
26
+ apply plugin: "com.android.library"
27
+ apply plugin: "kotlin-android"
19
28
 
20
- repositories {
21
- google()
22
- mavenCentral()
23
- }
29
+ // TODO: Currently breaks new arch support, but works without
30
+ // if (isNewArchitectureEnabled()) {
31
+ // apply plugin: "com.facebook.react"
32
+ // }
33
+
34
+ def getExtOrDefault(name) {
35
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["MapLibreReactNative_" + name]
36
+ }
37
+
38
+ def getExtOrIntegerDefault(name) {
39
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["MapLibreReactNative_" + name]).toInteger()
40
+ }
41
+
42
+ def supportsNamespace() {
43
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
44
+ def major = parsed[0].toInteger()
45
+ def minor = parsed[1].toInteger()
46
+
47
+ // Namespace support was added in 7.3.0
48
+ return (major == 7 && minor >= 3) || major >= 8
24
49
  }
25
50
 
26
51
  android {
27
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
28
- buildToolsVersion safeExtGet("buildToolsVersion", '33.0.1')
29
-
30
- defaultConfig {
31
- minSdkVersion safeExtGet('minSdkVersion', 16)
32
- targetSdkVersion safeExtGet('targetSdkVersion', 26)
33
- versionCode 1
34
- versionName "1.0"
35
- buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
36
- }
52
+ if (supportsNamespace()) {
53
+ namespace "org.maplibre.reactnative"
37
54
 
38
- compileOptions {
39
- sourceCompatibility JavaVersion.VERSION_1_8
40
- targetCompatibility JavaVersion.VERSION_1_8
55
+ sourceSets {
56
+ main {
57
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
58
+ }
41
59
  }
60
+ }
61
+
62
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
63
+
64
+ defaultConfig {
65
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
66
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
42
67
 
43
- buildTypes {
44
- release {
45
- minifyEnabled false
46
- }
68
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
69
+ }
70
+
71
+ buildTypes {
72
+ release {
73
+ minifyEnabled false
47
74
  }
75
+ }
76
+
77
+ lintOptions {
78
+ disable "GradleCompatible"
79
+ }
80
+
81
+ compileOptions {
82
+ sourceCompatibility JavaVersion.VERSION_1_8
83
+ targetCompatibility JavaVersion.VERSION_1_8
84
+ }
48
85
  }
49
86
 
87
+ repositories {
88
+ mavenCentral()
89
+ google()
90
+ }
91
+
92
+ def kotlin_version = getExtOrDefault("kotlinVersion")
93
+
50
94
  dependencies {
51
- // The version of react-native is set by the React Native Gradle Plugin
52
- implementation("com.facebook.react:react-android")
53
-
54
- // MapLibre SDK
55
- implementation "org.maplibre.gl:android-sdk:11.5.0"
56
- implementation "org.maplibre.gl:android-sdk-turf:6.0.1"
57
-
58
- // Dependencies
59
- implementation "androidx.vectordrawable:vectordrawable:1.1.0"
60
- implementation "androidx.annotation:annotation:1.7.0"
61
- implementation "androidx.appcompat:appcompat:1.6.1"
62
- implementation "com.squareup.okhttp3:okhttp:${safeExtGet('okhttpVersion', '4.9.0')}"
63
- implementation "com.squareup.okhttp3:okhttp-urlconnection:${safeExtGet('okhttpVersion', '4.9.0')}"
64
-
65
- // MapLibre plugins
66
- implementation ("org.maplibre.gl:android-plugin-localization-v9:3.0.1")
67
- implementation ("org.maplibre.gl:android-plugin-annotation-v9:3.0.1")
68
- implementation ("org.maplibre.gl:android-plugin-markerview-v9:3.0.1")
95
+ // For < 0.71, this will be from the local maven repo
96
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
97
+ //noinspection GradleDynamicVersion
98
+ implementation "com.facebook.react:react-native:+"
99
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
100
+
101
+ // MapLibre SDK
102
+ implementation "org.maplibre.gl:android-sdk:11.5.0"
103
+ implementation "org.maplibre.gl:android-sdk-turf:6.0.1"
104
+
105
+ // Dependencies
106
+ implementation "androidx.vectordrawable:vectordrawable:1.1.0"
107
+ implementation "androidx.annotation:annotation:1.7.0"
108
+ implementation "androidx.appcompat:appcompat:1.6.1"
109
+ implementation "com.squareup.okhttp3:okhttp:${getExtOrDefault('okhttpVersion')}"
110
+ implementation "com.squareup.okhttp3:okhttp-urlconnection:${getExtOrDefault('okhttpVersion')}"
111
+
112
+ // MapLibre plugins
113
+ implementation ("org.maplibre.gl:android-plugin-localization-v9:3.0.1")
114
+ implementation ("org.maplibre.gl:android-plugin-annotation-v9:3.0.1")
115
+ implementation ("org.maplibre.gl:android-plugin-markerview-v9:3.0.1")
69
116
  }
@@ -0,0 +1,7 @@
1
+ MapLibreReactNative_kotlinVersion=1.7.0
2
+ MapLibreReactNative_minSdkVersion=21
3
+ MapLibreReactNative_targetSdkVersion=31
4
+ MapLibreReactNative_compileSdkVersion=31
5
+ MapLibreReactNative_ndkversion=21.4.7075529
6
+
7
+ MapLibreReactNative_okhttpVersion=4.9.0
@@ -1,4 +1,6 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.maplibre.reactnative">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="org.maplibre.reactnative">
3
+
2
4
  <uses-permission android:name="android.permission.INTERNET" />
3
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
5
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
4
6
  </manifest>
@@ -0,0 +1,5 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+
3
+ <uses-permission android:name="android.permission.INTERNET" />
4
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
5
+ </manifest>
@@ -52,11 +52,6 @@ public class MLRNPackage implements ReactPackage {
52
52
  return modules;
53
53
  }
54
54
 
55
- @Deprecated
56
- public List<Class<? extends JavaScriptModule>> createJSModules() {
57
- return Collections.emptyList();
58
- }
59
-
60
55
  @Override
61
56
  public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
62
57
  List<ViewManager> managers = new ArrayList<>();
@@ -243,70 +243,4 @@ public class MLRNShapeSource extends MLRNSource<GeoJsonSource> {
243
243
  AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
244
244
  mManager.handleEvent(event);
245
245
  }
246
-
247
- // Deprecated. Will be removed in 9+ ver.
248
- public void getClusterExpansionZoomById(String callbackID, int clusterId) {
249
- if (mSource == null) {
250
- WritableMap payload = new WritableNativeMap();
251
- payload.putString("error", "source is not yet loaded");
252
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
253
- mManager.handleEvent(event);
254
- return;
255
- }
256
- List<Feature> features = mSource.querySourceFeatures(Expression.eq(Expression.id(), clusterId));
257
- int zoom = -1;
258
- if (features.size() > 0) {
259
- zoom = mSource.getClusterExpansionZoom(features.get(0));
260
- }
261
-
262
- if (zoom == -1) {
263
- WritableMap payload = new WritableNativeMap();
264
- payload.putString("error", "Could not get zoom for cluster id " + clusterId);
265
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
266
- mManager.handleEvent(event);
267
- return;
268
- }
269
-
270
- WritableMap payload = new WritableNativeMap();
271
- payload.putInt("data", zoom);
272
-
273
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
274
- mManager.handleEvent(event);
275
- }
276
-
277
- // Deprecated. Will be removed in 9+ ver.
278
- public void getClusterLeavesById(String callbackID, int clusterId, int number, int offset) {
279
- if (mSource == null) {
280
- WritableMap payload = new WritableNativeMap();
281
- payload.putString("error", "source is not yet loaded");
282
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
283
- mManager.handleEvent(event);
284
- return;
285
- }
286
- Feature clusterFeature = mSource.querySourceFeatures(Expression.eq(Expression.get("cluster_id"), clusterId)).get(0);
287
- FeatureCollection leaves = mSource.getClusterLeaves(clusterFeature, number, offset);
288
- WritableMap payload = new WritableNativeMap();
289
- payload.putString("data", leaves.toJson());
290
-
291
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
292
- mManager.handleEvent(event);
293
- }
294
-
295
- // Deprecated. Will be removed in 9+ ver.
296
- public void getClusterChildrenById(String callbackID, int clusterId) {
297
- if (mSource == null) {
298
- WritableMap payload = new WritableNativeMap();
299
- payload.putString("error", "source is not yet loaded");
300
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
301
- mManager.handleEvent(event);
302
- return;
303
- }
304
- Feature clusterFeature = mSource.querySourceFeatures(Expression.eq(Expression.get("cluster_id"), clusterId)).get(0);
305
- FeatureCollection leaves = mSource.getClusterChildren(clusterFeature);
306
- WritableMap payload = new WritableNativeMap();
307
- payload.putString("data", leaves.toJson());
308
-
309
- AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
310
- mManager.handleEvent(event);
311
- }
312
246
  }
@@ -179,11 +179,6 @@ public class MLRNShapeSourceManager extends AbstractEventEmitter<MLRNShapeSource
179
179
  public static final int METHOD_GET_CLUSTER_LEAVES = 105;
180
180
  public static final int METHOD_GET_CLUSTER_CHILDREN = 106;
181
181
 
182
- // Deprecated. Will be removed in 9+ ver.
183
- public static final int METHOD_GET_CLUSTER_EXPANSION_ZOOM_BY_ID = 107;
184
- public static final int METHOD_GET_CLUSTER_LEAVES_BY_ID = 108;
185
- public static final int METHOD_GET_CLUSTER_CHILDREN_BY_ID = 109;
186
-
187
182
  @Nullable
188
183
  @Override
189
184
  public Map<String, Integer> getCommandsMap() {
@@ -192,12 +187,6 @@ public class MLRNShapeSourceManager extends AbstractEventEmitter<MLRNShapeSource
192
187
  .put("getClusterExpansionZoom", METHOD_GET_CLUSTER_EXPANSION_ZOOM)
193
188
  .put("getClusterLeaves", METHOD_GET_CLUSTER_LEAVES)
194
189
  .put("getClusterChildren", METHOD_GET_CLUSTER_CHILDREN)
195
-
196
- // Deprecated. Will be removed in 9+ ver.
197
- .put("getClusterExpansionZoomById", METHOD_GET_CLUSTER_EXPANSION_ZOOM_BY_ID)
198
- .put("getClusterLeavesById", METHOD_GET_CLUSTER_LEAVES_BY_ID)
199
- .put("getClusterChildrenById", METHOD_GET_CLUSTER_CHILDREN_BY_ID)
200
-
201
190
  .build();
202
191
  }
203
192
 
@@ -227,23 +216,6 @@ public class MLRNShapeSourceManager extends AbstractEventEmitter<MLRNShapeSource
227
216
  args.getString(1)
228
217
  );
229
218
  break;
230
- case METHOD_GET_CLUSTER_EXPANSION_ZOOM_BY_ID:
231
- source.getClusterExpansionZoomById(args.getString(0), args.getInt(1));
232
- break;
233
- case METHOD_GET_CLUSTER_LEAVES_BY_ID:
234
- source.getClusterLeavesById(
235
- args.getString(0),
236
- args.getInt(1),
237
- args.getInt(2),
238
- args.getInt((3))
239
- );
240
- break;
241
- case METHOD_GET_CLUSTER_CHILDREN_BY_ID:
242
- source.getClusterChildrenById(
243
- args.getString(0),
244
- args.getInt(1)
245
- );
246
- break;
247
219
  }
248
220
  }
249
221
  }
@@ -1,5 +1,4 @@
1
1
  #import "MLRNLayer.h"
2
- @import MapLibre;
3
2
 
4
3
  @interface MLRNBackgroundLayer : MLRNLayer
5
4
 
@@ -1,5 +1,4 @@
1
1
  #import "MLRNVectorLayer.h"
2
- @import MapLibre;
3
2
 
4
3
  @interface MLRNFillExtrusionLayer : MLRNVectorLayer
5
4
 
@@ -1,5 +1,4 @@
1
1
  #import "MLRNVectorLayer.h"
2
- @import MapLibre;
3
2
 
4
3
  @interface MLRNFillLayer : MLRNVectorLayer
5
4
 
@@ -1,5 +1,6 @@
1
1
  #import "MLRNFillLayer.h"
2
2
  #import "MLRNStyle.h"
3
+
3
4
  #import <React/RCTLog.h>
4
5
 
5
6
  @implementation MLRNFillLayer
@@ -1,5 +1,4 @@
1
1
  #import "MLRNVectorLayer.h"
2
- @import MapLibre;
3
2
 
4
3
  @interface MLRNLineLayer : MLRNVectorLayer
5
4
 
@@ -1,5 +1,4 @@
1
1
  #import "MLRNLayer.h"
2
- @import MapLibre;
3
2
 
4
3
  @interface MLRNRasterLayer : MLRNLayer
5
4
 
@@ -31,15 +31,4 @@
31
31
 
32
32
  - (double)getClusterExpansionZoom:(nonnull NSString *)featureJSON;
33
33
 
34
- // Deprecated. Will be removed in 9+ ver.
35
- - (nonnull NSArray<id <MLNFeature>> *)getClusterLeavesById:(nonnull NSNumber *)clusterId
36
- number:(NSUInteger)number
37
- offset:(NSUInteger)offset;
38
-
39
- // Deprecated. Will be removed in 9+ ver.
40
- - (nonnull NSArray<id <MLNFeature>> *)getClusterChildrenById:(nonnull NSNumber *)clusterId;
41
-
42
- // Deprecated. Will be removed in 9+ ver.
43
- - (double)getClusterExpansionZoomById:(nonnull NSNumber *)clusterId;
44
-
45
34
  @end
@@ -145,42 +145,4 @@ static UIImage * _placeHolderImage;
145
145
  return [shapeSource childrenOfCluster:cluster];
146
146
  }
147
147
 
148
-
149
- // Deprecated. Will be removed in 9+ ver.
150
- - (double)getClusterExpansionZoomById:(nonnull NSNumber *)clusterId
151
- {
152
- MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
153
- NSArray<id<MLNFeature>> *features = [shapeSource featuresMatchingPredicate: [NSPredicate predicateWithFormat:@"%K = %i", @"cluster_id", clusterId.intValue]];
154
- if (features.count == 0) {
155
- return -1;
156
- }
157
- return [shapeSource zoomLevelForExpandingCluster:(MLNPointFeatureCluster *)features[0]];
158
- }
159
-
160
- // Deprecated. Will be removed in 9+ ver.
161
- - (nonnull NSArray<id <MLNFeature>> *)getClusterLeavesById:(nonnull NSNumber *)clusterId
162
- number:(NSUInteger)number
163
- offset:(NSUInteger)offset
164
- {
165
- MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
166
-
167
- NSPredicate* predicate = [NSPredicate predicateWithFormat:@"cluster_id == %@", clusterId];
168
- NSArray<id<MLNFeature>> *features = [shapeSource featuresMatchingPredicate:predicate];
169
-
170
- MLNPointFeatureCluster * cluster = (MLNPointFeatureCluster *)features[0];
171
- return [shapeSource leavesOfCluster:cluster offset:offset limit:number];
172
- }
173
-
174
- // Deprecated. Will be removed in 9+ ver.
175
- - (nonnull NSArray<id <MLNFeature>> *)getClusterChildrenById:(nonnull NSNumber *)clusterId
176
- {
177
- MLNShapeSource *shapeSource = (MLNShapeSource *)self.source;
178
-
179
- NSPredicate* predicate = [NSPredicate predicateWithFormat:@"cluster_id == %@", clusterId];
180
- NSArray<id<MLNFeature>> *features = [shapeSource featuresMatchingPredicate:predicate];
181
-
182
- MLNPointFeatureCluster * cluster = (MLNPointFeatureCluster *)features[0];
183
- return [shapeSource childrenOfCluster:cluster];
184
- }
185
-
186
148
  @end
@@ -128,72 +128,4 @@ RCT_EXPORT_METHOD(getClusterChildren:(nonnull NSNumber*)reactTag
128
128
  }];
129
129
  }
130
130
 
131
- // Deprecated. Will be removed in 9+ ver.
132
- RCT_EXPORT_METHOD(getClusterExpansionZoomById:(nonnull NSNumber*)reactTag
133
- clusterId:(nonnull NSNumber*)clusterId
134
- resolver:(RCTPromiseResolveBlock)resolve
135
- rejecter:(RCTPromiseRejectBlock)reject)
136
- {
137
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary<NSNumber*, UIView*> *viewRegistry) {
138
- MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
139
-
140
- if (![shapeSource isKindOfClass:[MLRNShapeSource class]]) {
141
- RCTLogError(@"Invalid react tag, could not find MLRNMapView");
142
- return;
143
- }
144
-
145
- double zoom = [shapeSource getClusterExpansionZoomById:clusterId];
146
- if (zoom == -1) {
147
- reject(@"zoom_error", [NSString stringWithFormat:@"Could not get zoom for cluster id %@", clusterId], nil);
148
- return;
149
- }
150
- resolve(@{@"data":@(zoom)});
151
- }];
152
- }
153
-
154
- // Deprecated. Will be removed in 9+ ver.
155
- RCT_EXPORT_METHOD(getClusterLeavesById:(nonnull NSNumber*)reactTag
156
- clusterId:(nonnull NSNumber *)clusterId
157
- number:(NSUInteger) number
158
- offset:(NSUInteger) offset
159
- resolver:(RCTPromiseResolveBlock)resolve
160
- rejecter:(RCTPromiseRejectBlock)reject)
161
- {
162
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary<NSNumber*, UIView*> *viewRegistry) {
163
- MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
164
-
165
- NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterLeavesById:clusterId number:number offset:offset];
166
-
167
- NSMutableArray<NSDictionary*> *features = [[NSMutableArray alloc] initWithCapacity:shapes.count];
168
- for (int i = 0; i < shapes.count; i++) {
169
- [features addObject:shapes[i].geoJSONDictionary];
170
- }
171
-
172
- resolve(@{
173
- @"data": @{ @"type": @"FeatureCollection", @"features": features }
174
- });
175
- }];
176
- }
177
- // Deprecated. Will be removed in 9+ ver.
178
- RCT_EXPORT_METHOD(getClusterChildrenById:(nonnull NSNumber*)reactTag
179
- clusterId:(nonnull NSNumber *)clusterId
180
- resolver:(RCTPromiseResolveBlock)resolve
181
- rejecter:(RCTPromiseRejectBlock)reject)
182
- {
183
- [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, NSDictionary<NSNumber*, UIView*> *viewRegistry) {
184
- MLRNShapeSource* shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
185
-
186
- NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterChildrenById: clusterId];
187
-
188
- NSMutableArray<NSDictionary*> *features = [[NSMutableArray alloc] initWithCapacity:shapes.count];
189
- for (int i = 0; i < shapes.count; i++) {
190
- [features addObject:shapes[i].geoJSONDictionary];
191
- }
192
-
193
- resolve(@{
194
- @"data": @{ @"type": @"FeatureCollection", @"features": features }
195
- });
196
- }];
197
- }
198
-
199
131
  @end
@@ -1,11 +1,5 @@
1
- #import <React/RCTComponent.h>
2
1
  #import "MLRNVectorLayer.h"
3
2
 
4
- @interface MLRNSymbolLayer : MLRNVectorLayer<RCTInvalidating>
5
-
6
- @property (nonatomic, strong) NSMutableArray<id<RCTComponent>> *reactSubviews;
7
-
8
- @property (nonatomic, assign) BOOL snapshot;
9
- @property (nonatomic, copy) NSString *sourceLayerID;
3
+ @interface MLRNSymbolLayer : MLRNVectorLayer
10
4
 
11
5
  @end
@@ -1,85 +1,10 @@
1
1
  #import "MLRNSymbolLayer.h"
2
2
  #import "MLRNStyle.h"
3
- #import <React/UIView+React.h>
3
+
4
4
  #import <React/RCTLog.h>
5
5
 
6
6
  @implementation MLRNSymbolLayer
7
7
 
8
- - (instancetype)initWithFrame:(CGRect)frame
9
- {
10
- if (self = [super initWithFrame:frame]) {
11
- _reactSubviews = [[NSMutableArray alloc] init];
12
- }
13
- return self;
14
- }
15
-
16
- - (void)invalidate
17
- {
18
- if (_snapshot == YES && self.style != nil) {
19
- [self.style removeImageForName:self.id];
20
- }
21
- }
22
-
23
- #pragma clang diagnostic push
24
- #pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
25
- - (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
26
- [_reactSubviews insertObject:(UIView *)subview atIndex:(NSUInteger) atIndex];
27
- }
28
- #pragma clang diagnostic pop
29
-
30
- #pragma clang diagnostic push
31
- #pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
32
- - (void)removeReactSubview:(id<RCTComponent>)subview {
33
- [_reactSubviews removeObject:(UIView *)subview];
34
- }
35
- #pragma clang diagnostic pop
36
-
37
- #pragma clang diagnostic push
38
- #pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
39
- - (NSArray<id<RCTComponent>> *)reactSubviews {
40
- return nil;
41
- }
42
- #pragma clang diagnostic pop
43
-
44
- - (void)setSnapshot:(BOOL)snapshot
45
- {
46
- _snapshot = snapshot;
47
-
48
- if (self.style != nil) {
49
- UIImage *image;
50
- MLNSymbolStyleLayer *layer = (MLNSymbolStyleLayer *) self.styleLayer;
51
-
52
- if (_snapshot == YES) {
53
- image = [self _createViewSnapshot];
54
- [self.style setImage:image forName:self.id];
55
- layer.iconImageName = [NSExpression expressionWithFormat:self.id];
56
- } else {
57
- image = [self.style imageForName:self.id];
58
-
59
- if (image != nil) {
60
- [self.style removeImageForName:self.id];
61
- layer.iconImageName = nil;
62
- }
63
- }
64
- }
65
- }
66
-
67
- - (void)addedToMap
68
- {
69
- [super addedToMap];
70
-
71
- if (_snapshot == YES) {
72
- UIImage *image = [self _createViewSnapshot];
73
-
74
- if (image != nil) {
75
- [self.style setImage:image forName:self.id];
76
-
77
- MLNSymbolStyleLayer *layer = (MLNSymbolStyleLayer *)self.styleLayer;
78
- layer.iconImageName = [NSExpression expressionForConstantValue:self.id];
79
- }
80
- }
81
- }
82
-
83
8
  - (MLNSymbolStyleLayer*)makeLayer:(MLNStyle*)style
84
9
  {
85
10
  MLNSource *source = [self layerWithSourceIDInStyle: style];
@@ -97,17 +22,4 @@
97
22
  }];
98
23
  }
99
24
 
100
- - (UIImage *)_createViewSnapshot
101
- {
102
- if (_reactSubviews.count == 0) {
103
- return nil;
104
- }
105
- UIView *view = (UIView *)_reactSubviews[0];
106
- UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.f);
107
- [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
108
- UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
109
- UIGraphicsEndImageContext();
110
- return snapshot;
111
- }
112
-
113
25
  @end
@@ -12,7 +12,6 @@ RCT_EXPORT_VIEW_PROPERTY(sourceLayerID, NSString);
12
12
  RCT_EXPORT_VIEW_PROPERTY(id, NSString);
13
13
  RCT_EXPORT_VIEW_PROPERTY(sourceID, NSString);
14
14
  RCT_EXPORT_VIEW_PROPERTY(filter, NSArray);
15
- RCT_EXPORT_VIEW_PROPERTY(snapshot, BOOL);
16
15
 
17
16
  RCT_EXPORT_VIEW_PROPERTY(aboveLayerID, NSString);
18
17
  RCT_EXPORT_VIEW_PROPERTY(belowLayerID, NSString);