@lugg/maps 0.2.0-alpha.4 → 0.2.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.
@@ -1,7 +1,6 @@
1
1
  package com.luggmaps
2
2
 
3
3
  import android.annotation.SuppressLint
4
- import android.util.Log
5
4
  import android.view.View
6
5
  import android.view.ViewGroup
7
6
  import com.facebook.react.uimanager.PixelUtil.dpToPx
@@ -103,7 +102,6 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
103
102
  override fun removeViewAt(index: Int) {
104
103
  val view = getChildAt(index)
105
104
  if (view is LuggMarkerView) {
106
- Log.d(TAG, "removing markerView: ${view.name}")
107
105
  view.marker?.remove()
108
106
  view.marker = null
109
107
  } else if (view is LuggPolylineView) {
@@ -123,7 +121,6 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
123
121
  }
124
122
 
125
123
  fun onDropViewInstance() {
126
- Log.d(TAG, "dropping mapView instance")
127
124
  pendingMarkerViews.clear()
128
125
  pendingPolylineViews.clear()
129
126
  polylineAnimators.values.forEach { it.destroy() }
@@ -282,6 +279,7 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
282
279
  title = markerView.title
283
280
  snippet = markerView.description
284
281
  setAnchor(markerView.anchorX, markerView.anchorY)
282
+ zIndex = markerView.zIndex
285
283
  if (!markerView.hasCustomView) {
286
284
  iconView = null
287
285
  }
@@ -291,7 +289,6 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
291
289
  private fun processPendingMarkers() {
292
290
  if (googleMap == null) return
293
291
 
294
- Log.d(TAG, "processing pending markers ${pendingMarkerViews.size}")
295
292
  pendingMarkerViews.forEach { addMarkerViewToMap(it) }
296
293
  pendingMarkerViews.clear()
297
294
  }
@@ -312,13 +309,13 @@ class LuggGoogleMapView(private val reactContext: ThemedReactContext) :
312
309
  .title(markerView.title)
313
310
  .snippet(markerView.description)
314
311
 
315
- Log.d(TAG, "adding marker: ${markerView.name} customview: ${markerView.hasCustomView}")
316
312
  if (markerView.hasCustomView) {
317
313
  options.iconView(iconView)
318
314
  }
319
315
 
320
316
  val marker = map.addMarker(options) as AdvancedMarker
321
317
  marker.setAnchor(markerView.anchorX, markerView.anchorY)
318
+ marker.zIndex = markerView.zIndex
322
319
 
323
320
  markerView.marker = marker
324
321
  }
@@ -1,7 +1,6 @@
1
1
  package com.luggmaps
2
2
 
3
3
  import android.content.Context
4
- import android.util.Log
5
4
  import android.view.View
6
5
  import androidx.core.view.isNotEmpty
7
6
  import com.facebook.react.views.view.ReactViewGroup
@@ -34,6 +33,9 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
34
33
  var anchorY: Float = 1.0f
35
34
  private set
36
35
 
36
+ var zIndex: Float = 0f
37
+ private set
38
+
37
39
  var didLayout: Boolean = false
38
40
  private set
39
41
 
@@ -114,6 +116,10 @@ class LuggMarkerView(context: Context) : ReactViewGroup(context) {
114
116
  anchorY = y.toFloat()
115
117
  }
116
118
 
119
+ fun setZIndex(zIndex: Float) {
120
+ this.zIndex = zIndex
121
+ }
122
+
117
123
  fun setName(name: String?) {
118
124
  this.name = name
119
125
  }
@@ -63,6 +63,12 @@ class LuggMarkerViewManager :
63
63
  }
64
64
  }
65
65
 
66
+ @ReactProp(name = "zIndex", defaultFloat = 0f)
67
+ override fun setZIndex(view: LuggMarkerView, zIndex: Float) {
68
+ super.setZIndex(view, zIndex)
69
+ view.setZIndex(zIndex)
70
+ }
71
+
66
72
  companion object {
67
73
  const val NAME = "LuggMarkerView"
68
74
  }
