@maydon_tech/react-native-nitro-maps 0.1.0 → 0.1.2

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.
@@ -31,6 +31,7 @@ namespace margelo::nitro::nitromap { struct MarkerColor; }
31
31
  namespace margelo::nitro::nitromap { enum class ClusterAnimationStyle; }
32
32
 
33
33
  #include "ClusterStrategy.hpp"
34
+ #include <optional>
34
35
  #include <string>
35
36
  #include "MarkerColor.hpp"
36
37
  #include <variant>
@@ -44,24 +45,24 @@ namespace margelo::nitro::nitromap {
44
45
  struct ClusterConfig {
45
46
  public:
46
47
  bool enabled SWIFT_PRIVATE;
47
- ClusterStrategy strategy SWIFT_PRIVATE;
48
- double radius SWIFT_PRIVATE;
49
- double minimumClusterSize SWIFT_PRIVATE;
50
- double maxZoom SWIFT_PRIVATE;
51
- std::variant<std::string, MarkerColor> backgroundColor SWIFT_PRIVATE;
52
- std::variant<std::string, MarkerColor> textColor SWIFT_PRIVATE;
53
- double borderWidth SWIFT_PRIVATE;
54
- std::variant<std::string, MarkerColor> borderColor SWIFT_PRIVATE;
55
- bool animatesClusters SWIFT_PRIVATE;
56
- double animationDuration SWIFT_PRIVATE;
57
- ClusterAnimationStyle animationStyle SWIFT_PRIVATE;
58
- bool realtimeClustering SWIFT_PRIVATE;
59
- double renderBuffer SWIFT_PRIVATE;
60
- double throttleInterval SWIFT_PRIVATE;
48
+ std::optional<ClusterStrategy> strategy SWIFT_PRIVATE;
49
+ std::optional<double> radius SWIFT_PRIVATE;
50
+ std::optional<double> minimumClusterSize SWIFT_PRIVATE;
51
+ std::optional<double> maxZoom SWIFT_PRIVATE;
52
+ std::optional<std::variant<std::string, MarkerColor>> backgroundColor SWIFT_PRIVATE;
53
+ std::optional<std::variant<std::string, MarkerColor>> textColor SWIFT_PRIVATE;
54
+ std::optional<double> borderWidth SWIFT_PRIVATE;
55
+ std::optional<std::variant<std::string, MarkerColor>> borderColor SWIFT_PRIVATE;
56
+ std::optional<bool> animatesClusters SWIFT_PRIVATE;
57
+ std::optional<double> animationDuration SWIFT_PRIVATE;
58
+ std::optional<ClusterAnimationStyle> animationStyle SWIFT_PRIVATE;
59
+ std::optional<bool> realtimeClustering SWIFT_PRIVATE;
60
+ std::optional<double> renderBuffer SWIFT_PRIVATE;
61
+ std::optional<double> throttleInterval SWIFT_PRIVATE;
61
62
 
62
63
  public:
63
64
  ClusterConfig() = default;
64
- explicit ClusterConfig(bool enabled, ClusterStrategy strategy, double radius, double minimumClusterSize, double maxZoom, std::variant<std::string, MarkerColor> backgroundColor, std::variant<std::string, MarkerColor> textColor, double borderWidth, std::variant<std::string, MarkerColor> borderColor, bool animatesClusters, double animationDuration, ClusterAnimationStyle animationStyle, bool realtimeClustering, double renderBuffer, double throttleInterval): enabled(enabled), strategy(strategy), radius(radius), minimumClusterSize(minimumClusterSize), maxZoom(maxZoom), backgroundColor(backgroundColor), textColor(textColor), borderWidth(borderWidth), borderColor(borderColor), animatesClusters(animatesClusters), animationDuration(animationDuration), animationStyle(animationStyle), realtimeClustering(realtimeClustering), renderBuffer(renderBuffer), throttleInterval(throttleInterval) {}
65
+ explicit ClusterConfig(bool enabled, std::optional<ClusterStrategy> strategy, std::optional<double> radius, std::optional<double> minimumClusterSize, std::optional<double> maxZoom, std::optional<std::variant<std::string, MarkerColor>> backgroundColor, std::optional<std::variant<std::string, MarkerColor>> textColor, std::optional<double> borderWidth, std::optional<std::variant<std::string, MarkerColor>> borderColor, std::optional<bool> animatesClusters, std::optional<double> animationDuration, std::optional<ClusterAnimationStyle> animationStyle, std::optional<bool> realtimeClustering, std::optional<double> renderBuffer, std::optional<double> throttleInterval): enabled(enabled), strategy(strategy), radius(radius), minimumClusterSize(minimumClusterSize), maxZoom(maxZoom), backgroundColor(backgroundColor), textColor(textColor), borderWidth(borderWidth), borderColor(borderColor), animatesClusters(animatesClusters), animationDuration(animationDuration), animationStyle(animationStyle), realtimeClustering(realtimeClustering), renderBuffer(renderBuffer), throttleInterval(throttleInterval) {}
65
66
  };
66
67
 
67
68
  } // namespace margelo::nitro::nitromap
