react-native-google-maps-plus 1.3.0-dev.6 → 1.3.0-dev.8
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.
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +31 -8
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +69 -18
- package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +53 -14
- package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +44 -11
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +4 -4
- package/ios/MapCircleBuilder.swift +29 -9
- package/ios/MapMarkerBuilder.swift +60 -18
- package/ios/MapPolygonBuilder.swift +50 -16
- package/ios/MapPolylineBuilder.swift +31 -15
- package/ios/RNGoogleMapsPlusView.swift +3 -3
- package/package.json +1 -1
|
@@ -20,15 +20,38 @@ class MapCircleBuilder {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
fun update(
|
|
23
|
-
|
|
23
|
+
prev: RNCircle,
|
|
24
24
|
next: RNCircle,
|
|
25
|
+
circle: Circle,
|
|
25
26
|
) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
if (prev.center.latitude != next.center.latitude ||
|
|
28
|
+
prev.center.longitude != next.center.longitude
|
|
29
|
+
) {
|
|
30
|
+
circle.center = next.center.toLatLng()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (prev.radius != next.radius) {
|
|
34
|
+
circle.radius = next.radius
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (prev.strokeWidth != next.strokeWidth) {
|
|
38
|
+
circle.strokeWidth = next.strokeWidth?.dpToPx() ?: 1f
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (prev.strokeColor != next.strokeColor) {
|
|
42
|
+
circle.strokeColor = next.strokeColor?.toColor() ?: Color.BLACK
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (prev.fillColor != next.fillColor) {
|
|
46
|
+
circle.fillColor = next.fillColor?.toColor() ?: Color.TRANSPARENT
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (prev.pressable != next.pressable) {
|
|
50
|
+
circle.isClickable = next.pressable ?: false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (prev.zIndex != next.zIndex) {
|
|
54
|
+
circle.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
55
|
+
}
|
|
33
56
|
}
|
|
34
57
|
}
|
|
@@ -54,33 +54,84 @@ class MapMarkerBuilder(
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
fun update(
|
|
57
|
-
marker: Marker,
|
|
58
57
|
prev: RNMarker,
|
|
59
58
|
next: RNMarker,
|
|
59
|
+
marker: Marker,
|
|
60
60
|
) {
|
|
61
|
-
|
|
62
|
-
next.coordinate.
|
|
61
|
+
if (prev.coordinate.latitude != next.coordinate.latitude ||
|
|
62
|
+
prev.coordinate.longitude != next.coordinate.longitude
|
|
63
|
+
) {
|
|
64
|
+
marker.position = next.coordinate.toLatLng()
|
|
65
|
+
}
|
|
63
66
|
|
|
64
67
|
if (!prev.markerStyleEquals(next)) {
|
|
65
68
|
buildIconAsync(marker.id, next) { icon ->
|
|
66
69
|
marker.setIcon(icon)
|
|
70
|
+
if (prev.infoWindowAnchor?.x != next.infoWindowAnchor?.x ||
|
|
71
|
+
prev.infoWindowAnchor?.y != next.infoWindowAnchor?.y
|
|
72
|
+
) {
|
|
73
|
+
marker.setInfoWindowAnchor(
|
|
74
|
+
(next.infoWindowAnchor?.x ?: 0.5f).toFloat(),
|
|
75
|
+
(next.infoWindowAnchor?.y ?: 0f).toFloat(),
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (prev.anchor?.x != next.anchor?.x ||
|
|
80
|
+
prev.anchor?.y != next.anchor?.y
|
|
81
|
+
) {
|
|
82
|
+
marker.setAnchor(
|
|
83
|
+
(next.anchor?.x ?: 0.5f).toFloat(),
|
|
84
|
+
(next.anchor?.y ?: 1.0f).toFloat(),
|
|
85
|
+
)
|
|
86
|
+
}
|
|
67
87
|
}
|
|
88
|
+
} else {
|
|
89
|
+
if (prev.infoWindowAnchor?.x != next.infoWindowAnchor?.x ||
|
|
90
|
+
prev.infoWindowAnchor?.y != next.infoWindowAnchor?.y
|
|
91
|
+
) {
|
|
92
|
+
marker.setInfoWindowAnchor(
|
|
93
|
+
(next.infoWindowAnchor?.x ?: 0.5f).toFloat(),
|
|
94
|
+
(next.infoWindowAnchor?.y ?: 0f).toFloat(),
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (prev.anchor?.x != next.anchor?.x ||
|
|
99
|
+
prev.anchor?.y != next.anchor?.y
|
|
100
|
+
) {
|
|
101
|
+
marker.setAnchor(
|
|
102
|
+
(next.anchor?.x ?: 0.5f).toFloat(),
|
|
103
|
+
(next.anchor?.y ?: 1.0f).toFloat(),
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (prev.title != next.title) {
|
|
109
|
+
marker.title = next.title
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (prev.snippet != next.snippet) {
|
|
113
|
+
marker.snippet = next.snippet
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (prev.opacity != next.opacity) {
|
|
117
|
+
marker.alpha = next.opacity?.toFloat() ?: 1f
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (prev.flat != next.flat) {
|
|
121
|
+
marker.isFlat = next.flat ?: false
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (prev.draggable != next.draggable) {
|
|
125
|
+
marker.isDraggable = next.draggable ?: false
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (prev.rotation != next.rotation) {
|
|
129
|
+
marker.rotation = next.rotation?.toFloat() ?: 0f
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (prev.zIndex != next.zIndex) {
|
|
133
|
+
marker.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
68
134
|
}
|
|
69
|
-
marker.title = next.title
|
|
70
|
-
marker.snippet = next.snippet
|
|
71
|
-
marker.alpha = next.opacity?.toFloat() ?: 1f
|
|
72
|
-
marker.isFlat = next.flat ?: false
|
|
73
|
-
marker.isDraggable = next.draggable ?: false
|
|
74
|
-
marker.rotation = next.rotation?.toFloat() ?: 0f
|
|
75
|
-
marker.setInfoWindowAnchor(
|
|
76
|
-
(next.infoWindowAnchor?.x ?: 0.5).toFloat(),
|
|
77
|
-
(next.infoWindowAnchor?.y ?: 0).toFloat(),
|
|
78
|
-
)
|
|
79
|
-
marker.setAnchor(
|
|
80
|
-
(next.anchor?.x ?: 0.5).toFloat(),
|
|
81
|
-
(next.anchor?.y ?: 1.0).toFloat(),
|
|
82
|
-
)
|
|
83
|
-
marker.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
84
135
|
}
|
|
85
136
|
|
|
86
137
|
fun buildIconAsync(
|
|
@@ -27,21 +27,60 @@ class MapPolygonBuilder {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
fun update(
|
|
30
|
-
|
|
30
|
+
prev: RNPolygon,
|
|
31
31
|
next: RNPolygon,
|
|
32
|
+
poly: Polygon,
|
|
32
33
|
) {
|
|
33
|
-
|
|
34
|
-
next.coordinates.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
val coordsChanged =
|
|
35
|
+
prev.coordinates.size != next.coordinates.size ||
|
|
36
|
+
!prev.coordinates.zip(next.coordinates).all { (a, b) ->
|
|
37
|
+
a.latitude == b.latitude && a.longitude == b.longitude
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (coordsChanged) {
|
|
41
|
+
poly.points = next.coordinates.map { it.toLatLng() }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
val prevHoles = prev.holes?.toList() ?: emptyList()
|
|
45
|
+
val nextHoles = next.holes?.toList() ?: emptyList()
|
|
46
|
+
val holesChanged =
|
|
47
|
+
prevHoles.size != nextHoles.size ||
|
|
48
|
+
!prevHoles.zip(nextHoles).all { (ha, hb) ->
|
|
49
|
+
ha.coordinates.size == hb.coordinates.size &&
|
|
50
|
+
ha.coordinates.zip(hb.coordinates).all { (a, b) ->
|
|
51
|
+
a.latitude == b.latitude && a.longitude == b.longitude
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (holesChanged) {
|
|
56
|
+
poly.holes =
|
|
57
|
+
nextHoles.map { hole ->
|
|
58
|
+
hole.coordinates.map { it.toLatLng() }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (prev.fillColor != next.fillColor) {
|
|
63
|
+
poly.fillColor = next.fillColor?.toColor() ?: Color.TRANSPARENT
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (prev.strokeColor != next.strokeColor) {
|
|
67
|
+
poly.strokeColor = next.strokeColor?.toColor() ?: Color.BLACK
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (prev.strokeWidth != next.strokeWidth) {
|
|
71
|
+
poly.strokeWidth = next.strokeWidth?.dpToPx() ?: 1f
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (prev.pressable != next.pressable) {
|
|
75
|
+
poly.isClickable = next.pressable ?: false
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (prev.geodesic != next.geodesic) {
|
|
79
|
+
poly.isGeodesic = next.geodesic ?: false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (prev.zIndex != next.zIndex) {
|
|
83
|
+
poly.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
84
|
+
}
|
|
46
85
|
}
|
|
47
86
|
}
|
|
@@ -31,19 +31,52 @@ class MapPolylineBuilder {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
fun update(
|
|
34
|
-
|
|
34
|
+
prev: RNPolyline,
|
|
35
35
|
next: RNPolyline,
|
|
36
|
+
polyline: Polyline,
|
|
36
37
|
) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
val coordsChanged =
|
|
39
|
+
prev.coordinates.size != next.coordinates.size ||
|
|
40
|
+
!prev.coordinates.zip(next.coordinates).all { (a, b) ->
|
|
41
|
+
a.latitude == b.latitude && a.longitude == b.longitude
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (coordsChanged) {
|
|
45
|
+
polyline.points = next.coordinates.map { it.toLatLng() }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (prev.width != next.width) {
|
|
49
|
+
polyline.width = next.width?.dpToPx() ?: 1f
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
val newCap = mapLineCap(next.lineCap ?: RNLineCapType.BUTT)
|
|
53
|
+
val prevCap = mapLineCap(prev.lineCap ?: RNLineCapType.BUTT)
|
|
54
|
+
if (newCap != prevCap) {
|
|
55
|
+
polyline.startCap = newCap
|
|
56
|
+
polyline.endCap = newCap
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
val newJoin = mapLineJoin(next.lineJoin ?: RNLineJoinType.MITER)
|
|
60
|
+
val prevJoin = mapLineJoin(prev.lineJoin ?: RNLineJoinType.MITER)
|
|
61
|
+
if (newJoin != prevJoin) {
|
|
62
|
+
polyline.jointType = newJoin
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (prev.color != next.color) {
|
|
66
|
+
polyline.color = next.color?.toColor() ?: Color.BLACK
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (prev.pressable != next.pressable) {
|
|
70
|
+
polyline.isClickable = next.pressable ?: false
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (prev.geodesic != next.geodesic) {
|
|
74
|
+
polyline.isGeodesic = next.geodesic ?: false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (prev.zIndex != next.zIndex) {
|
|
78
|
+
polyline.zIndex = next.zIndex?.toFloat() ?: 0f
|
|
79
|
+
}
|
|
47
80
|
}
|
|
48
81
|
|
|
49
82
|
private fun mapLineCap(type: RNLineCapType?): Cap =
|
|
@@ -157,7 +157,7 @@ class RNGoogleMapsPlusView(
|
|
|
157
157
|
} else if (!prev.markerEquals(next)) {
|
|
158
158
|
view.updateMarker(id) { marker ->
|
|
159
159
|
onUi {
|
|
160
|
-
markerBuilder.update(
|
|
160
|
+
markerBuilder.update(prev, next, marker)
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -181,7 +181,7 @@ class RNGoogleMapsPlusView(
|
|
|
181
181
|
} else if (!prev.polylineEquals(next)) {
|
|
182
182
|
view.updatePolyline(id) { polyline ->
|
|
183
183
|
onUi {
|
|
184
|
-
polylineBuilder.update(
|
|
184
|
+
polylineBuilder.update(prev, next, polyline)
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -205,7 +205,7 @@ class RNGoogleMapsPlusView(
|
|
|
205
205
|
view.addPolygon(id, polygonBuilder.build(next))
|
|
206
206
|
} else if (!prev.polygonEquals(next)) {
|
|
207
207
|
view.updatePolygon(id) { polygon ->
|
|
208
|
-
onUi { polygonBuilder.update(
|
|
208
|
+
onUi { polygonBuilder.update(prev, next, polygon) }
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -229,7 +229,7 @@ class RNGoogleMapsPlusView(
|
|
|
229
229
|
} else if (!prev.circleEquals(next)) {
|
|
230
230
|
view.updateCircle(id) { circle ->
|
|
231
231
|
onUi {
|
|
232
|
-
circleBuilder.update(
|
|
232
|
+
circleBuilder.update(prev, next, circle)
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -14,14 +14,34 @@ final class MapCircleBuilder {
|
|
|
14
14
|
return circle
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
func update(_ next: RNCircle, _ c: GMSCircle) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
func update(_ prev: RNCircle, _ next: RNCircle, _ c: GMSCircle) {
|
|
18
|
+
if prev.center.latitude != next.center.latitude
|
|
19
|
+
|| prev.center.longitude != next.center.longitude {
|
|
20
|
+
c.position = next.center.toCLLocationCoordinate2D()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if prev.radius != next.radius {
|
|
24
|
+
c.radius = next.radius ?? 0
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if prev.fillColor != next.fillColor {
|
|
28
|
+
c.fillColor = next.fillColor?.toUIColor() ?? .clear
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if prev.strokeColor != next.strokeColor {
|
|
32
|
+
c.strokeColor = next.strokeColor?.toUIColor() ?? .black
|
|
33
|
+
}
|
|
26
34
|
|
|
35
|
+
if prev.strokeWidth != next.strokeWidth {
|
|
36
|
+
c.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if prev.pressable != next.pressable {
|
|
40
|
+
c.isTappable = next.pressable ?? false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if prev.zIndex != next.zIndex {
|
|
44
|
+
c.zIndex = Int32(next.zIndex ?? 0)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
27
47
|
}
|
|
@@ -44,31 +44,58 @@ final class MapMarkerBuilder {
|
|
|
44
44
|
|
|
45
45
|
@MainActor
|
|
46
46
|
func update(_ prev: RNMarker, _ next: RNMarker, _ m: GMSMarker) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
if prev.coordinate.latitude != next.coordinate.latitude
|
|
48
|
+
|| prev.coordinate.longitude != next.coordinate.longitude {
|
|
49
|
+
m.position = next.coordinate.toCLLocationCoordinate2D()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if prev.title != next.title {
|
|
53
|
+
m.title = next.title
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if prev.snippet != next.snippet {
|
|
57
|
+
m.snippet = next.snippet
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if prev.opacity != next.opacity {
|
|
61
|
+
let opacity = Float(next.opacity ?? 1)
|
|
62
|
+
m.opacity = opacity
|
|
63
|
+
m.iconView?.alpha = CGFloat(opacity)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if prev.flat != next.flat {
|
|
67
|
+
m.isFlat = next.flat ?? false
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if prev.draggable != next.draggable {
|
|
71
|
+
m.isDraggable = next.draggable ?? false
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if prev.rotation != next.rotation {
|
|
75
|
+
m.rotation = next.rotation ?? 0
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if prev.zIndex != next.zIndex {
|
|
79
|
+
m.zIndex = Int32(next.zIndex ?? 0)
|
|
80
|
+
}
|
|
81
|
+
|
|
63
82
|
if !prev.markerStyleEquals(next) {
|
|
64
83
|
buildIconAsync(next.id, next) { img in
|
|
65
84
|
m.tracksViewChanges = true
|
|
66
85
|
m.icon = img
|
|
67
86
|
|
|
68
|
-
if prev.anchor?.x != next.anchor?.x || prev.anchor?.y != next.anchor?.y
|
|
87
|
+
if prev.anchor?.x != next.anchor?.x || prev.anchor?.y != next.anchor?.y{
|
|
69
88
|
m.groundAnchor = CGPoint(
|
|
70
89
|
x: next.anchor?.x ?? 0.5,
|
|
71
|
-
y: next.anchor?.y ??
|
|
90
|
+
y: next.anchor?.y ?? 1
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if prev.infoWindowAnchor?.x != next.infoWindowAnchor?.x
|
|
95
|
+
|| prev.infoWindowAnchor?.y != next.infoWindowAnchor?.y {
|
|
96
|
+
m.infoWindowAnchor = CGPoint(
|
|
97
|
+
x: next.infoWindowAnchor?.x ?? 0.5,
|
|
98
|
+
y: next.infoWindowAnchor?.y ?? 0
|
|
72
99
|
)
|
|
73
100
|
}
|
|
74
101
|
|
|
@@ -76,6 +103,21 @@ final class MapMarkerBuilder {
|
|
|
76
103
|
m?.tracksViewChanges = false
|
|
77
104
|
}
|
|
78
105
|
}
|
|
106
|
+
} else {
|
|
107
|
+
if prev.anchor?.x != next.anchor?.x || prev.anchor?.y != next.anchor?.y{
|
|
108
|
+
m.groundAnchor = CGPoint(
|
|
109
|
+
x: next.anchor?.x ?? 0.5,
|
|
110
|
+
y: next.anchor?.y ?? 1
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if prev.infoWindowAnchor?.x != next.infoWindowAnchor?.x
|
|
115
|
+
|| prev.infoWindowAnchor?.y != next.infoWindowAnchor?.y {
|
|
116
|
+
m.infoWindowAnchor = CGPoint(
|
|
117
|
+
x: next.infoWindowAnchor?.x ?? 0.5,
|
|
118
|
+
y: next.infoWindowAnchor?.y ?? 0
|
|
119
|
+
)
|
|
120
|
+
}
|
|
79
121
|
}
|
|
80
122
|
}
|
|
81
123
|
|
|
@@ -28,26 +28,60 @@ final class MapPolygonBuilder {
|
|
|
28
28
|
return pg
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
func update(_ next: RNPolygon, _ pg: GMSPolygon) {
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
func update(_ prev: RNPolygon, _ next: RNPolygon, _ pg: GMSPolygon) {
|
|
32
|
+
let coordsChanged =
|
|
33
|
+
prev.coordinates.count != next.coordinates.count
|
|
34
|
+
|| !zip(prev.coordinates, next.coordinates).allSatisfy {
|
|
35
|
+
$0.latitude == $1.latitude && $0.longitude == $1.longitude
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if coordsChanged {
|
|
39
|
+
let path = GMSMutablePath()
|
|
40
|
+
next.coordinates.forEach { path.add($0.toCLLocationCoordinate2D()) }
|
|
41
|
+
pg.path = path
|
|
37
42
|
}
|
|
38
|
-
pg.path = path
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
let prevHoles = prev.holes ?? []
|
|
45
|
+
let nextHoles = next.holes ?? []
|
|
46
|
+
let holesChanged =
|
|
47
|
+
prevHoles.count != nextHoles.count
|
|
48
|
+
|| !zip(prevHoles, nextHoles).allSatisfy { a, b in
|
|
49
|
+
a.coordinates.count == b.coordinates.count
|
|
50
|
+
&& zip(a.coordinates, b.coordinates).allSatisfy {
|
|
51
|
+
$0.latitude == $1.latitude && $0.longitude == $1.longitude
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if holesChanged {
|
|
56
|
+
pg.holes = nextHoles.map { hole in
|
|
47
57
|
let path = GMSMutablePath()
|
|
48
58
|
hole.coordinates.forEach { path.add($0.toCLLocationCoordinate2D()) }
|
|
49
59
|
return path
|
|
50
|
-
}
|
|
51
|
-
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if prev.fillColor != next.fillColor {
|
|
64
|
+
pg.fillColor = next.fillColor?.toUIColor() ?? .clear
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if prev.strokeColor != next.strokeColor {
|
|
68
|
+
pg.strokeColor = next.strokeColor?.toUIColor() ?? .black
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if prev.strokeWidth != next.strokeWidth {
|
|
72
|
+
pg.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if prev.pressable != next.pressable {
|
|
76
|
+
pg.isTappable = next.pressable ?? false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if prev.geodesic != next.geodesic {
|
|
80
|
+
pg.geodesic = next.geodesic ?? false
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if prev.zIndex != next.zIndex {
|
|
84
|
+
pg.zIndex = Int32(next.zIndex ?? 0)
|
|
85
|
+
}
|
|
52
86
|
}
|
|
53
87
|
}
|
|
@@ -22,21 +22,37 @@ final class MapPolylineBuilder {
|
|
|
22
22
|
return pl
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
func update(_ next: RNPolyline, _ pl: GMSPolyline) {
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
func update(_ prev: RNPolyline, _ next: RNPolyline, _ pl: GMSPolyline) {
|
|
26
|
+
let coordsChanged =
|
|
27
|
+
prev.coordinates.count != next.coordinates.count
|
|
28
|
+
|| !zip(prev.coordinates, next.coordinates).allSatisfy {
|
|
29
|
+
$0.latitude == $1.latitude && $0.longitude == $1.longitude
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if coordsChanged {
|
|
33
|
+
let path = GMSMutablePath()
|
|
34
|
+
next.coordinates.forEach { path.add($0.toCLLocationCoordinate2D()) }
|
|
35
|
+
pl.path = path
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if prev.width != next.width {
|
|
39
|
+
pl.strokeWidth = CGFloat(next.width ?? 1.0)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if prev.color != next.color {
|
|
43
|
+
pl.strokeColor = next.color?.toUIColor() ?? .black
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if prev.pressable != next.pressable {
|
|
47
|
+
pl.isTappable = next.pressable ?? false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if prev.geodesic != next.geodesic {
|
|
51
|
+
pl.geodesic = next.geodesic ?? false
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if prev.zIndex != next.zIndex {
|
|
55
|
+
pl.zIndex = Int32(next.zIndex ?? 0)
|
|
31
56
|
}
|
|
32
|
-
pl.path = path
|
|
33
|
-
|
|
34
|
-
/* lineCap not supported */
|
|
35
|
-
/* lineJoin not supported */
|
|
36
|
-
pl.strokeWidth = CGFloat(next.width ?? 1.0)
|
|
37
|
-
pl.strokeColor = next.color?.toUIColor() ?? .black
|
|
38
|
-
pl.isTappable = next.pressable ?? false
|
|
39
|
-
pl.geodesic = next.geodesic ?? false
|
|
40
|
-
pl.zIndex = Int32(next.zIndex ?? 0)
|
|
41
57
|
}
|
|
42
58
|
}
|
|
@@ -169,7 +169,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
169
169
|
if let prev = prevById[id] {
|
|
170
170
|
if !prev.polylineEquals(next) {
|
|
171
171
|
impl.updatePolyline(id: id) { pl in
|
|
172
|
-
self.polylineBuilder.update(next, pl)
|
|
172
|
+
self.polylineBuilder.update(prev, next, pl)
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
} else {
|
|
@@ -201,7 +201,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
201
201
|
if let prev = prevById[id] {
|
|
202
202
|
if !prev.polygonEquals(next) {
|
|
203
203
|
impl.updatePolygon(id: id) { pg in
|
|
204
|
-
self.polygonBuilder.update(next, pg)
|
|
204
|
+
self.polygonBuilder.update(prev, next, pg)
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
} else {
|
|
@@ -230,7 +230,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
|
|
|
230
230
|
if let prev = prevById[id] {
|
|
231
231
|
if !prev.circleEquals(next) {
|
|
232
232
|
impl.updateCircle(id: id) { circle in
|
|
233
|
-
self.circleBuilder.update(next, circle)
|
|
233
|
+
self.circleBuilder.update(prev, next, circle)
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
} else {
|
package/package.json
CHANGED