@@ -14,6 +14,12 @@ import kotlin.math.min
14
14
  class PolylineAnimator {
15
15
  var polyline: Polyline? = null
16
16
  var coordinates: List<LatLng> = emptyList()
17
+ set(value) {
18
+ field = value
19
+ if (animated && animator != null) {
20
+ computeCumulativeDistances()
21
+ }
22
+ }
17
23
  var strokeColors: List<Int> = listOf(Color.BLACK)
18
24
  var strokeWidth: Float = 1f
19
25
 
@@ -316,6 +316,9 @@ using namespace luggmaps::events;
316
316
  // Build new polyline from coordinates
317
317
  NSArray<CLLocation *> *coordinates = polylineView.coordinates;
318
318
  if (coordinates.count == 0) {
319
+ if (renderer) {
320
+ renderer.animated = NO;
321
+ }
319
322
  if (oldPolyline) {
320
323
  [_mapView removeOverlay:oldPolyline];
321
324
  polylineView.polyline = nil;
@@ -337,6 +340,8 @@ using namespace luggmaps::events;
337
340
 
338
341
  // If we have an existing renderer, update it in place
339
342
  if (renderer && oldPolyline) {
343
+ [_mapView removeOverlay:oldPolyline];
344
+ [_mapView addOverlay:newPolyline];
340
345
  [renderer updatePolyline:newPolyline];
341
346
  renderer.lineWidth = polylineView.strokeWidth;
342
347
  renderer.strokeColor = polylineView.strokeColors.firstObject;
@@ -388,6 +393,12 @@ using namespace luggmaps::events;
388
393
  annotation.title = markerView.title;
389
394
  annotation.subtitle = markerView.markerDescription;
390
395
 
396
+ MKAnnotationView *annotationView = annotation.annotationView;
397
+ if (annotationView) {
398
+ annotationView.layer.zPosition = markerView.zIndex;
399
+ annotationView.zPriority = markerView.zIndex;
400
+ }
401
+
391
402
  [self updateAnnotationViewFrame:annotation];
392
403
  }
393
404
 
@@ -442,6 +453,8 @@ using namespace luggmaps::events;
442
453
  reuseIdentifier:nil];
443
454
  annotationView.canShowCallout = YES;
444
455
  annotationView.displayPriority = MKFeatureDisplayPriorityRequired;
456
+ annotationView.layer.zPosition = markerView.zIndex;
457
+ annotationView.zPriority = markerView.zIndex;
445
458
 
446
459
  UIView *iconView = markerView.iconView;
447
460
  [iconView removeFromSuperview];
@@ -242,14 +242,15 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
242
242
  marker.position = markerView.coordinate;
243
243
  marker.title = markerView.title;
244
244
  marker.snippet = markerView.markerDescription;
245
- marker.groundAnchor = markerView.anchor;
246
-
245
+ marker.zIndex = (int)markerView.zIndex;
247
246
  if (markerView.hasCustomView) {
248
247
  UIView *iconView = markerView.iconView;
249
248
  [iconView removeFromSuperview];
250
249
  marker.iconView = iconView;
250
+ marker.groundAnchor = markerView.anchor;
251
251
  } else {
252
252
  marker.iconView = nil;
253
+ marker.groundAnchor = CGPointMake(0.5, 1);
253
254
  }
254
255
  }
255
256
 
@@ -280,9 +281,10 @@ static NSString *const kDemoMapId = @"DEMO_MAP_ID";
280
281
 
281
282
  if (markerView.hasCustomView) {
282
283
  marker.iconView = iconView;
284
+ marker.groundAnchor = markerView.anchor;
283
285
  }
284
286
 
285
- marker.groundAnchor = markerView.anchor;
287
+ marker.zIndex = (int)markerView.zIndex;
286
288
  marker.map = _mapView;
287
289
 
288
290
  markerView.marker = marker;
@@ -14,10 +14,12 @@ NS_ASSUME_NONNULL_BEGIN
14
14
 
15
15
  @interface LuggMarkerView : RCTViewComponentView
16
16
 
17
+ @property(nonatomic, readonly, nullable) NSString *name;
17
18
  @property(nonatomic, readonly) CLLocationCoordinate2D coordinate;
18
19
  @property(nonatomic, readonly, nullable) NSString *title;
19
20
  @property(nonatomic, readonly, nullable) NSString *markerDescription;
20
21
  @property(nonatomic, readonly) CGPoint anchor;
22
+ @property(nonatomic, readonly) NSInteger zIndex;
21
23
  @property(nonatomic, readonly) BOOL hasCustomView;
22
24
  @property(nonatomic, readonly) BOOL didLayout;
23
25
  @property(nonatomic, readonly) UIView *iconView;
@@ -13,10 +13,12 @@ using namespace facebook::react;
13
13
  @end
14
14
 
15
15
  @implementation LuggMarkerView {
16
+ NSString *_name;
16
17
  CLLocationCoordinate2D _coordinate;
17
18
  NSString *_title;
18
19
  NSString *_markerDescription;
19
20
  CGPoint _anchor;
21
+ NSInteger _zIndex;
20
22
  BOOL _didLayout;
21
23
  UIView *_iconView;
22
24
  }
@@ -34,6 +36,7 @@ using namespace facebook::react;
34
36
 
35
37
  _coordinate = CLLocationCoordinate2DMake(0, 0);
36
38
  _anchor = CGPointMake(0.5, 1.0);
39
+ _zIndex = 0;
37
40
  _didLayout = NO;
38
41
 
39
42
  _iconView = [[UIView alloc] init];
@@ -52,12 +55,14 @@ using namespace facebook::react;
52
55
  const auto &newViewProps =
53
56
  *std::static_pointer_cast<LuggMarkerViewProps const>(props);
54
57
 
58
+ _name = [NSString stringWithUTF8String:newViewProps.name.c_str()];
55
59
  _coordinate = CLLocationCoordinate2DMake(newViewProps.coordinate.latitude,
56
60
  newViewProps.coordinate.longitude);
57
61
  _title = [NSString stringWithUTF8String:newViewProps.title.c_str()];
58
62
  _markerDescription =
59
63
  [NSString stringWithUTF8String:newViewProps.description.c_str()];
60
64
  _anchor = CGPointMake(newViewProps.anchor.x, newViewProps.anchor.y);
65
+ _zIndex = newViewProps.zIndex.value_or(0);
61
66
  }