@@ -75,39 +76,39 @@ namespace margelo::nitro {
75
76
  jsi::Object obj = arg.asObject(runtime);
76
77
  return margelo::nitro::nitromap::ClusterConfig(
77
78
  JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "enabled")),
78
- JSIConverter<margelo::nitro::nitromap::ClusterStrategy>::fromJSI(runtime, obj.getProperty(runtime, "strategy")),
79
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "radius")),
80
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "minimumClusterSize")),
81
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "maxZoom")),
82
- JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::fromJSI(runtime, obj.getProperty(runtime, "backgroundColor")),
83
- JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::fromJSI(runtime, obj.getProperty(runtime, "textColor")),
84
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "borderWidth")),
85
- JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::fromJSI(runtime, obj.getProperty(runtime, "borderColor")),
86
- JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "animatesClusters")),
87
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "animationDuration")),
88
- JSIConverter<margelo::nitro::nitromap::ClusterAnimationStyle>::fromJSI(runtime, obj.getProperty(runtime, "animationStyle")),
89
- JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "realtimeClustering")),
90
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "renderBuffer")),
91
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "throttleInterval"))
79
+ JSIConverter<std::optional<margelo::nitro::nitromap::ClusterStrategy>>::fromJSI(runtime, obj.getProperty(runtime, "strategy")),
80
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "radius")),
81
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "minimumClusterSize")),
82
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "maxZoom")),
83
+ JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::fromJSI(runtime, obj.getProperty(runtime, "backgroundColor")),
84
+ JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::fromJSI(runtime, obj.getProperty(runtime, "textColor")),
85
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "borderWidth")),
86
+ JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::fromJSI(runtime, obj.getProperty(runtime, "borderColor")),
87
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "animatesClusters")),
88
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "animationDuration")),
89
+ JSIConverter<std::optional<margelo::nitro::nitromap::ClusterAnimationStyle>>::fromJSI(runtime, obj.getProperty(runtime, "animationStyle")),
90
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "realtimeClustering")),
91
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "renderBuffer")),
92
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "throttleInterval"))
92
93
  );
93
94
  }
94
95
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitromap::ClusterConfig& arg) {
95
96
  jsi::Object obj(runtime);
96
97
  obj.setProperty(runtime, "enabled", JSIConverter<bool>::toJSI(runtime, arg.enabled));
97
- obj.setProperty(runtime, "strategy", JSIConverter<margelo::nitro::nitromap::ClusterStrategy>::toJSI(runtime, arg.strategy));
98
- obj.setProperty(runtime, "radius", JSIConverter<double>::toJSI(runtime, arg.radius));
99
- obj.setProperty(runtime, "minimumClusterSize", JSIConverter<double>::toJSI(runtime, arg.minimumClusterSize));
100
- obj.setProperty(runtime, "maxZoom", JSIConverter<double>::toJSI(runtime, arg.maxZoom));
101
- obj.setProperty(runtime, "backgroundColor", JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::toJSI(runtime, arg.backgroundColor));
102
- obj.setProperty(runtime, "textColor", JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::toJSI(runtime, arg.textColor));
103
- obj.setProperty(runtime, "borderWidth", JSIConverter<double>::toJSI(runtime, arg.borderWidth));
104
- obj.setProperty(runtime, "borderColor", JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::toJSI(runtime, arg.borderColor));
105
- obj.setProperty(runtime, "animatesClusters", JSIConverter<bool>::toJSI(runtime, arg.animatesClusters));
106
- obj.setProperty(runtime, "animationDuration", JSIConverter<double>::toJSI(runtime, arg.animationDuration));
107
- obj.setProperty(runtime, "animationStyle", JSIConverter<margelo::nitro::nitromap::ClusterAnimationStyle>::toJSI(runtime, arg.animationStyle));
108
- obj.setProperty(runtime, "realtimeClustering", JSIConverter<bool>::toJSI(runtime, arg.realtimeClustering));
109
- obj.setProperty(runtime, "renderBuffer", JSIConverter<double>::toJSI(runtime, arg.renderBuffer));
110
- obj.setProperty(runtime, "throttleInterval", JSIConverter<double>::toJSI(runtime, arg.throttleInterval));
98
+ obj.setProperty(runtime, "strategy", JSIConverter<std::optional<margelo::nitro::nitromap::ClusterStrategy>>::toJSI(runtime, arg.strategy));
99
+ obj.setProperty(runtime, "radius", JSIConverter<std::optional<double>>::toJSI(runtime, arg.radius));
100
+ obj.setProperty(runtime, "minimumClusterSize", JSIConverter<std::optional<double>>::toJSI(runtime, arg.minimumClusterSize));
101
+ obj.setProperty(runtime, "maxZoom", JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxZoom));
102
+ obj.setProperty(runtime, "backgroundColor", JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::toJSI(runtime, arg.backgroundColor));
103
+ obj.setProperty(runtime, "textColor", JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::toJSI(runtime, arg.textColor));
104
+ obj.setProperty(runtime, "borderWidth", JSIConverter<std::optional<double>>::toJSI(runtime, arg.borderWidth));
105
+ obj.setProperty(runtime, "borderColor", JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::toJSI(runtime, arg.borderColor));
106
+ obj.setProperty(runtime, "animatesClusters", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.animatesClusters));
107
+ obj.setProperty(runtime, "animationDuration", JSIConverter<std::optional<double>>::toJSI(runtime, arg.animationDuration));
108
+ obj.setProperty(runtime, "animationStyle", JSIConverter<std::optional<margelo::nitro::nitromap::ClusterAnimationStyle>>::toJSI(runtime, arg.animationStyle));
109
+ obj.setProperty(runtime, "realtimeClustering", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.realtimeClustering));
110
+ obj.setProperty(runtime, "renderBuffer", JSIConverter<std::optional<double>>::toJSI(runtime, arg.renderBuffer));
111
+ obj.setProperty(runtime, "throttleInterval", JSIConverter<std::optional<double>>::toJSI(runtime, arg.throttleInterval));
111
112
  return obj;
