@mapsindoors/react-native-maps-indoors-mapbox 2.8.0 → 2.9.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 (45) hide show
  1. package/README.md +84 -1
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsPackage.java +10 -0
  4. package/android/src/main/java/com/mapsindoorsrn/core/BaseMapCacheProviders.java +94 -0
  5. package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +140 -49
  6. package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +16 -7
  7. package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +1 -1
  8. package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +115 -20
  9. package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +200 -11
  10. package/android/src/main/java/com/mapsindoorsrn/core/RnGson.java +110 -0
  11. package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +1 -1
  12. package/android/src/main/java/com/mapsindoorsrn/core/models/DirectionsRendererOptionsModel.java +498 -0
  13. package/index.ts +25 -0
  14. package/ios/.swift-format +79 -0
  15. package/ios/core/DirectionsRendererBridge.m +11 -0
  16. package/ios/core/DirectionsRendererModule.swift +162 -1
  17. package/ios/core/DirectionsRendererOptions.swift +352 -0
  18. package/ios/core/MapsIndoorsBridge.m +14 -1
  19. package/ios/core/MapsIndoorsData.swift +1 -0
  20. package/ios/core/MapsIndoorsModule.swift +180 -21
  21. package/ios/core/UtilsModule.swift +57 -45
  22. package/package.json +1 -1
  23. package/react-native-maps-indoors-mapbox.podspec +2 -2
  24. package/specs/NativeDirectionsRendererModule.ts +3 -0
  25. package/specs/NativeMapsIndoorsModule.ts +6 -1
  26. package/src/core/EventNames.ts +3 -0
  27. package/src/core/MPDirectionsRenderer.ts +76 -1
  28. package/src/core/MPDirectionsRendererOptions.ts +287 -0
  29. package/src/core/MPError.ts +48 -1
  30. package/src/core/MPLanguageTag.ts +222 -0
  31. package/src/core/MPLegBoundaryIcons.ts +130 -0
  32. package/src/core/MPRouteAnimationType.ts +24 -0
  33. package/src/core/MPRouteArrowStyle.ts +28 -0
  34. package/src/core/MPRouteMarkerDisplayRule.ts +140 -0
  35. package/src/core/MPRouteStampType.ts +24 -0
  36. package/src/core/MPSolution.ts +33 -2
  37. package/src/core/MPStrokeStyle.ts +22 -0
  38. package/src/core/MapsIndoors.ts +155 -11
  39. package/src/core/OnBaseMapCacheProgressListener.ts +20 -0
  40. package/src/core/__tests__/MPBounds.test.ts +109 -0
  41. package/src/core/__tests__/MPFilter.test.ts +76 -0
  42. package/src/core/__tests__/MPLanguageTag.test.ts +168 -0
  43. package/src/core/__tests__/MPPoint.test.ts +82 -0
  44. package/src/core/__tests__/MPSolution.test.ts +107 -0
  45. package/src/core/__tests__/MapsIndoors.language.test.ts +180 -0
