@maplibre/maplibre-react-native 11.0.0-alpha.4 → 11.0.0-alpha.6

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 (82) hide show
  1. package/MapLibreReactNative.podspec +1 -1
  2. package/README.md +9 -1
  3. package/android/gradle.properties +1 -1
  4. package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +20 -24
  5. package/android/src/main/java/org/maplibre/reactnative/components/images/MLRNImagesManager.java +3 -0
  6. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java +9 -0
  7. package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java +5 -0
  8. package/android/src/main/java/org/maplibre/reactnative/modules/MLRNSnapshotModule.kt +2 -16
  9. package/android/src/main/java/org/maplibre/reactnative/utils/DownloadMapImageTask.java +8 -10
  10. package/android/src/main/java/org/maplibre/reactnative/utils/DownloadedImage.java +6 -0
  11. package/android/src/main/java/org/maplibre/reactnative/utils/ImageEntry.java +1 -0
  12. package/ios/MLRNImageQueue.h +1 -0
  13. package/ios/MLRNImageQueue.m +2 -0
  14. package/ios/MLRNImageQueueOperation.h +1 -0
  15. package/ios/MLRNImageQueueOperation.m +17 -15
  16. package/ios/MLRNMapViewManager.m +4 -4
  17. package/ios/MLRNShapeSource.h +1 -0
  18. package/ios/MLRNShapeSource.m +4 -0
  19. package/ios/MLRNShapeSourceManager.m +1 -0
  20. package/ios/MLRNStyle.m +5 -5
  21. package/ios/MLRNStyleValue.h +1 -0
  22. package/ios/MLRNStyleValue.m +13 -0
  23. package/ios/MLRNUtils.h +1 -0
  24. package/ios/MLRNUtils.m +10 -1
  25. package/lib/commonjs/MapLibreRN.js.map +1 -1
  26. package/lib/commonjs/components/Images.js +32 -46
  27. package/lib/commonjs/components/Images.js.map +1 -1
  28. package/lib/commonjs/components/ShapeSource.js +1 -0
  29. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  30. package/lib/module/MapLibreRN.js.map +1 -1
  31. package/lib/module/components/Images.js +32 -46
  32. package/lib/module/components/Images.js.map +1 -1
  33. package/lib/module/components/ShapeSource.js +1 -0
  34. package/lib/module/components/ShapeSource.js.map +1 -1
  35. package/lib/typescript/commonjs/src/MapLibreRN.d.ts +1 -1
  36. package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/src/components/BackgroundLayer.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/src/components/Callout.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/src/components/CircleLayer.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/src/components/FillExtrusionLayer.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/src/components/FillLayer.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/components/HeatmapLayer.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/src/components/ImageSource.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/components/Images.d.ts +11 -2
  45. package/lib/typescript/commonjs/src/components/Images.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/components/Light.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/src/components/LineLayer.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/components/MarkerView.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/src/components/NativeUserLocation.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/src/components/RasterLayer.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/src/components/RasterSource.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +5 -0
  53. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts.map +1 -1
  55. package/lib/typescript/commonjs/src/plugin/android.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/src/plugin/ios.d.ts.map +1 -1
  57. package/lib/typescript/module/src/MapLibreRN.d.ts +1 -1
  58. package/lib/typescript/module/src/MapLibreRN.d.ts.map +1 -1
  59. package/lib/typescript/module/src/components/BackgroundLayer.d.ts.map +1 -1
  60. package/lib/typescript/module/src/components/Callout.d.ts.map +1 -1
  61. package/lib/typescript/module/src/components/CircleLayer.d.ts.map +1 -1
  62. package/lib/typescript/module/src/components/FillExtrusionLayer.d.ts.map +1 -1
  63. package/lib/typescript/module/src/components/FillLayer.d.ts.map +1 -1
  64. package/lib/typescript/module/src/components/HeatmapLayer.d.ts.map +1 -1
  65. package/lib/typescript/module/src/components/ImageSource.d.ts.map +1 -1
  66. package/lib/typescript/module/src/components/Images.d.ts +11 -2
  67. package/lib/typescript/module/src/components/Images.d.ts.map +1 -1
  68. package/lib/typescript/module/src/components/Light.d.ts.map +1 -1
  69. package/lib/typescript/module/src/components/LineLayer.d.ts.map +1 -1
  70. package/lib/typescript/module/src/components/MarkerView.d.ts.map +1 -1
  71. package/lib/typescript/module/src/components/NativeUserLocation.d.ts.map +1 -1
  72. package/lib/typescript/module/src/components/RasterLayer.d.ts.map +1 -1
  73. package/lib/typescript/module/src/components/RasterSource.d.ts.map +1 -1
  74. package/lib/typescript/module/src/components/ShapeSource.d.ts +5 -0
  75. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  76. package/lib/typescript/module/src/components/SymbolLayer.d.ts.map +1 -1
  77. package/lib/typescript/module/src/plugin/android.d.ts.map +1 -1
  78. package/lib/typescript/module/src/plugin/ios.d.ts.map +1 -1
  79. package/package.json +4 -4
  80. package/src/MapLibreRN.ts +1 -0
  81. package/src/components/Images.tsx +62 -67
  82. package/src/components/ShapeSource.tsx +6 -0