112
113
  }
113
114
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -119,20 +120,20 @@ namespace margelo::nitro {
119
120
  return false;
120
121
  }
121
122
  if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "enabled"))) return false;
122
- if (!JSIConverter<margelo::nitro::nitromap::ClusterStrategy>::canConvert(runtime, obj.getProperty(runtime, "strategy"))) return false;
123
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "radius"))) return false;
124
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "minimumClusterSize"))) return false;
125
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "maxZoom"))) return false;
126
- if (!JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::canConvert(runtime, obj.getProperty(runtime, "backgroundColor"))) return false;
127
- if (!JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::canConvert(runtime, obj.getProperty(runtime, "textColor"))) return false;
128
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "borderWidth"))) return false;
129
- if (!JSIConverter<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>::canConvert(runtime, obj.getProperty(runtime, "borderColor"))) return false;
130
- if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "animatesClusters"))) return false;
131
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "animationDuration"))) return false;
132
- if (!JSIConverter<margelo::nitro::nitromap::ClusterAnimationStyle>::canConvert(runtime, obj.getProperty(runtime, "animationStyle"))) return false;
133
- if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "realtimeClustering"))) return false;
134
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "renderBuffer"))) return false;
135
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "throttleInterval"))) return false;
123
+ if (!JSIConverter<std::optional<margelo::nitro::nitromap::ClusterStrategy>>::canConvert(runtime, obj.getProperty(runtime, "strategy"))) return false;
124
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "radius"))) return false;
125
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "minimumClusterSize"))) return false;
126
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "maxZoom"))) return false;
127
+ if (!JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::canConvert(runtime, obj.getProperty(runtime, "backgroundColor"))) return false;
128
+ if (!JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::canConvert(runtime, obj.getProperty(runtime, "textColor"))) return false;
129
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "borderWidth"))) return false;
130
+ if (!JSIConverter<std::optional<std::variant<std::string, margelo::nitro::nitromap::MarkerColor>>>::canConvert(runtime, obj.getProperty(runtime, "borderColor"))) return false;
131
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "animatesClusters"))) return false;
132
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "animationDuration"))) return false;
133
+ if (!JSIConverter<std::optional<margelo::nitro::nitromap::ClusterAnimationStyle>>::canConvert(runtime, obj.getProperty(runtime, "animationStyle"))) return false;
134
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "realtimeClustering"))) return false;
135
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "renderBuffer"))) return false;
136
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "throttleInterval"))) return false;
136
137
  return true;
137
138
  }
138
139
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maydon_tech/react-native-nitro-maps",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A high-performance React Native map library powered by Nitro Modules with support for Apple Maps, Google Maps, and Yandex Maps. Features native clustering, custom markers, and seamless cross-platform integration.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -247,6 +247,7 @@ const NitroMapInner = forwardRef<NitroMapRef, NitroMapProps>(
247
247
  const combinedStyle = useMemo(() => [styles.default, style], [style]);
248
248
 
249
249
  // Parse cluster config colors (convert hex strings to MarkerColor objects)
