@lugg/maps 1.0.0-beta.15 → 1.0.0-beta.17
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/ios/core/GMSPolylineAnimator.m +40 -15
- package/package.json +6 -4
|
@@ -148,13 +148,25 @@ static const NSUInteger kMaxGradientSpans = 512;
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
GMSMutablePath *path = [GMSMutablePath path];
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
CLLocationCoordinate2D lastCoord = self.coordinates.firstObject.coordinate;
|
|
152
|
+
[path addCoordinate:lastCoord];
|
|
153
|
+
for (NSUInteger i = 1; i < self.coordinates.count; i++) {
|
|
154
|
+
CLLocationCoordinate2D coord = self.coordinates[i].coordinate;
|
|
155
|
+
if (coord.latitude == lastCoord.latitude && coord.longitude == lastCoord.longitude) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
[path addCoordinate:coord];
|
|
159
|
+
lastCoord = coord;
|
|
153
160
|
}
|
|
161
|
+
|
|
162
|
+
// Clear stale spans before swapping the path so Google Maps never rebuilds
|
|
163
|
+
// span models against a path with fewer segments (GMSModelStyleBuilder
|
|
164
|
+
// couldNotInstantiate -> EXC_BAD_ACCESS). Reassign spans once the new path is set.
|
|
165
|
+
_polyline.spans = nil;
|
|
154
166
|
_polyline.path = path;
|
|
155
167
|
|
|
156
|
-
if (self.strokeColors.count > 1) {
|
|
157
|
-
_polyline.spans = [self
|
|
168
|
+
if (path.count > 1 && self.strokeColors.count > 1) {
|
|
169
|
+
_polyline.spans = [self createGradientSpansForSegmentCount:path.count - 1];
|
|
158
170
|
} else {
|
|
159
171
|
_polyline.strokeColor = self.strokeColors.firstObject ?: [UIColor blackColor];
|
|
160
172
|
}
|
|
@@ -222,35 +234,44 @@ static const NSUInteger kMaxGradientSpans = 512;
|
|
|
222
234
|
}
|
|
223
235
|
|
|
224
236
|
if (headDist <= tailDist) {
|
|
237
|
+
_polyline.spans = nil;
|
|
225
238
|
_polyline.path = [GMSMutablePath path];
|
|
226
239
|
return;
|
|
227
240
|
}
|
|
228
241
|
|
|
229
|
-
CGFloat visibleLength = headDist - tailDist;
|
|
230
242
|
NSUInteger startIndex = [self indexForDistance:tailDist];
|
|
231
243
|
NSUInteger endIndex = [self indexForDistance:headDist];
|
|
232
244
|
|
|
233
245
|
GMSMutablePath *path = [GMSMutablePath path];
|
|
234
|
-
NSMutableArray<GMSStyleSpan *> *spans = [NSMutableArray array];
|
|
235
246
|
|
|
236
|
-
CLLocationCoordinate2D
|
|
237
|
-
[path addCoordinate:
|
|
247
|
+
CLLocationCoordinate2D lastCoord = [self coordinateAtDistance:tailDist];
|
|
248
|
+
[path addCoordinate:lastCoord];
|
|
238
249
|
|
|
239
250
|
for (NSUInteger i = startIndex + 1; i <= endIndex; i++) {
|
|
240
|
-
|
|
251
|
+
CLLocationCoordinate2D coord = self.coordinates[i].coordinate;
|
|
252
|
+
if (coord.latitude == lastCoord.latitude && coord.longitude == lastCoord.longitude) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
[path addCoordinate:coord];
|
|
256
|
+
lastCoord = coord;
|
|
241
257
|
}
|
|
242
258
|
|
|
243
259
|
CLLocationCoordinate2D endCoord = [self coordinateAtDistance:headDist];
|
|
244
|
-
|
|
245
|
-
(endIndex < self.coordinates.count) ? self.coordinates[endIndex].coordinate : endCoord;
|
|
246
|
-
if (endCoord.latitude != lastAdded.latitude || endCoord.longitude != lastAdded.longitude) {
|
|
260
|
+
if (endCoord.latitude != lastCoord.latitude || endCoord.longitude != lastCoord.longitude) {
|
|
247
261
|
[path addCoordinate:endCoord];
|
|
248
262
|
}
|
|
249
263
|
|
|
250
264
|
NSUInteger pathCount = path.count;
|
|
251
|
-
NSUInteger segmentCount = pathCount - 1;
|
|
265
|
+
NSUInteger segmentCount = (pathCount > 1) ? pathCount - 1 : 0;
|
|
266
|
+
|
|
267
|
+
if (segmentCount == 0) {
|
|
268
|
+
_polyline.spans = nil;
|
|
269
|
+
_polyline.path = path;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
252
272
|
|
|
253
273
|
if (self.strokeColors.count <= 1) {
|
|
274
|
+
_polyline.spans = nil;
|
|
254
275
|
_polyline.path = path;
|
|
255
276
|
_polyline.strokeColor = self.strokeColors.firstObject ?: [UIColor blackColor];
|
|
256
277
|
return;
|
|
@@ -259,6 +280,7 @@ static const NSUInteger kMaxGradientSpans = 512;
|
|
|
259
280
|
NSUInteger spanCount = MIN(segmentCount, kMaxAnimationSpans);
|
|
260
281
|
double segmentsPerSpan = (double)segmentCount / spanCount;
|
|
261
282
|
|
|
283
|
+
NSMutableArray<GMSStyleSpan *> *spans = [NSMutableArray array];
|
|
262
284
|
for (NSUInteger i = 0; i < spanCount; i++) {
|
|
263
285
|
CGFloat gradientPos = ((CGFloat)i + 0.5) / spanCount;
|
|
264
286
|
UIColor *color = [self colorAtGradientPosition:gradientPos];
|
|
@@ -266,13 +288,16 @@ static const NSUInteger kMaxGradientSpans = 512;
|
|
|
266
288
|
[spans addObject:[GMSStyleSpan spanWithStyle:style segments:segmentsPerSpan]];
|
|
267
289
|
}
|
|
268
290
|
|
|
291
|
+
// Clear stale spans before swapping the path so Google Maps never rebuilds
|
|
292
|
+
// span models against a path with fewer segments (GMSModelStyleBuilder
|
|
293
|
+
// couldNotInstantiate -> EXC_BAD_ACCESS). Reassign spans once the new path is set.
|
|
294
|
+
_polyline.spans = nil;
|
|
269
295
|
_polyline.path = path;
|
|
270
296
|
_polyline.spans = spans;
|
|
271
297
|
}
|
|
272
298
|
|
|
273
|
-
- (NSArray<GMSStyleSpan *> *)
|
|
299
|
+
- (NSArray<GMSStyleSpan *> *)createGradientSpansForSegmentCount:(NSUInteger)segmentCount {
|
|
274
300
|
NSMutableArray<GMSStyleSpan *> *spans = [NSMutableArray array];
|
|
275
|
-
NSUInteger segmentCount = self.coordinates.count - 1;
|
|
276
301
|
NSUInteger spanCount = MIN(segmentCount, kMaxGradientSpans);
|
|
277
302
|
double segmentsPerSpan = (double)segmentCount / spanCount;
|
|
278
303
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lugg/maps",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
4
4
|
"description": "Universal maps for React Native.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"@eslint/compat": "^1.3.2",
|
|
76
76
|
"@eslint/eslintrc": "^3.3.1",
|
|
77
77
|
"@eslint/js": "^9.35.0",
|
|
78
|
+
"@expo/config-plugins": "^56.0.8",
|
|
78
79
|
"@react-native/babel-preset": "0.85.3",
|
|
79
80
|
"@react-native/eslint-config": "0.85.3",
|
|
80
81
|
"@react-native/jest-preset": "0.85.3",
|
|
@@ -102,17 +103,18 @@
|
|
|
102
103
|
},
|
|
103
104
|
"peerDependencies": {
|
|
104
105
|
"@vis.gl/react-google-maps": ">=1.0.0",
|
|
106
|
+
"expo": "*",
|
|
105
107
|
"react": "*",
|
|
106
108
|
"react-native": "*"
|
|
107
109
|
},
|
|
108
110
|
"peerDependenciesMeta": {
|
|
109
111
|
"@vis.gl/react-google-maps": {
|
|
110
112
|
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"expo": {
|
|
115
|
+
"optional": true
|
|
111
116
|
}
|
|
112
117
|
},
|
|
113
|
-
"dependencies": {
|
|
114
|
-
"@expo/config-plugins": "^56.0.8"
|
|
115
|
-
},
|
|
116
118
|
"workspaces": [
|
|
117
119
|
"example/bare",
|
|
118
120
|
"example/expo",
|