@@ -0,0 +1,498 @@
1
+ package com.mapsindoorsrn.core.models;
2
+
3
+ import android.graphics.Color;
4
+
5
+ import androidx.annotation.NonNull;
6
+ import androidx.annotation.Nullable;
7
+
8
+ import com.google.gson.annotations.SerializedName;
9
+ import com.mapsindoors.core.MPDirectionsRendererConfig;
10
+ import com.mapsindoors.core.MPDirectionsRendererOptions;
11
+ import com.mapsindoors.core.MPRouteAnimationType;
12
+ import com.mapsindoors.core.MPRouteArrowStyle;
13
+ import com.mapsindoors.core.MPRouteStampType;
14
+ import com.mapsindoors.core.MPStrokeStyle;
15
+
16
+ /**
17
+ * The flat directions renderer options as they cross the React Native bridge.
18
+ *
19
+ * The Android SDK splits the same surface in two: the polyline styling and animation timing live on
20
+ * {@link MPDirectionsRendererOptions}, everything else on {@link MPDirectionsRendererConfig}. Every
21
+ * field here is nullable, so an option the app left out is inherited instead of reset - from the
22
+ * previously applied options, or from the solution config.
23
+ */
24
+ public class DirectionsRendererOptionsModel {
25
+ /**
26
+ * The stamp type value used for a custom icon. The Android SDK has no preset for it, a custom
27
+ * stamp is expressed by {@link MPDirectionsRendererConfig.Stamp#iconUrl} alone.
28
+ */
29
+ private static final String STAMP_TYPE_CUSTOM = "custom";
30
+
31
+ @Nullable @SerializedName("strokeColor") public String strokeColor;
32
+ @Nullable @SerializedName("strokeOpacity") public Float strokeOpacity;
33
+ @Nullable @SerializedName("strokeWeight") public Float strokeWeight;
34
+ @Nullable @SerializedName("strokeStyle") public MPStrokeStyle strokeStyle;
35
+ @Nullable @SerializedName("backgroundColorEnabled") public Boolean backgroundColorEnabled;
36
+ @Nullable @SerializedName("backgroundColor") public String backgroundColor;
37
+ @Nullable @SerializedName("backgroundColorOpacity") public Double backgroundColorOpacity;
38
+ @Nullable @SerializedName("backgroundColorWeight") public Double backgroundColorWeight;
39
+ @Nullable @SerializedName("animationType") public MPRouteAnimationType animationType;
40
+ @Nullable @SerializedName("animationSpeed") public Double animationSpeed;
41
+ @Nullable @SerializedName("animationMinDuration") public Double animationMinDuration;
42
+ @Nullable @SerializedName("animationRepeating") public Boolean animationRepeating;
43
+ @Nullable @SerializedName("forceAnimation") public Boolean forceAnimation;
44
+ @Nullable @SerializedName("animatedOverlayColor") public String animatedOverlayColor;
45
+ @Nullable @SerializedName("animatedOverlayOpacity") public Float animatedOverlayOpacity;
46
+ @Nullable @SerializedName("animatedOverlayWeight") public Float animatedOverlayWeight;
47
+ @Nullable @SerializedName("stampType") public String stampType;
48
+ @Nullable @SerializedName("stampImageUrl") public String stampImageUrl;
49
+ @Nullable @SerializedName("stampSpacing") public Double stampSpacing;
50
+ @Nullable @SerializedName("stampScale") public Double stampScale;
51
+ @Nullable @SerializedName("arrowStyle") public MPRouteArrowStyle arrowStyle;
52
+ @Nullable @SerializedName("stampColor") public String stampColor;
53
+ @Nullable @SerializedName("startDisplayRule") public RouteMarkerDisplayRule startDisplayRule;
54
+ @Nullable @SerializedName("endDisplayRule") public RouteMarkerDisplayRule endDisplayRule;
55
+ @Nullable @SerializedName("legBoundaryIcons") public LegBoundaryIcons legBoundaryIcons;
56
+ @Nullable @SerializedName("elevated") public Boolean elevated;
57
+ @Nullable @SerializedName("elevationHeight") public Double elevationHeight;
58
+ @Nullable @SerializedName("fitBoundsMaxZoom") public Double fitBoundsMaxZoom;
59
+
60
+ /**
61
+ * The subset of a route terminus display rule that the Android SDK renders.
62
+ *
63
+ * The bridge keeps the label style flat, the way the iOS SDK exposes it, so it is nested back
64
+ * into {@link MPDirectionsRendererConfig.TerminiLabelStyle} here.
65
+ */
66
+ public static class RouteMarkerDisplayRule {
67
+ @Nullable @SerializedName("iconUrl") public String iconUrl;
68
+ @Nullable @SerializedName("iconVisible") public Boolean iconVisible;
69
+ @Nullable @SerializedName("iconSize") public IconSize iconSize;
70
+ @Nullable @SerializedName("label") public String label;
71
+ @Nullable @SerializedName("labelVisible") public Boolean labelVisible;
72
+ @Nullable @SerializedName("labelTextSize") public Double labelTextSize;
73
+ @Nullable @SerializedName("labelTextColor") public String labelTextColor;
74
+ @Nullable @SerializedName("labelHaloColor") public String labelHaloColor;
75
+ @Nullable @SerializedName("labelHaloWidth") public Double labelHaloWidth;
76
+ @Nullable @SerializedName("zoomFrom") public Double zoomFrom;
77
+ @Nullable @SerializedName("zoomTo") public Double zoomTo;
78
+
79
+ MPDirectionsRendererConfig.TerminiDisplayRule toTerminiDisplayRule() {
80
+ MPDirectionsRendererConfig.TerminiLabelStyle labelStyle = null;
81
+ if (labelTextSize != null || labelTextColor != null || labelHaloColor != null || labelHaloWidth != null) {
82
+ labelStyle = new MPDirectionsRendererConfig.TerminiLabelStyle(
83
+ labelTextSize, labelTextColor, labelHaloColor, labelHaloWidth);
84
+ }
85
+ return new MPDirectionsRendererConfig.TerminiDisplayRule(
86
+ iconUrl,
87
+ iconSize != null ? iconSize.toIconSize() : null,
88
+ iconVisible,
89
+ label,
90
+ labelVisible,
91
+ labelStyle,
92
+ zoomFrom,
93
+ zoomTo);
94
+ }
95
+
96
+ @Nullable
97
+ static RouteMarkerDisplayRule fromTerminiDisplayRule(@Nullable MPDirectionsRendererConfig.TerminiDisplayRule rule) {
98
+ if (rule == null) {
99
+ return null;
100
+ }
101
+ RouteMarkerDisplayRule model = new RouteMarkerDisplayRule();
102
+ model.iconUrl = rule.getIcon();
103
+ model.iconVisible = rule.getIconVisible();
104
+ model.iconSize = IconSize.fromIconSize(rule.getIconSize());
105
+ model.label = rule.getLabel();
106
+ model.labelVisible = rule.getLabelVisible();
107
+ MPDirectionsRendererConfig.TerminiLabelStyle style = rule.getLabelStyle();
108
+ if (style != null) {
109
+ model.labelTextSize = style.getTextSize();
110
+ model.labelTextColor = style.getTextColor();
111
+ model.labelHaloColor = style.getHaloColor();
112
+ model.labelHaloWidth = style.getHaloWidth();
113
+ }
114
+ model.zoomFrom = rule.getZoomFrom();
115
+ model.zoomTo = rule.getZoomTo();
116
+ return model;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Explicit icon dimensions in pixels.
122
+ */
123
+ public static class IconSize {
124
+ @Nullable @SerializedName("width") public Double width;
125
+ @Nullable @SerializedName("height") public Double height;
126
+
127
+ MPDirectionsRendererConfig.IconSize toIconSize() {
128
+ return new MPDirectionsRendererConfig.IconSize(width, height);
129
+ }
130
+
131
+ @Nullable
132
+ static IconSize fromIconSize(@Nullable MPDirectionsRendererConfig.IconSize size) {
133
+ if (size == null) {
134
+ return null;
135
+ }
136
+ IconSize model = new IconSize();
137
+ model.width = size.getWidth();
138
+ model.height = size.getHeight();
139
+ return model;
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Per connector type leg boundary icons.
145
+ *
146
+ * The bridge uses camel cased connector names, the Android SDK's wire keys are lower cased.
147
+ */
148
+ public static class LegBoundaryIcons {
149
+ @Nullable @SerializedName("defaultIcon") public String defaultIcon;
150
+ @Nullable @SerializedName("elevator") public String elevator;
151
+ @Nullable @SerializedName("escalator") public String escalator;
152
+ @Nullable @SerializedName("stairs") public String stairs;
153
+ @Nullable @SerializedName("ramp") public String ramp;
154
+ @Nullable @SerializedName("wheelchairRamp") public String wheelchairRamp;
155
+ @Nullable @SerializedName("wheelchairLift") public String wheelchairLift;
156
+ @Nullable @SerializedName("ladder") public String ladder;
157
+ @Nullable @SerializedName("entry") public String entry;
158
+ @Nullable @SerializedName("scale") public Double scale;
159
+
160
+ MPDirectionsRendererConfig.LegBoundaryIcons toLegBoundaryIcons() {
161
+ return new MPDirectionsRendererConfig.LegBoundaryIcons(
162
+ defaultIcon, elevator, escalator, stairs, ramp,
163
+ wheelchairRamp, wheelchairLift, ladder, entry, scale);
164
+ }
165
+
166
+ @Nullable
167
+ static LegBoundaryIcons fromLegBoundaryIcons(@Nullable MPDirectionsRendererConfig.LegBoundaryIcons icons) {
168
+ if (icons == null) {
169
+ return null;
170
+ }
171
+ LegBoundaryIcons model = new LegBoundaryIcons();
172
+ model.defaultIcon = icons.getDefaultIcon();
173
+ model.elevator = icons.getElevator();
174
+ model.escalator = icons.getEscalator();
175
+ model.stairs = icons.getStairs();
176
+ model.ramp = icons.getRamp();
177
+ model.wheelchairRamp = icons.getWheelchairramp();
178
+ model.wheelchairLift = icons.getWheelchairlift();
179
+ model.ladder = icons.getLadder();
180
+ model.entry = icons.getEntry();
181
+ model.scale = icons.getScale();
182
+ return model;
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Builds the polyline styling and animation timing the Android SDK takes as options.
188
+ *
189
+ * A set of options is declarative, so an option left out here falls back to the SDK's built-in
190
+ * default rather than to whatever was applied before.
191
+ */
192
+ @NonNull
193
+ public MPDirectionsRendererOptions toMPDirectionsRendererOptions() {
194
+ MPDirectionsRendererOptions current = new MPDirectionsRendererOptions();
195
+ Integer overlayColor = animatedOverlayColor != null
196
+ ? Integer.valueOf(Color.parseColor(animatedOverlayColor))
197
+ : current.getAnimatedOverlayColor();
198
+ return new MPDirectionsRendererOptions(
199
+ strokeColor != null ? Color.parseColor(strokeColor) : current.getStrokeColor(),
200
+ strokeOpacity != null ? strokeOpacity : current.getStrokeOpacity(),
201
+ strokeWeight != null ? strokeWeight : current.getStrokeWeight(),
202
+ strokeStyle != null ? strokeStyle : current.getStrokeStyle(),
203
+ animationSpeed != null ? animationSpeed : current.getAnimationSpeed(),
204
+ animationMinDuration != null ? animationMinDuration : current.getAnimationMinDuration(),
205
+ animationRepeating != null ? animationRepeating : current.getAnimationRepeating(),
206
+ overlayColor,
207
+ animatedOverlayOpacity != null ? animatedOverlayOpacity : current.getAnimatedOverlayOpacity(),
208
+ animatedOverlayWeight != null ? animatedOverlayWeight : current.getAnimatedOverlayWeight(),
209
+ fitBoundsMaxZoom != null ? fitBoundsMaxZoom : current.getFitBoundsMaxZoom(),
210
+ forceAnimation != null ? forceAnimation : current.getForceAnimation());
211
+ }
212
+
213
+ /**
214
+ * Builds the route styling the Android SDK takes as a config.
215
+ *
216
+ * The SDK merges a runtime config over the solution config whole-block for everything but the
217
+ * line and the halo, so an app that overrides one field of a block would otherwise drop the rest
218
+ * of the solution's block. Every block is therefore completed field by field from
219
+ * {@code solutionConfig}, which keeps an option that was left out inherited rather than reset -
220
+ * the resolution order the bridge documents on both platforms.
221
+ *
222
+ * A block neither the app nor the solution configured stays null, so the SDK keeps its built-in
223
+ * appearance for it.
224
+ *
225
+ * @param solutionConfig the solution served config, as it was before any runtime override was
226
+ * applied. Pass null when the solution serves none.
227
+ */
228
+ @NonNull
229
+ public MPDirectionsRendererConfig toMPDirectionsRendererConfig(@Nullable MPDirectionsRendererConfig solutionConfig) {
230
+ MPDirectionsRendererConfig.Line baseLine = solutionConfig != null ? solutionConfig.getLine() : null;
231
+ MPDirectionsRendererConfig.Halo baseHalo = solutionConfig != null ? solutionConfig.getHalo() : null;
232
+ MPDirectionsRendererConfig.Animation baseAnimation = solutionConfig != null ? solutionConfig.getAnimation() : null;
233
+ MPDirectionsRendererConfig.Overlay baseOverlay = baseAnimation != null ? baseAnimation.getOverlay() : null;
234
+ MPDirectionsRendererConfig.Stamp baseStamp = solutionConfig != null ? solutionConfig.getStamp() : null;
235
+ MPDirectionsRendererConfig.Camera baseCamera = solutionConfig != null ? solutionConfig.getCamera() : null;
236
+ MPDirectionsRendererConfig.Elevation baseElevation = solutionConfig != null ? solutionConfig.getElevation() : null;
237
+
238
+ MPDirectionsRendererConfig.Line line = null;
239
+ if (strokeColor != null || strokeOpacity != null || strokeWeight != null || strokeStyle != null || baseLine != null) {
240
+ line = new MPDirectionsRendererConfig.Line(
241
+ strokeColor != null ? strokeColor : baseLine != null ? baseLine.getStrokeColor() : null,
242
+ strokeOpacity != null ? strokeOpacity.doubleValue() : baseLine != null ? baseLine.getStrokeOpacity() : null,
243
+ strokeWeight != null ? strokeWeight.doubleValue() : baseLine != null ? baseLine.getStrokeWeight() : null,
244
+ strokeStyle != null ? strokeStyle : baseLine != null ? baseLine.getStrokeStyle() : null);
245
+ }
246
+
247
+ MPDirectionsRendererConfig.Halo halo = null;
248
+ if (backgroundColorEnabled != null || backgroundColor != null
249
+ || backgroundColorOpacity != null || backgroundColorWeight != null || baseHalo != null) {
250
+ halo = new MPDirectionsRendererConfig.Halo(
251
+ backgroundColorEnabled != null ? backgroundColorEnabled : baseHalo != null ? baseHalo.getEnabled() : null,
252
+ backgroundColor != null ? backgroundColor : baseHalo != null ? baseHalo.getColor() : null,
253
+ backgroundColorOpacity != null ? backgroundColorOpacity : baseHalo != null ? baseHalo.getOpacity() : null,
254
+ backgroundColorWeight != null ? backgroundColorWeight : baseHalo != null ? baseHalo.getWeight() : null);
255
+ }
256
+
257
+ MPDirectionsRendererConfig.Overlay overlay = null;
258
+ if (animatedOverlayColor != null || animatedOverlayOpacity != null
259
+ || animatedOverlayWeight != null || baseOverlay != null) {
260
+ overlay = new MPDirectionsRendererConfig.Overlay(
261
+ animatedOverlayColor != null ? animatedOverlayColor : baseOverlay != null ? baseOverlay.getStrokeColor() : null,
262
+ animatedOverlayOpacity != null ? animatedOverlayOpacity.doubleValue() : baseOverlay != null ? baseOverlay.getStrokeOpacity() : null,
263
+ animatedOverlayWeight != null ? animatedOverlayWeight.doubleValue() : baseOverlay != null ? baseOverlay.getStrokeWeight() : null);
264
+ }
265
+
266
+ MPDirectionsRendererConfig.Animation animation = null;
267
+ if (animationType != null || animationSpeed != null || animationMinDuration != null
268
+ || forceAnimation != null || overlay != null || baseAnimation != null) {
269
+ animation = new MPDirectionsRendererConfig.Animation(
270
+ animationType != null ? animationType : baseAnimation != null ? baseAnimation.getType() : null,
271
+ animationSpeed != null ? animationSpeed : baseAnimation != null ? baseAnimation.getSpeed() : null,
272
+ animationMinDuration != null ? animationMinDuration : baseAnimation != null ? baseAnimation.getMinAnimationTime() : null,
273
+ forceAnimation != null ? forceAnimation : baseAnimation != null ? baseAnimation.getForceAnimation() : null,
274
+ overlay);
275
+ }
276
+
277
+ MPDirectionsRendererConfig.Stamp stamp = null;
278
+ if (stampType != null || stampImageUrl != null || stampSpacing != null
279
+ || stampScale != null || arrowStyle != null || stampColor != null || baseStamp != null) {
280
+ stamp = new MPDirectionsRendererConfig.Stamp(
281
+ stampPreset(baseStamp),
282
+ stampImageUrl != null ? stampImageUrl : baseStamp != null ? baseStamp.getIconUrl() : null,
283
+ stampSpacing != null ? stampSpacing : baseStamp != null ? baseStamp.getSpacingPx() : null,
284
+ stampScale != null ? stampScale : baseStamp != null ? baseStamp.getScale() : null,
285
+ arrowStyle != null ? arrowStyle : baseStamp != null ? baseStamp.getArrowStyle() : null,
286
+ stampColor != null ? stampColor : baseStamp != null ? baseStamp.getColor() : null);
287
+ }
288
+
289
+ MPDirectionsRendererConfig.Camera camera = null;
290
+ if (fitBoundsMaxZoom != null || baseCamera != null) {
291
+ camera = new MPDirectionsRendererConfig.Camera(
292
+ fitBoundsMaxZoom != null ? fitBoundsMaxZoom
293
+ : baseCamera != null ? baseCamera.getFitBoundsMaxZoom() : null);
294
+ }
295
+
296
+ MPDirectionsRendererConfig.Elevation elevation = null;
297
+ if (elevated != null || elevationHeight != null || baseElevation != null) {
298
+ elevation = new MPDirectionsRendererConfig.Elevation(
299
+ elevated != null ? elevated : baseElevation != null ? baseElevation.getElevated() : null,
300
+ elevationHeight != null ? elevationHeight : baseElevation != null ? baseElevation.getHeightMeters() : null);
301
+ }
302
+
303
+ return new MPDirectionsRendererConfig(
304
+ line,
305
+ halo,
306
+ animation,
307
+ stamp,
308
+ solutionConfig != null ? solutionConfig.getStopIcons() : null,
309
+ mergedLegBoundaryIcons(solutionConfig),
310
+ mergedTerminiDisplayRule(startDisplayRule, solutionConfig != null ? solutionConfig.getStartDisplayRule() : null),
311
+ mergedTerminiDisplayRule(endDisplayRule, solutionConfig != null ? solutionConfig.getEndDisplayRule() : null),
312
+ camera,
313
+ elevation);
314
+ }
315
+
316
+ @Nullable
317
+ private MPDirectionsRendererConfig.LegBoundaryIcons mergedLegBoundaryIcons(@Nullable MPDirectionsRendererConfig solutionConfig) {
318
+ MPDirectionsRendererConfig.LegBoundaryIcons base = solutionConfig != null ? solutionConfig.getLegBoundaryIcons() : null;
319
+ if (legBoundaryIcons == null) {
320
+ return base;
321
+ }
322
+ MPDirectionsRendererConfig.LegBoundaryIcons icons = legBoundaryIcons.toLegBoundaryIcons();
323
+ if (base == null) {
324
+ return icons;
325
+ }
326
+ return new MPDirectionsRendererConfig.LegBoundaryIcons(
327
+ icons.getDefaultIcon() != null ? icons.getDefaultIcon() : base.getDefaultIcon(),
328
+ icons.getElevator() != null ? icons.getElevator() : base.getElevator(),
329
+ icons.getEscalator() != null ? icons.getEscalator() : base.getEscalator(),
330
+ icons.getStairs() != null ? icons.getStairs() : base.getStairs(),
331
+ icons.getRamp() != null ? icons.getRamp() : base.getRamp(),
332
+ icons.getWheelchairramp() != null ? icons.getWheelchairramp() : base.getWheelchairramp(),
333
+ icons.getWheelchairlift() != null ? icons.getWheelchairlift() : base.getWheelchairlift(),
334
+ icons.getLadder() != null ? icons.getLadder() : base.getLadder(),
335
+ icons.getEntry() != null ? icons.getEntry() : base.getEntry(),
336
+ icons.getScale() != null ? icons.getScale() : base.getScale());
337
+ }
338
+
339
+ @Nullable
340
+ private static MPDirectionsRendererConfig.TerminiDisplayRule mergedTerminiDisplayRule(
341
+ @Nullable RouteMarkerDisplayRule override,
342
+ @Nullable MPDirectionsRendererConfig.TerminiDisplayRule base) {
343
+ if (override == null) {
344
+ return base;
345
+ }
346
+ MPDirectionsRendererConfig.TerminiDisplayRule rule = override.toTerminiDisplayRule();
347
+ if (base == null) {
348
+ return rule;
349
+ }
350
+ MPDirectionsRendererConfig.TerminiLabelStyle baseStyle = base.getLabelStyle();
351
+ MPDirectionsRendererConfig.TerminiLabelStyle style = rule.getLabelStyle();
352
+ MPDirectionsRendererConfig.TerminiLabelStyle mergedStyle = style == null ? baseStyle
353
+ : baseStyle == null ? style
354
+ : new MPDirectionsRendererConfig.TerminiLabelStyle(
355
+ style.getTextSize() != null ? style.getTextSize() : baseStyle.getTextSize(),
356
+ style.getTextColor() != null ? style.getTextColor() : baseStyle.getTextColor(),
357
+ style.getHaloColor() != null ? style.getHaloColor() : baseStyle.getHaloColor(),
358
+ style.getHaloWidth() != null ? style.getHaloWidth() : baseStyle.getHaloWidth());
359
+
360
+ return new MPDirectionsRendererConfig.TerminiDisplayRule(
361
+ rule.getIcon() != null ? rule.getIcon() : base.getIcon(),
362
+ rule.getIconSize() != null ? rule.getIconSize() : base.getIconSize(),
363
+ rule.getIconVisible() != null ? rule.getIconVisible() : base.getIconVisible(),
364
+ rule.getLabel() != null ? rule.getLabel() : base.getLabel(),
365
+ rule.getLabelVisible() != null ? rule.getLabelVisible() : base.getLabelVisible(),
366
+ mergedStyle,
367
+ rule.getZoomFrom() != null ? rule.getZoomFrom() : base.getZoomFrom(),
368
+ rule.getZoomTo() != null ? rule.getZoomTo() : base.getZoomTo());
369
+ }
370
+
371
+ /**
372
+ * Flattens the options and the effective config the renderer currently holds back into the
373
+ * bridge's shape.
374
+ */
375
+ @NonNull
376
+ public static DirectionsRendererOptionsModel from(@Nullable MPDirectionsRendererOptions options,
377
+ @Nullable MPDirectionsRendererConfig config) {
378
+ DirectionsRendererOptionsModel model = new DirectionsRendererOptionsModel();
379
+
380
+ if (options != null) {
381
+ model.strokeColor = colorToHexString(options.getStrokeColor());
382
+ model.strokeOpacity = options.getStrokeOpacity();
383
+ model.strokeWeight = options.getStrokeWeight();
384
+ model.strokeStyle = options.getStrokeStyle();
385
+ model.animationSpeed = options.getAnimationSpeed();
386
+ model.animationMinDuration = options.getAnimationMinDuration();
387
+ model.animationRepeating = options.getAnimationRepeating();
388
+ Integer overlayColor = options.getAnimatedOverlayColor();
389
+ model.animatedOverlayColor = overlayColor != null ? colorToHexString(overlayColor) : null;
390
+ model.animatedOverlayOpacity = options.getAnimatedOverlayOpacity();
391
+ model.animatedOverlayWeight = options.getAnimatedOverlayWeight();
392
+ model.fitBoundsMaxZoom = options.getFitBoundsMaxZoom();
393
+ model.forceAnimation = options.getForceAnimation();
394
+ }
395
+
396
+ if (config == null) {
397
+ return model;
398
+ }
399
+
400
+ MPDirectionsRendererConfig.Line line = config.getLine();
401
+ if (line != null) {
402
+ if (model.strokeColor == null) model.strokeColor = line.getStrokeColor();
403
+ if (model.strokeOpacity == null && line.getStrokeOpacity() != null) model.strokeOpacity = line.getStrokeOpacity().floatValue();
404
+ if (model.strokeWeight == null && line.getStrokeWeight() != null) model.strokeWeight = line.getStrokeWeight().floatValue();
405
+ if (model.strokeStyle == null) model.strokeStyle = line.getStrokeStyle();
406
+ }
407
+
408
+ MPDirectionsRendererConfig.Halo halo = config.getHalo();
409
+ if (halo != null) {
410
+ model.backgroundColorEnabled = halo.getEnabled();
411
+ model.backgroundColor = halo.getColor();
412
+ model.backgroundColorOpacity = halo.getOpacity();
413
+ model.backgroundColorWeight = halo.getWeight();
414
+ }
415
+
416
+ MPDirectionsRendererConfig.Animation animation = config.getAnimation();
417
+ if (animation != null) {
418
+ model.animationType = animation.getType();
419
+ if (model.animationSpeed == null) model.animationSpeed = animation.getSpeed();
420
+ if (model.animationMinDuration == null) model.animationMinDuration = animation.getMinAnimationTime();
421
+ if (model.forceAnimation == null) model.forceAnimation = animation.getForceAnimation();
422
+ MPDirectionsRendererConfig.Overlay overlay = animation.getOverlay();
423
+ if (overlay != null) {
424
+ if (model.animatedOverlayColor == null) model.animatedOverlayColor = overlay.getStrokeColor();
425
+ if (model.animatedOverlayOpacity == null && overlay.getStrokeOpacity() != null) model.animatedOverlayOpacity = overlay.getStrokeOpacity().floatValue();
426
+ if (model.animatedOverlayWeight == null && overlay.getStrokeWeight() != null) model.animatedOverlayWeight = overlay.getStrokeWeight().floatValue();
427
+ }
428
+ }
429
+
430
+ MPDirectionsRendererConfig.Stamp stamp = config.getStamp();
431
+ if (stamp != null) {
432
+ model.stampImageUrl = stamp.getIconUrl();
433
+ model.stampType = model.stampImageUrl != null ? STAMP_TYPE_CUSTOM
434
+ : stamp.getPreset() != null ? stampTypeToString(stamp.getPreset()) : null;
435
+ model.stampSpacing = stamp.getSpacingPx();
436
+ model.stampScale = stamp.getScale();
437
+ model.arrowStyle = stamp.getArrowStyle();
438
+ model.stampColor = stamp.getColor();
439
+ }
440
+
441
+ model.startDisplayRule = RouteMarkerDisplayRule.fromTerminiDisplayRule(config.getStartDisplayRule());
442
+ model.endDisplayRule = RouteMarkerDisplayRule.fromTerminiDisplayRule(config.getEndDisplayRule());
443
+ model.legBoundaryIcons = LegBoundaryIcons.fromLegBoundaryIcons(config.getLegBoundaryIcons());
444
+
445
+ MPDirectionsRendererConfig.Camera camera = config.getCamera();
446
+ if (camera != null && model.fitBoundsMaxZoom == null) {
447
+ model.fitBoundsMaxZoom = camera.getFitBoundsMaxZoom();
448
+ }
449
+
450
+ MPDirectionsRendererConfig.Elevation elevation = config.getElevation();
451
+ if (elevation != null) {
452
+ model.elevated = elevation.getElevated();
453
+ model.elevationHeight = elevation.getHeightMeters();
454
+ }
455
+
456
+ return model;
457
+ }
458
+
459
+ /**
460
+ * Resolves the stamp preset, inheriting from {@code base} where the app expressed no opinion.
461
+ *
462
+ * The Android SDK has no preset for a custom stamp, that case is carried by the icon URL alone,
463
+ * so {@code custom} deliberately resolves to a null preset. An unrecognised value inherits
464
+ * rather than doing the same: it is a typo, not a request for a custom stamp, and treating the
465
+ * two alike would silently drop a preset the solution configured.
466
+ */
467
+ @Nullable
468
+ private MPRouteStampType stampPreset(@Nullable MPDirectionsRendererConfig.Stamp base) {
469
+ if (stampType == null) {
470
+ return base != null ? base.getPreset() : null;
471
+ }
472
+ if ("none".equalsIgnoreCase(stampType)) {
473
+ return MPRouteStampType.NONE;
474
+ }
475
+ if ("arrow".equalsIgnoreCase(stampType)) {
476
+ return MPRouteStampType.ARROW;
477
+ }
478
+ if (STAMP_TYPE_CUSTOM.equalsIgnoreCase(stampType)) {
479
+ return null;
480
+ }
481
+ return base != null ? base.getPreset() : null;
482
+ }
483
+
484
+ @NonNull
485
+ private static String stampTypeToString(@NonNull MPRouteStampType type) {
486
+ return type == MPRouteStampType.NONE ? "none" : "arrow";
487
+ }
488
+
489
+ /**
490
+ * The bridge keeps colors opaque and carries transparency in the separate opacity options, so
491
+ * that a color reads back the same on both platforms - the two SDKs disagree on where the alpha
492
+ * component of an 8 digit hex string sits.
493
+ */
494
+ @NonNull
495
+ private static String colorToHexString(int color) {
496
+ return String.format("#%06X", 0xFFFFFF & color);
497
+ }
498
+ }
package/index.ts CHANGED
@@ -7,6 +7,7 @@ import MPQuery from './src/core/MPQuery';
7
7
  import MPError from './src/core/MPError';
8
8
  import MPFilter from './src/core/MPFilter';
9
9
  import MPBounds from './src/core/MPBounds';
10
+ import { normalizeLanguageTag, resolveLanguageTag } from './src/core/MPLanguageTag';
10
11
  import { MPLocationType } from './src/core/MPLocationType';
11
12
  import { MPLocationPropertyNames } from './src/core/MPLocationPropertyNames';
12
13
  import { MPLabelType } from './src/core/MPLabelType';
@@ -36,8 +37,15 @@ import MPRouteLeg from './src/core/MPRouteLeg';
36
37
  import MPRouteStep from './src/core/MPRouteStep';
37
38
  import MPRouteProperty from './src/core/MPRouteProperty';
38
39
  import MPDirectionsRenderer from './src/core/MPDirectionsRenderer';
40
+ import MPDirectionsRendererOptions from './src/core/MPDirectionsRendererOptions';
41
+ import MPRouteMarkerDisplayRule from './src/core/MPRouteMarkerDisplayRule';
42
+ import MPLegBoundaryIcons from './src/core/MPLegBoundaryIcons';
39
43
  import MPDirectionsService from './src/core/MPDirectionsService';
40
44
  import { MPCameraViewFitMode } from './src/core/MPCameraViewFitMode';
45
+ import { MPStrokeStyle } from './src/core/MPStrokeStyle';
46
+ import { MPRouteAnimationType } from './src/core/MPRouteAnimationType';
47
+ import { MPRouteStampType } from './src/core/MPRouteStampType';
48
+ import { MPRouteArrowStyle } from './src/core/MPRouteArrowStyle';
41
49
  import MPCameraPosition from './src/core/MPCameraPosition';
42
50
  import MPFilterBehavior from './src/core/MPFilterBehavior';
43
51
  import MPHighlightBehavior from './src/core/MPHighlightBehavior';
@@ -60,6 +68,7 @@ import { OnFloorSelectionChangedListener } from './src/core/OnFloorSelectionChan
60
68
  import { OnVenueFoundAtCameraTargetListener } from './src/core/OnVenueFoundAtCameraTargetListener';
61
69
  import { OnBuildingFoundAtCameraTargetListener } from './src/core/OnBuildingFoundAtCameraTargetListener';
62
70
  import { OnLegSelectedListener } from './src/core/OnLegSelectedListener';
71
+ import { OnBaseMapCacheProgressListener } from './src/core/OnBaseMapCacheProgressListener';
63
72
  import MPBuildingCollection from './src/core/MPBuildingCollection';
64
73
  import MPVenueCollection from './src/core/MPVenueCollection';
65
74
  import MPCategoryCollection from './src/core/MPCategoryCollection';
@@ -95,6 +104,9 @@ import { MPRouteCoordinateParams } from './src/core/MPRouteCoordinate';
95
104
  import { MPHighlightBehaviorParams } from './src/core/MPHighlightBehavior';
96
105
  import { RouteStopIconConfig } from './src/core/RouteStopIconConfig';
97
106
  import { MPRouteStopIconConfigParams } from './src/core/MPRouteStopIconConfig';
107
+ import { MPDirectionsRendererOptionsParams } from './src/core/MPDirectionsRendererOptions';
108
+ import { MPRouteMarkerDisplayRuleParams } from './src/core/MPRouteMarkerDisplayRule';
109
+ import { MPLegBoundaryIconsParams } from './src/core/MPLegBoundaryIcons';
98
110
  import { MPPOITypeParams } from './src/core/MPPOIType';
99
111
  import { MPSelectionMode } from './src/core/MPSelectionMode';
100
112
  import { MPFeatureType } from './src/core/MPFeatureTypes';
@@ -138,8 +150,13 @@ export {
138
150
  MPVenue,
139
151
  MPVenueInfo,
140
152
  MPLocationType,
153
+ normalizeLanguageTag,
154
+ resolveLanguageTag,
141
155
  MPLocationPropertyNames,
142
156
  MPDirectionsRenderer,
157
+ MPDirectionsRendererOptions,
158
+ MPRouteMarkerDisplayRule,
159
+ MPLegBoundaryIcons,
143
160
  MPDirectionsService,
144
161
  MPRoute,
145
162
  MPRouteCoordinate,
@@ -147,6 +164,10 @@ export {
147
164
  MPRouteProperty,
148
165
  MPRouteStep,
149
166
  MPCameraViewFitMode,
167
+ MPStrokeStyle,
168
+ MPRouteAnimationType,
169
+ MPRouteStampType,
170
+ MPRouteArrowStyle,
150
171
  MPBuildingCollection,
151
172
  MPVenueCollection,
152
173
  MPCategoryCollection,
@@ -179,6 +200,7 @@ export type {
179
200
  OnMarkerInfoWindowClickListener,
180
201
  OnLiveLocationUpdateListener,
181
202
  OnLegSelectedListener,
203
+ OnBaseMapCacheProgressListener,
182
204
  MPEntity,
183
205
  MPFloorParams,
184
206
  MPQueryParams,
@@ -206,6 +228,9 @@ export type {
206
228
  MPSolutionConfigParams,
207
229
  MPRouteCoordinateParams,
208
230
  MPRouteStopIconConfigParams,
231
+ MPDirectionsRendererOptionsParams,
232
+ MPRouteMarkerDisplayRuleParams,
233
+ MPLegBoundaryIconsParams,
209
234
  RouteStopIconConfig,
210
235
  MPPOITypeParams
211
236
  };
@@ -0,0 +1,79 @@
1
+ {
2
+ "fileScopedDeclarationPrivacy" : {
3
+ "accessLevel" : "private"
4
+ },
5
+ "indentConditionalCompilationBlocks" : true,
6
+ "indentSwitchCaseLabels" : false,
7
+ "indentation" : {
8
+ "spaces" : 4
9
+ },
10
+ "lineBreakAroundMultilineExpressionChainComponents" : false,
11
+ "lineBreakBeforeControlFlowKeywords" : false,
12
+ "lineBreakBeforeEachArgument" : false,
13
+ "lineBreakBeforeEachGenericRequirement" : false,
14
+ "lineBreakBetweenDeclarationAttributes" : false,
15
+ "lineLength" : 1000,
16
+ "maximumBlankLines" : 1,
17
+ "multiElementCollectionTrailingCommas" : true,
18
+ "noAssignmentInExpressions" : {
19
+ "allowedFunctions" : [
20
+ "XCTAssertNoThrow"
21
+ ]
22
+ },
23
+ "prioritizeKeepingFunctionOutputTogether" : false,
24
+ "reflowMultilineStringLiterals" : {
25
+ "never" : {
26
+
27
+ }
28
+ },
29
+ "respectsExistingLineBreaks" : true,
30
+ "rules" : {
31
+ "AllPublicDeclarationsHaveDocumentation" : false,
32
+ "AlwaysUseLiteralForEmptyCollectionInit" : false,
33
+ "AlwaysUseLowerCamelCase" : true,
34
+ "AmbiguousTrailingClosureOverload" : true,
35
+ "AvoidRetroactiveConformances" : true,
36
+ "BeginDocumentationCommentWithOneLineSummary" : false,
37
+ "DoNotUseSemicolons" : true,
38
+ "DontRepeatTypeInStaticProperties" : true,
39
+ "FileScopedDeclarationPrivacy" : true,
40
+ "FullyIndirectEnum" : true,
41
+ "GroupNumericLiterals" : true,
42
+ "IdentifiersMustBeASCII" : true,
43
+ "NeverForceUnwrap" : false,
44
+ "NeverUseForceTry" : false,
45
+ "NeverUseImplicitlyUnwrappedOptionals" : false,
46
+ "NoAccessLevelOnExtensionDeclaration" : true,
47
+ "NoAssignmentInExpressions" : true,
48
+ "NoBlockComments" : true,
49
+ "NoCasesWithOnlyFallthrough" : true,
50
+ "NoEmptyLinesOpeningClosingBraces" : true,
51
+ "NoEmptyTrailingClosureParentheses" : true,
52
+ "NoLabelsInCasePatterns" : true,
53
+ "NoLeadingUnderscores" : false,
54
+ "NoParensAroundConditions" : true,
55
+ "NoPlaygroundLiterals" : true,
56
+ "NoVoidReturnOnFunctionSignature" : true,
57
+ "OmitExplicitReturns" : false,
58
+ "OneCasePerLine" : true,
59
+ "OneVariableDeclarationPerLine" : true,
60
+ "OnlyOneTrailingClosureArgument" : true,
61
+ "OrderedImports" : true,
62
+ "ReplaceForEachWithForLoop" : true,
63
+ "ReturnVoidInsteadOfEmptyTuple" : true,
64
+ "TypeNamesShouldBeCapitalized" : true,
65
+ "UseEarlyExits" : false,
66
+ "UseExplicitNilCheckInConditions" : true,
67
+ "UseLetInEveryBoundCaseVariable" : true,
68
+ "UseShorthandTypeNames" : true,
69
+ "UseSingleLinePropertyGetter" : true,
70
+ "UseSynthesizedInitializer" : true,
71
+ "UseTripleSlashForDocumentationComments" : true,
72
+ "UseWhereClausesInForLoops" : false,
73
+ "ValidateDocumentationComments" : false
74
+ },
75
+ "spacesAroundRangeFormationOperators" : false,
76
+ "spacesBeforeEndOfLineComments" : 2,
77
+ "tabWidth" : 8,
78
+ "version" : 1
79
+ }