62
67
 
63
68
  - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
@@ -109,6 +114,10 @@ using namespace facebook::react;
109
114
  }
110
115
  }
111
116
 
117
+ - (NSString *)name {
118
+ return _name;
119
+ }
120
+
112
121
  - (CLLocationCoordinate2D)coordinate {
113
122
  return _coordinate;
114
123
  }
@@ -125,6 +134,10 @@ using namespace facebook::react;
125
134
  return _anchor;
126
135
  }
127
136
 
137
+ - (NSInteger)zIndex {
138
+ return _zIndex;
139
+ }
140
+
128
141
  - (BOOL)hasCustomView {
129
142
  return _iconView.subviews.count > 0;
130
143
  }
@@ -12,6 +12,13 @@
12
12
  [self stopAnimation];
13
13
  }
14
14
 
15
+ - (void)setCoordinates:(NSArray<CLLocation *> *)coordinates {
16
+ [super setCoordinates:coordinates];
17
+ if (_animated && _displayLink) {
18
+ [self computeCumulativeDistances];
19
+ }
20
+ }
21
+
15
22
  - (void)setAnimated:(BOOL)animated {
16
23
  if (_animated == animated) {
17
24
  return;
@@ -93,6 +93,9 @@
93
93
  _polyline = polyline;
94
94
  [self invalidatePath];
95
95
  [self createPath];
96
+ if (_animated) {
97
+ [self computeCumulativeDistances];
98
+ }
96
99
  [self setNeedsDisplay];
97
100
  }
98
101
 
@@ -12,10 +12,13 @@ export class Marker extends React.Component {
12
12
  title,
13
13
  description,
14
14
  anchor,
15
+ zIndex,
15
16
  children
16
17
  } = this.props;
17
18
  return /*#__PURE__*/_jsx(LuggMarkerViewNativeComponent, {
18
- style: styles.marker,
19
+ style: [{
20
+ zIndex
21
+ }, styles.marker],
19
22
  name: name,
20
23
  coordinate: coordinate,
21
24
  title: title,
@@ -1 +1 @@
1
- {"version":3,"names":["React","StyleSheet","LuggMarkerViewNativeComponent","jsx","_jsx","Marker","Component","render","name","coordinate","title","description","anchor","children","props","style","styles","marker","create","position","pointerEvents"],"sourceRoot":"../../../src","sources":["components/Marker.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,UAAU,QAAQ,cAAc;AACzC,OAAOC,6BAA6B,MAAM,yCAAyC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA8BpF,OAAO,MAAMC,MAAM,SAASL,KAAK,CAACM,SAAS,CAAc;EACvDC,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC,IAAI;MAAEC,UAAU;MAAEC,KAAK;MAAEC,WAAW;MAAEC,MAAM;MAAEC;IAAS,CAAC,GAC9D,IAAI,CAACC,KAAK;IAEZ,oBACEV,IAAA,CAACF,6BAA6B;MAC5Ba,KAAK,EAAEC,MAAM,CAACC,MAAO;MACrBT,IAAI,EAAEA,IAAK;MACXC,UAAU,EAAEA,UAAW;MACvBC,KAAK,EAAEA,KAAM;MACbC,WAAW,EAAEA,WAAY;MACzBC,MAAM,EAAEA,MAAO;MAAAC,QAAA,EAEdA;IAAQ,CACoB,CAAC;EAEpC;AACF;AAEA,MAAMG,MAAM,GAAGf,UAAU,CAACiB,MAAM,CAAC;EAC/BD,MAAM,EAAE;IACNE,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","StyleSheet","LuggMarkerViewNativeComponent","jsx","_jsx","Marker","Component","render","name","coordinate","title","description","anchor","zIndex","children","props","style","styles","marker","create","position","pointerEvents"],"sourceRoot":"../../../src","sources":["components/Marker.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,UAAU,QAAQ,cAAc;AACzC,OAAOC,6BAA6B,MAAM,yCAAyC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAkCpF,OAAO,MAAMC,MAAM,SAASL,KAAK,CAACM,SAAS,CAAc;EACvDC,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC,IAAI;MAAEC,UAAU;MAAEC,KAAK;MAAEC,WAAW;MAAEC,MAAM;MAAEC,MAAM;MAAEC;IAAS,CAAC,GACtE,IAAI,CAACC,KAAK;IAEZ,oBACEX,IAAA,CAACF,6BAA6B;MAC5Bc,KAAK,EAAE,CAAC;QAAEH;MAAO,CAAC,EAAEI,MAAM,CAACC,MAAM,CAAE;MACnCV,IAAI,EAAEA,IAAK;MACXC,UAAU,EAAEA,UAAW;MACvBC,KAAK,EAAEA,KAAM;MACbC,WAAW,EAAEA,WAAY;MACzBC,MAAM,EAAEA,MAAO;MAAAE,QAAA,EAEdA;IAAQ,CACoB,CAAC;EAEpC;AACF;AAEA,MAAMG,MAAM,GAAGhB,UAAU,CAACkB,MAAM,CAAC;EAC/BD,MAAM,EAAE;IACNE,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -22,6 +22,10 @@ export interface MarkerProps {
22
22
  * Anchor point for custom marker views
23
23
  */
24
24
  anchor?: Point;
25
+ /**
26
+ * Z-index for marker ordering. Higher values render on top.
27
+ */
28
+ zIndex?: number;
25
29
  /**
26
30
  * Custom marker view
27
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IACtD,MAAM;CAiBP"}
1
+ {"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IACtD,MAAM;CAiBP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lugg/maps",
3
- "version": "0.2.0-alpha.4",
3
+ "version": "0.2.0-alpha.6",
4
4
  "description": "Universal maps for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -25,6 +25,10 @@ export interface MarkerProps {
25
25
  * Anchor point for custom marker views
26
26
  */
27
27
  anchor?: Point;
28
+ /**
29
+ * Z-index for marker ordering. Higher values render on top.
30
+ */
31
+ zIndex?: number;
28
32
  /**
29
33
  * Custom marker view
30
34
  */
@@ -33,12 +37,12 @@ export interface MarkerProps {
33
37
 
34
38
  export class Marker extends React.Component<MarkerProps> {
35
39
  render() {
36
- const { name, coordinate, title, description, anchor, children } =
40
+ const { name, coordinate, title, description, anchor, zIndex, children } =
37
41
  this.props;
38
42
 
39
43
  return (
40
44
  <LuggMarkerViewNativeComponent
41
- style={styles.marker}
45
+ style={[{ zIndex }, styles.marker]}
42
46
  name={name}
43
47
  coordinate={coordinate}
44
48
  title={title}