@@ -3,7 +3,7 @@ require "json"
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
5
  # Global Variable Defaults
6
- $MLRN_NATIVE_VERSION ||= "6.14.0"
6
+ $MLRN_NATIVE_VERSION ||= "6.17.1"
7
7
  $MLRN_SPM_SPEC ||= {
8
8
  url: "https://github.com/maplibre/maplibre-gl-native-distribution",
9
9
  requirement: {
package/README.md CHANGED
@@ -1,4 +1,12 @@
1
- [![MapLibre Logo](https://maplibre.org/img/maplibre-logo-big.svg)](https://maplibre.org)
1
+ <p align="center">
2
+ <a href="https://maplibre.org">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://maplibre.org/img/maplibre-logos/maplibre-logo-for-dark-bg.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://maplibre.org/img/maplibre-logos/maplibre-logo-for-light-bg.svg">
6
+ <img alt="MapLibre Logo" src="https://maplibre.org/img/maplibre-logos/maplibre-logo-for-light-bg.svg" width="200">
7
+ </picture>
8
+ </a>
9
+ </p>
2
10
 
3
11
  # MapLibre React Native
4
12
 
@@ -5,7 +5,7 @@ org.maplibre.reactnative.compileSdkVersion=35
5
5
  org.maplibre.reactnative.ndkVersion=27.1.12297006
6
6
 
7
7
  # MapLibre React Native
8
- org.maplibre.reactnative.nativeVersion=11.10.1
8
+ org.maplibre.reactnative.nativeVersion=11.12.1
9
9
  org.maplibre.reactnative.nativeVariant=opengl
10
10
  org.maplibre.reactnative.pluginVersion=3.0.2
11
11
  org.maplibre.reactnative.turfVersion=6.0.1
@@ -57,50 +57,46 @@ class MLRNPackage : BaseReactPackage() {
57
57
  moduleInfos[MLRNModule.REACT_CLASS] = ReactModuleInfo(
58
58
  MLRNModule.REACT_CLASS,
59
59
  MLRNModule.REACT_CLASS,
60
- false, // canOverrideExistingModule
61
- false, // needsEagerInit
62
- true, // hasConstants
63
- false, // isCxxModule
64
- false // isTurboModule
60
+ canOverrideExistingModule = false,
61
+ needsEagerInit = false,
62
+ isCxxModule = false,
63
+ isTurboModule = false
65
64
  )
66
65
 
67
66
  moduleInfos[MLRNOfflineModule.REACT_CLASS] = ReactModuleInfo(
68
67
  MLRNOfflineModule.REACT_CLASS,
69
68
  MLRNOfflineModule.REACT_CLASS,
70
- false, // canOverrideExistingModule
71
- false, // needsEagerInit
72
- true, // hasConstants
73
- false, // isCxxModule
74
- false // isTurboModule
69
+ canOverrideExistingModule = false,
70
+ needsEagerInit = false,
71
+ isCxxModule = false,
72
+ isTurboModule = false
75
73
  )
76
74
 
77
75
  moduleInfos[MLRNSnapshotModule.NAME] = ReactModuleInfo(
78
76
  MLRNSnapshotModule.NAME,
79
77
  MLRNSnapshotModule.NAME,
80
- false, // canOverrideExistingModule
81
- false, // needsEagerInit
82
- false, // isCxxModule
83
- true // isTurboModule
78
+ canOverrideExistingModule = false,
79
+ needsEagerInit = false,
80
+ isCxxModule = false,
81
+ isTurboModule = true
84
82
  )
85
83
 
86
84
  moduleInfos[MLRNLocationModule.REACT_CLASS] = ReactModuleInfo(
87
85
  MLRNLocationModule.REACT_CLASS,
88
86
  MLRNLocationModule.REACT_CLASS,
89
- false, // canOverrideExistingModule
90
- false, // needsEagerInit
91
- true, // hasConstants
92
- false, // isCxxModule
93
- false // isTurboModule
87
+ canOverrideExistingModule = false,
88
+ needsEagerInit = false,
89
+ isCxxModule = false,
90
+ isTurboModule = false
94
91
  )
95
92
 
96
93
  moduleInfos[MLRNLogging.REACT_CLASS] = ReactModuleInfo(
97
94
  MLRNLogging.REACT_CLASS,
98
95
  MLRNLogging.REACT_CLASS,
99
- false, // canOverrideExistingModule
100
- false, // needsEagerInit
101
- true, // hasConstants
102
- false, // isCxxModule
103
- false // isTurboModule
96
+ canOverrideExistingModule = false,
97
+ needsEagerInit = false,
98
+ isCxxModule = false,
99
+ isTurboModule = false
104
100
  )
105
101
 
106
102
  moduleInfos
@@ -64,6 +64,9 @@ public class MLRNImagesManager extends AbstractEventEmitter<MLRNImages> {
64
64
  boolean hasScale = imageMap.hasKey("scale") && imageMap.getType("scale") == ReadableType.Number;
65
65
  double scale = hasScale ? imageMap.getDouble("scale") : ImageEntry.defaultScale;
66
66
  imageEntry = new ImageEntry(uri, scale);
67
+
68
+ boolean hasSdf = imageMap.hasKey("sdf") && imageMap.getType("sdf") == ReadableType.Boolean;
69
+ imageEntry.sdf = hasSdf && imageMap.getBoolean("sdf");
67
70
  } else {
68
71
  imageEntry = new ImageEntry(map.getString(imageName));
69
72
  }
@@ -40,6 +40,7 @@ public class MLRNShapeSource extends MLRNSource<GeoJsonSource> {
40
40
 
41
41
  private Boolean mCluster;
42
42
  private Integer mClusterRadius;
43
+ private Integer mClusterMinPoints;
43
44
  private Integer mClusterMaxZoom;
44
45
  private List<Map.Entry<String, ClusterPropertyEntry>> mClusterProperties;
45
46
 
@@ -104,6 +105,10 @@ public class MLRNShapeSource extends MLRNSource<GeoJsonSource> {
104
105
  mClusterRadius = clusterRadius;
105
106
  }
106
107
 
108
+ public void setClusterMinPoints(int clusterMinPoints) {
109
+ mClusterMinPoints = clusterMinPoints;
110
+ }
111
+
107
112
  public void setClusterMaxZoom(int clusterMaxZoom) {
108
113
  mClusterMaxZoom = clusterMaxZoom;
109
114
  }
@@ -143,6 +148,10 @@ public class MLRNShapeSource extends MLRNSource<GeoJsonSource> {
143
148
  options.withClusterRadius(mClusterRadius);
144
149
  }
145
150
 
151
+ if (mClusterMinPoints != null) {
152
+ options.withClusterMinPoints(mClusterMinPoints);
153
+ }
154
+
146
155
  if (mClusterMaxZoom != null) {
147
156
  options.withClusterMaxZoom(mClusterMaxZoom);
148
157
  }
@@ -106,6 +106,11 @@ public class MLRNShapeSourceManager extends AbstractEventEmitter<MLRNShapeSource
106
106
  source.setClusterRadius(radius);
107
107
  }
108
108
 
109
+ @ReactProp(name = "clusterMinPoints")
110
+ public void setClusterMinPoints(MLRNShapeSource source, int minPoints) {
111
+ source.setClusterMinPoints(minPoints);
112
+ }
113
+
109
114
  @ReactProp(name = "clusterMaxZoomLevel")
110
115
  public void setClusterMaxZoomLevel(MLRNShapeSource source, int clusterMaxZoom) {
111
116
  source.setClusterMaxZoom(clusterMaxZoom);
@@ -17,8 +17,6 @@ import org.maplibre.geojson.Point
17
17
  import org.maplibre.reactnative.NativeSnapshotModuleSpec
18
18
  import org.maplibre.reactnative.utils.BitmapUtils
19
19
  import org.maplibre.reactnative.utils.GeoJSONUtils
20
- import java.io.IOException
21
- import java.io.OutputStream
22
20
  import java.util.UUID
23
21
 
24
22
  @ReactModule(name = MLRNSnapshotModule.NAME)
@@ -33,15 +31,14 @@ class MLRNSnapshotModule(reactContext: ReactApplicationContext) :
33
31
  private val context: ReactApplicationContext = reactContext
34
32
 
35
33
  // Prevent garbage collection
36
- private val snapshotterMap: MutableMap<String, MapSnapshotter> =
37
- HashMap<String, MapSnapshotter>()
34
+ private val snapshotterMap: MutableMap<String, MapSnapshotter> = HashMap()
38
35
 
39
36
  override fun takeSnap(jsOptions: ReadableMap, promise: Promise) {
40
37
  org.maplibre.android.storage.FileSource.getInstance(context).activate()
41
38
 
42
39
  context.runOnUiQueueThread {
43
40
  val snapshotterID = UUID.randomUUID().toString()
44
- val snapshotter: MapSnapshotter = MapSnapshotter(context, getOptions(jsOptions))
41
+ val snapshotter = MapSnapshotter(context, getOptions(jsOptions))
45
42
  snapshotterMap[snapshotterID] = snapshotter
46
43
  snapshotter.start(object :
47
44
  MapSnapshotter.SnapshotReadyCallback {
@@ -114,15 +111,4 @@ class MLRNSnapshotModule(reactContext: ReactApplicationContext) :
114
111
 
115
112
  return options
116
113
  }
117
-
118
- private fun closeSnapshotOutputStream(outputStream: OutputStream?) {
119
- if (outputStream == null) {
120
- return
121
- }
122
- try {
123
- outputStream.close()
124
- } catch (e: IOException) {
125
- e.localizedMessage?.let { Log.w(NAME, it) }
126
- }
127
- }
128
114
  }
@@ -33,7 +33,7 @@ import java.util.Map;
33
33
 
34
34
  import javax.annotation.Nullable;
35
35
 
36
- public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry>, Void, List<Map.Entry<String, Bitmap>>> {
36
+ public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry>, Void, List<Map.Entry<String, DownloadedImage>>> {
37
37
  public static final String LOG_TAG = "DownloadMapImageTask";
38
38
 
39
39
  private WeakReference<Context> mContext;
@@ -55,8 +55,8 @@ public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry
55
55
 
56
56
  @SafeVarargs
57
57
  @Override
58
- protected final List<Map.Entry<String, Bitmap>> doInBackground(Map.Entry<String, ImageEntry>... objects) {
59
- List<Map.Entry<String, Bitmap>> images = new ArrayList<>();
58
+ protected final List<Map.Entry<String, DownloadedImage>> doInBackground(Map.Entry<String, ImageEntry>... objects) {
59
+ List<Map.Entry<String, DownloadedImage>> images = new ArrayList<>();
60
60
 
61
61
  Context context = mContext.get();
62
62
  if (context == null) return images;
@@ -95,7 +95,7 @@ public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry
95
95
  // the fresco reference.
96
96
  .copy(Bitmap.Config.ARGB_8888, true);
97
97
  bitmap.setDensity((int) ((double) DisplayMetrics.DENSITY_DEFAULT * imageEntry.getScaleOr(1.0)));
98
- images.add(new AbstractMap.SimpleEntry<>(object.getKey(), bitmap));
98
+ images.add(new AbstractMap.SimpleEntry<>(object.getKey(), new DownloadedImage(object.getKey(), bitmap, imageEntry)));
99
99
  } else {
100
100
  FLog.e(LOG_TAG, "Failed to load bitmap from: " + uri);
101
101
  }
@@ -114,7 +114,7 @@ public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry
114
114
  // local asset required from JS require('image.png') or import icon from 'image.png' while in release mode
115
115
  Bitmap bitmap = BitmapUtils.getBitmapFromResource(context, uri, getBitmapOptions(metrics, imageEntry.scale));
116
116
  if (bitmap != null) {
117
- images.add(new AbstractMap.SimpleEntry<>(object.getKey(), bitmap));
117
+ images.add(new AbstractMap.SimpleEntry<>(object.getKey(), new DownloadedImage(object.getKey(), bitmap, imageEntry)));
118
118
  } else {
119
119
  FLog.e(LOG_TAG, "Failed to load bitmap from: " + uri);
120
120
  }
@@ -125,16 +125,14 @@ public class DownloadMapImageTask extends AsyncTask<Map.Entry<String, ImageEntry
125
125
  }
126
126
 
127
127
  @Override
128
- protected void onPostExecute(List<Map.Entry<String, Bitmap>> images) {
128
+ protected void onPostExecute(List<Map.Entry<String, DownloadedImage>> images) {
129
129
  MapLibreMap map = mMap.get();
130
130
  if (map != null && images != null && images.size() > 0) {
131
131
  Style style = map.getStyle();
132
132
  if (style != null) {
133
- HashMap<String, Bitmap> bitmapImages = new HashMap<>();
134
- for (Map.Entry<String, Bitmap> image : images) {
135
- bitmapImages.put(image.getKey(), image.getValue());
133
+ for (Map.Entry<String, DownloadedImage> image : images) {
134
+ style.addImage(image.getKey(), image.getValue().bitmap(), image.getValue().info().sdf);
136
135
  }
137
- style.addImages(bitmapImages);
138
136
  }
139
137
  }
140
138
 
@@ -0,0 +1,6 @@
1
+ package org.maplibre.reactnative.utils;
2
+
3
+ import android.graphics.Bitmap;
4
+
5
+ public record DownloadedImage(String name, Bitmap bitmap, ImageEntry info) {
6
+ }
@@ -4,6 +4,7 @@ public class ImageEntry {
4
4
  public String uri;
5
5
  public double scale = 1.0;
6
6
  public static final double defaultScale = 0.0;
7
+ public boolean sdf;
7
8
 
8
9
  public ImageEntry(String _uri, Double _scale) {
9
10
  uri = _uri;
@@ -8,6 +8,7 @@
8
8
  - (void)cancelAllOperations;
9
9
  - (void)addImage:(NSString *)imageURL
10
10
  scale:(double)scale
11
+ sdf:(Boolean)sdf
11
12
  bridge:(RCTBridge *)bridge
12
13
  completionHandler:(RCTImageLoaderCompletionBlock)handler;
13
14
 
@@ -33,11 +33,13 @@
33
33
 
34
34
  - (void)addImage:(NSString *)imageURL
35
35
  scale:(double)scale
36
+ sdf:(Boolean)sdf
36
37
  bridge:(RCTBridge *)bridge
37
38
  completionHandler:(RCTImageLoaderCompletionBlock)handler {
38
39
  MLRNImageQueueOperation *operation = [[MLRNImageQueueOperation alloc] init];
39
40
  operation.bridge = bridge;
40
41
  operation.urlRequest = [RCTConvert NSURLRequest:imageURL];
42
+ operation.sdf = sdf;
41
43
  operation.completionHandler = handler;
42
44
  operation.scale = scale;
43
45
  [imageQueue addOperation:operation];
@@ -5,6 +5,7 @@
5
5
  @property (nonatomic, weak) RCTBridge *bridge;
6
6
  @property (nonatomic, copy) RCTImageLoaderCompletionBlock completionHandler;
7
7
  @property (nonatomic, copy) NSURLRequest *urlRequest;
8
+ @property (nonatomic) Boolean sdf;
8
9
  @property (nonatomic) double scale;
9
10
 
10
11
  @end
@@ -100,21 +100,23 @@ typedef NS_ENUM(NSInteger, MLRNImageQueueOperationState) {
100
100
  }
101
101
  __weak MLRNImageQueueOperation *weakSelf = self;
102
102
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
103
- [weakSelf
104
- setCancellationBlock:[[weakSelf.bridge moduleForName:@"ImageLoader"
105
- lazilyLoadIfNecessary:YES]
106
- loadImageWithURLRequest:weakSelf.urlRequest
107
- size:CGSizeZero
108
- scale:weakSelf.scale
109
- clipped:YES
110
- resizeMode:RCTResizeModeStretch
111
- progressBlock:nil
112
- partialLoadBlock:nil
113
- completionBlock:^void(NSError *error, UIImage *image) {
114
- weakSelf.completionHandler(error, image);
115
- [weakSelf setState:IOState_Finished
116
- except:IOState_Finished];
117
- }]];
103
+ [weakSelf setCancellationBlock:
104
+ [[weakSelf.bridge moduleForName:@"ImageLoader" lazilyLoadIfNecessary:YES]
105
+ loadImageWithURLRequest:weakSelf.urlRequest
106
+ size:CGSizeZero
107
+ scale:weakSelf.scale
108
+ clipped:YES
109
+ resizeMode:RCTResizeModeStretch
110
+ progressBlock:nil
111
+ partialLoadBlock:nil
112
+ completionBlock:^void(NSError *error, UIImage *image) {
113
+ if (image && weakSelf.sdf) {
114
+ image = [image
115
+ imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
116
+ }
117
+ weakSelf.completionHandler(error, image);
118
+ [weakSelf setState:IOState_Finished except:IOState_Finished];
119
+ }]];
118
120
  if ([weakSelf setState:IOState_Executing
119
121
  only:IOState_Initial] == IOState_CancelledDoNotExecute) {
120
122
  [weakSelf callCancellationBlock];
@@ -45,12 +45,12 @@ RCT_EXPORT_MODULE(MLRNMapView)
45
45
  UILongPressGestureRecognizer *longPress =
46
46
  [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(didLongPressMap:)];
47
47
 
48
- // this allows the internal annotation gestures to take precedents over the map tap gesture
48
+ // this allows the internal annotation gestures to take precedence over the map tap gesture
49
49
  for (int i = 0; i < mapView.gestureRecognizers.count; i++) {
50
- UIGestureRecognizer *gestuerReconginer = mapView.gestureRecognizers[i];
50
+ UIGestureRecognizer *gestureRecognizer = mapView.gestureRecognizers[i];
51
51
 
52
- if ([gestuerReconginer isKindOfClass:[UITapGestureRecognizer class]]) {
53
- [tap requireGestureRecognizerToFail:gestuerReconginer];
52
+ if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
53
+ [tap requireGestureRecognizerToFail:gestureRecognizer];
54
54
  }
55
55
  }
56
56
 
@@ -12,6 +12,7 @@
12
12
 
13
13
  @property (nonatomic, strong, nullable) NSNumber *cluster;
14
14
  @property (nonatomic, strong, nullable) NSNumber *clusterRadius;
15
+ @property (nonatomic, strong, nullable) NSNumber *clusterMinPoints;
15
16
  @property (nonatomic, strong, nullable) NSNumber *clusterMaxZoomLevel;
16
17
  @property (nonatomic, strong, nullable)
17
18
  NSDictionary<NSString *, NSArray<NSExpression *> *> *clusterProperties;
@@ -64,6 +64,10 @@ static UIImage *_placeHolderImage;
64
64
  options[MLNShapeSourceOptionClusterRadius] = _clusterRadius;
65
65
  }
66
66
 
67
+ if (_clusterMinPoints != nil) {
68
+ options[MLNShapeSourceOptionClusterMinPoints] = _clusterMinPoints;
69
+ }
70
+
67
71
  if (_clusterMaxZoomLevel != nil) {
68
72
  options[MLNShapeSourceOptionMaximumZoomLevelForClustering] = _clusterMaxZoomLevel;
69
73
  }
@@ -15,6 +15,7 @@ RCT_EXPORT_VIEW_PROPERTY(shape, NSString)
15
15
 
16
16
  RCT_EXPORT_VIEW_PROPERTY(cluster, NSNumber)
17
17
  RCT_EXPORT_VIEW_PROPERTY(clusterRadius, NSNumber)
18
+ RCT_EXPORT_VIEW_PROPERTY(clusterMinPoints, NSNumber)
18
19
  RCT_EXPORT_VIEW_PROPERTY(clusterMaxZoomLevel, NSNumber)
19
20
  RCT_EXPORT_VIEW_PROPERTY(clusterProperties, NSDictionary)
20
21
  RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber)
package/ios/MLRNStyle.m CHANGED
@@ -56,7 +56,7 @@
56
56
  } else {
57
57
  NSString *imageURI = [styleValue getImageURI];
58
58
 
59
- [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] callback:^(NSError *error, UIImage *image) {
59
+ [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] sdf:[styleValue getImageSdf] callback:^(NSError *error, UIImage *image) {
60
60
  if (image != nil) {
61
61
  dispatch_async(dispatch_get_main_queue(), ^{
62
62
  if (isValid()) {
@@ -138,7 +138,7 @@
138
138
  } else {
139
139
  NSString *imageURI = [styleValue getImageURI];
140
140
 
141
- [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] callback:^(NSError *error, UIImage *image) {
141
+ [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] sdf:[styleValue getImageSdf] callback:^(NSError *error, UIImage *image) {
142
142
  if (image != nil) {
143
143
  dispatch_async(dispatch_get_main_queue(), ^{
144
144
  if (isValid()) {
@@ -200,7 +200,7 @@
200
200
  } else {
201
201
  NSString *imageURI = [styleValue getImageURI];
202
202
 
203
- [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] callback:^(NSError *error, UIImage *image) {
203
+ [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] sdf:[styleValue getImageSdf] callback:^(NSError *error, UIImage *image) {
204
204
  if (image != nil) {
205
205
  dispatch_async(dispatch_get_main_queue(), ^{
206
206
  if (isValid()) {
@@ -454,7 +454,7 @@
454
454
  } else {
455
455
  NSString *imageURI = [styleValue getImageURI];
456
456
 
457
- [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] callback:^(NSError *error, UIImage *image) {
457
+ [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] sdf:[styleValue getImageSdf] callback:^(NSError *error, UIImage *image) {
458
458
  if (image != nil) {
459
459
  dispatch_async(dispatch_get_main_queue(), ^{
460
460
  if (isValid()) {
@@ -592,7 +592,7 @@
592
592
  } else {
593
593
  NSString *imageURI = [styleValue getImageURI];
594
594
 
595
- [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] callback:^(NSError *error, UIImage *image) {
595
+ [MLRNUtils fetchImage:_bridge url:imageURI scale:[styleValue getImageScale] sdf:[styleValue getImageSdf] callback:^(NSError *error, UIImage *image) {
596
596
  if (image != nil) {
597
597
  dispatch_async(dispatch_get_main_queue(), ^{
598
598
  if (isValid()) {
@@ -10,6 +10,7 @@
10
10
  - (BOOL)shouldAddImage;
11
11
  - (NSString *)getImageURI;
12
12
  - (double)getImageScale;
13
+ - (BOOL)getImageSdf;
13
14
  - (MLNTransition)getTransition;
14
15
  - (NSExpression *)getSphericalPosition;
15
16
  - (BOOL)isVisible;
@@ -114,6 +114,19 @@
114
114
  }
115
115
  }
116
116
 
117
+ - (BOOL)getImageSdf {
118
+ if ([expressionJSON isKindOfClass:[NSDictionary class]]) {
119
+ id sdf = [expressionJSON valueForKey:@"sdf"];
120
+ if ([sdf isKindOfClass:[NSNumber class]]) {
121
+ return [sdf boolValue];
122
+ } else {
123
+ return false;
124
+ }
125
+ } else {
126
+ return false;
127
+ }
128
+ }
129
+
117
130
  - (MLNTransition)getTransition {
118
131
  if (![expressionJSON isKindOfClass:[NSDictionary class]]) {
119
132
  return MLNTransitionMake(0.f, 0.f);
package/ios/MLRNUtils.h CHANGED
@@ -16,6 +16,7 @@
16
16
  + (void)fetchImage:(RCTBridge *)bridge
17
17
  url:(NSString *)url
18
18
  scale:(double)scale
19
+ sdf:(Boolean)sdf
19
20
  callback:(RCTImageLoaderCompletionBlock)callback;
20
21
  + (void)fetchImages:(RCTBridge *)bridge
21
22
  style:(MLNStyle *)style
package/ios/MLRNUtils.m CHANGED
@@ -79,8 +79,13 @@ static double const MS_TO_S = 0.001;
79
79
  + (void)fetchImage:(RCTBridge *)bridge
80
80
  url:(NSString *)url
81
81
  scale:(double)scale
82
+ sdf:(Boolean)sdf
82
83
  callback:(RCTImageLoaderCompletionBlock)callback {
83
- [MLRNImageQueue.sharedInstance addImage:url scale:scale bridge:bridge completionHandler:callback];
84
+ [MLRNImageQueue.sharedInstance addImage:url
85
+ scale:scale
86
+ sdf:sdf
87
+ bridge:bridge
88
+ completionHandler:callback];
84
89
  }
85
90
 
86
91
  + (void)fetchImages:(RCTBridge *)bridge
@@ -117,9 +122,13 @@ static double const MS_TO_S = 0.001;
117
122
  NSDictionary *image = objects[imageName];
118
123
  BOOL hasScale =
119
124
  [image isKindOfClass:[NSDictionary class]] && ([image objectForKey:@"scale"] != nil);
125
+ BOOL hasSdf =
126
+ [image isKindOfClass:[NSDictionary class]] && ([image objectForKey:@"sdf"] != nil);
120
127
  double scale = hasScale ? [[image objectForKey:@"scale"] doubleValue] : 1.0;
128
+ double sdf = hasSdf ? [[image objectForKey:@"sdf"] boolValue] : false;
121
129
  [MLRNImageQueue.sharedInstance addImage:objects[imageName]
122
130
  scale:scale
131
+ sdf:sdf
123
132
  bridge:bridge
124
133
  completionHandler:^(NSError *error, UIImage *image) {
125
134
  if (!image) {
@@ -1 +1 @@
1
- {"version":3,"names":["_MLRNModule","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Camera","_MapView","_Light","_PointAnnotation","_Annotation","_Callout","_requestAndroidLocationPermissions","_UserLocation","_VectorSource","_ShapeSource","_RasterSource","_ImageSource","_Images","_FillLayer","_FillExtrusionLayer","_HeatmapLayer","_LineLayer","_CircleLayer","_SymbolLayer","_RasterLayer","_BackgroundLayer","_MarkerView","_LocationManager","_OfflineManager","_OfflinePack","_OfflineCreatePackOptions","_SnapshotManager","_Animated","_Logger"],"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IAAA2B,mBAAA,GAAA3B,OAAA;AACA,IAAA4B,aAAA,GAAA5B,OAAA;AACA,IAAA6B,UAAA,GAAA7B,OAAA;AACA,IAAA8B,YAAA,GAAA9B,OAAA;AACA,IAAA+B,YAAA,GAAA/B,OAAA;AACA,IAAAgC,YAAA,GAAAhC,OAAA;AACA,IAAAiC,gBAAA,GAAAjC,OAAA;AACA,IAAAkC,WAAA,GAAAlC,OAAA;AAEA,IAAAmC,gBAAA,GAAAnC,OAAA;AAIA,IAAAoC,eAAA,GAAApC,OAAA;AAGA,IAAAqC,YAAA,GAAArC,OAAA;AACA,IAAAsC,yBAAA,GAAAtC,OAAA;AACA,IAAAuC,gBAAA,GAAAvC,OAAA;AAoBA,IAAAwC,SAAA,GAAAxC,OAAA;AACA,IAAAyC,OAAA,GAAAzC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_MLRNModule","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Camera","_MapView","_Light","_PointAnnotation","_Annotation","_Callout","_requestAndroidLocationPermissions","_UserLocation","_VectorSource","_ShapeSource","_RasterSource","_ImageSource","_Images","_FillLayer","_FillExtrusionLayer","_HeatmapLayer","_LineLayer","_CircleLayer","_SymbolLayer","_RasterLayer","_BackgroundLayer","_MarkerView","_LocationManager","_OfflineManager","_OfflinePack","_OfflineCreatePackOptions","_SnapshotManager","_Animated","_Logger"],"sourceRoot":"../../src","sources":["MapLibreRN.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MA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AAA,GAAArC,OAAA;AACA,IAAAsC,yBAAA,GAAAtC,OAAA;AACA,IAAAuC,gBAAA,GAAAvC,OAAA;AAoBA,IAAAwC,SAAA,GAAAxC,OAAA;AACA,IAAAyC,OAAA,GAAAzC,OAAA","ignoreList":[]}
@@ -4,21 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.NATIVE_MODULE_NAME = exports.Images = void 0;
7
+ var _react = require("react");
7
8
  var _reactNative = require("react-native");
8
9
  var _jsxRuntime = require("react/jsx-runtime");
9
10
  const NATIVE_MODULE_NAME = exports.NATIVE_MODULE_NAME = "MLRNImages";
10
- function _isUrlOrPath(value) {
11
- return (typeof value === "string" || value instanceof String) && (value.startsWith("file://") || value.startsWith("http://") || value.startsWith("https://") || value.startsWith("data:") || value.startsWith("asset://") || value.startsWith("/"));
12
- }
13
- function _isImageSourcePropType(value) {
14
- if (typeof value === "number" || value instanceof Number) {
15
- return true;
16
- }
17
- const valueAsSource = value;
18
- return !!valueAsSource.uri && typeof valueAsSource.uri === "string";
19
- }
20
11
  /**
21
- * Images defines the images used in Symbol etc layers
12
+ * Images defines the images used in Symbol layers
22
13
  */
23
14
  const Images = ({
24
15
  images,
@@ -27,45 +18,40 @@ const Images = ({
27
18
  id,
28
19
  children
29
20
  }) => {
30
- const _getImages = () => {
31
- if (!images && !nativeAssetImages) {
32
- return {};
33
- }
34
- const imagesResult = {};
35
- let nativeImages = [];
36
- if (images) {
37
- const imageNames = Object.keys(images);
38
- for (const imageName of imageNames) {
39
- const value = images[imageName];
40
- if (value && _isUrlOrPath(value)) {
41
- imagesResult[imageName] = value;
42
- } else if (value && _isImageSourcePropType(value)) {
43
- const res = _reactNative.Image.resolveAssetSource(value);
44
- if (res && res.uri) {
45
- imagesResult[imageName] = res;
21
+ const props = (0, _react.useMemo)(() => {
22
+ const getImages = () => {
23
+ if (!images && !nativeAssetImages) {
24
+ return {};
25
+ }
26
+ const imagesResult = {};
27
+ if (images) {
28
+ Object.entries(images).forEach(([imageName, value]) => {
29
+ if (typeof value === "string") {
30
+ imagesResult[imageName] = value;
31
+ } else if (typeof value === "object" && "source" in value && value.source) {
32
+ imagesResult[imageName] = {
33
+ ..._reactNative.Image.resolveAssetSource(value.source),
34
+ sdf: value.sdf
35
+ };
36
+ } else {
37
+ imagesResult[imageName] = _reactNative.Image.resolveAssetSource(value);
46
38
  }
47
- }
39
+ });
48
40
  }
49
- }
50
- if (nativeAssetImages) {
51
- nativeImages = nativeAssetImages;
52
- }
41
+ return imagesResult;
42
+ };
53
43
  return {
54
- images: imagesResult,
55
- nativeImages
44
+ id,
45
+ hasOnImageMissing: !!onImageMissing,
46
+ onImageMissing: event => {
47
+ if (onImageMissing) {
48
+ onImageMissing(event.nativeEvent.payload.imageKey);
49
+ }
50
+ },
51
+ images: getImages(),
52
+ nativeImages: nativeAssetImages ?? []
56
53
  };
57
- };
58
- const _onImageMissing = event => {
59
- if (onImageMissing) {
60
- onImageMissing(event.nativeEvent.payload.imageKey);
61
- }
62
- };
63
- const props = {
64
- id,
65
- hasOnImageMissing: !!onImageMissing,
66
- onImageMissing: _onImageMissing,
67
- ..._getImages()
68
- };
54
+ }, [id, onImageMissing, images, nativeAssetImages]);
69
55
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(MLRNImages, {
70
56
  ...props,
71
57
  children: children