250
+ // and fill in defaults for optional fields
250
251
  const parsedClusterConfig = useMemo(() => {
251
252
  if (!clusterConfig) return undefined;
252
253
 
@@ -255,12 +256,23 @@ const NitroMapInner = forwardRef<NitroMapRef, NitroMapProps>(
255
256
  const defaultBorderColor: MarkerColor = Colors.white;
256
257
 
257
258
  return {
258
- ...clusterConfig,
259
+ enabled: clusterConfig.enabled,
260
+ strategy: clusterConfig.strategy ?? 'supercluster',
261
+ radius: clusterConfig.radius ?? 80,
262
+ minimumClusterSize: clusterConfig.minimumClusterSize ?? 2,
263
+ maxZoom: clusterConfig.maxZoom ?? 20,
259
264
  backgroundColor:
260
265
  parseColor(clusterConfig.backgroundColor) ?? defaultColor,
261
266
  textColor: parseColor(clusterConfig.textColor) ?? defaultTextColor,
267
+ borderWidth: clusterConfig.borderWidth ?? 2,
262
268
  borderColor:
263
269
  parseColor(clusterConfig.borderColor) ?? defaultBorderColor,
270
+ animatesClusters: clusterConfig.animatesClusters ?? true,
271
+ animationDuration: clusterConfig.animationDuration ?? 0.3,
272
+ animationStyle: clusterConfig.animationStyle ?? 'default',
273
+ realtimeClustering: clusterConfig.realtimeClustering ?? false,
274
+ renderBuffer: clusterConfig.renderBuffer ?? 0,
275
+ throttleInterval: clusterConfig.throttleInterval ?? 150,
264
276
  };
265
277
  }, [clusterConfig]);
266
278
 
@@ -217,51 +217,51 @@ export type ClusterConfig = {
217
217
  * - `'hideOnOverlap'` — lower-priority overlapping icons hidden
218
218
  * @default 'supercluster'
219
219
  */
220
- strategy: ClusterStrategy;
220
+ strategy?: ClusterStrategy;
221
221
  /**
222
222
  * Clustering radius in pixels.
223
223
  * Controls how aggressively markers group together.
224
224
  * Higher = fewer, larger clusters. Lower = more, smaller clusters.
225
225
  * @default 80
226
226
  */
227
- radius: number;
228
- /** Minimum number of markers to form a cluster */
229
- minimumClusterSize: number;
230
- /** Maximum zoom level at which clustering occurs */
231
- maxZoom: number;
227
+ radius?: number;
228
+ /** Minimum number of markers to form a cluster @default 2 */
229
+ minimumClusterSize?: number;
230
+ /** Maximum zoom level at which clustering occurs @default 20 */
231
+ maxZoom?: number;
232
232
  /** Background color of cluster circles (hex string or MarkerColor) */
233
- backgroundColor: ColorValue;
233
+ backgroundColor?: ColorValue;
234
234
  /** Text color for cluster count numbers (hex string or MarkerColor) */
235
- textColor: ColorValue;
236
- /** Border thickness in pixels */
237
- borderWidth: number;
235
+ textColor?: ColorValue;
236
+ /** Border thickness in pixels @default 2 */
237
+ borderWidth?: number;
238
238
  /** Border color of cluster circles (hex string or MarkerColor) */
239
- borderColor: ColorValue;
240
- /** Enable cluster animations */
241
- animatesClusters: boolean;
242
- /** Animation duration in seconds (e.g., 0.3) */
243
- animationDuration: number;
244
- /** Animation style for cluster expand/collapse */
245
- animationStyle: ClusterAnimationStyle;
239
+ borderColor?: ColorValue;
240
+ /** Enable cluster animations @default true */
241
+ animatesClusters?: boolean;
242
+ /** Animation duration in seconds (e.g., 0.3) @default 0.3 */
243
+ animationDuration?: number;
244
+ /** Animation style for cluster expand/collapse @default 'default' */
245
+ animationStyle?: ClusterAnimationStyle;
246
246
  /**
247
247
  * When true, clusters update live during pan/zoom gestures (throttled).
248
248
  * When false, clusters only update after the gesture ends (debounced).
249
249
  * Live mode provides smoother UX but uses more CPU.
250
250
  * @default false
251
251
  */
252
- realtimeClustering: boolean;
252
+ realtimeClustering?: boolean;
253
253
  /**
254
254
  * Extra buffer around the visible viewport for pre-computing clusters.
255
255
  * Expressed as a fraction of the viewport size (0 = no buffer, 0.5 = 50% extra on each side).
256
256
  * Prevents markers from "popping in" at edges during pan.
257
257
  * @default 0
258
258
  */
259
- renderBuffer: number;
259
+ renderBuffer?: number;
260
260
  /**
261
261
  * Throttle interval in milliseconds for live clustering during gestures.
262
262
  * Only used when `realtimeClustering` is true.
263
263
  * Higher = better performance, lower = smoother updates.
264
264
  * @default 150
265
265
  */
266
- throttleInterval: number;
266
+ throttleInterval?: number;
267
267
  };