react-native-maps 0.31.0-beta.6 → 1.0.0-beta.1
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/README.md +1 -5
- package/android/build.gradle +31 -2
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapCalloutManager.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTile.java +11 -4
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTileManager.java +5 -1
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +4 -43
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapMarker.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapMarkerManager.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapModule.java +1 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapOverlayManager.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapPolygonManager.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapPolylineManager.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +5 -5
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +0 -32
- package/android/src/main/java/com/airbnb/android/react/maps/ImageReader.java +2 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +37 -31
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -95
- package/ios/AirMaps/AIRMap.m +0 -7
- package/ios/AirMaps/AIRMapManager.m +0 -105
- package/lib/AnimatedRegion.d.ts +19 -0
- package/lib/AnimatedRegion.js +134 -0
- package/lib/Geojson.d.ts +166 -0
- package/lib/Geojson.js +165 -0
- package/lib/MapCallout.d.ts +40 -0
- package/lib/MapCallout.js +51 -0
- package/lib/MapCalloutSubview.d.ts +34 -0
- package/lib/MapCalloutSubview.js +48 -0
- package/lib/MapCircle.d.ts +117 -0
- package/lib/MapCircle.js +53 -0
- package/lib/MapHeatmap.d.ts +77 -0
- package/lib/MapHeatmap.js +59 -0
- package/lib/MapLocalTile.d.ts +35 -0
- package/lib/MapLocalTile.js +44 -0
- package/lib/MapMarker.d.ts +289 -0
- package/lib/MapMarker.js +113 -0
- package/lib/MapOverlay.d.ts +86 -0
- package/lib/MapOverlay.js +63 -0
- package/lib/MapPolygon.d.ts +156 -0
- package/lib/MapPolygon.js +74 -0
- package/lib/MapPolyline.d.ts +156 -0
- package/lib/MapPolyline.js +53 -0
- package/lib/MapUrlTile.d.ts +134 -0
- package/lib/MapUrlTile.js +44 -0
- package/lib/MapView.d.ts +825 -0
- package/lib/MapView.js +418 -0
- package/{src/MapView.web.js → lib/MapView.web.d.ts} +0 -0
- package/lib/MapView.web.js +9 -0
- package/lib/MapWMSTile.d.ts +116 -0
- package/lib/MapWMSTile.js +44 -0
- package/lib/ProviderConstants.d.ts +2 -0
- package/lib/ProviderConstants.js +5 -0
- package/lib/decorateMapComponent.d.ts +35 -0
- package/lib/decorateMapComponent.js +80 -0
- package/{src/index.js → lib/index.d.ts} +5 -16
- package/lib/index.js +66 -0
- package/lib/sharedTypes.d.ts +82 -0
- package/lib/sharedTypes.js +2 -0
- package/package.json +18 -27
- package/react-native-google-maps.podspec +1 -1
- package/react-native-maps.podspec +1 -1
- package/index.d.ts +0 -637
- package/src/AnimatedRegion.js +0 -164
- package/src/Geojson.js +0 -334
- package/src/MapCallout.js +0 -51
- package/src/MapCalloutSubview.js +0 -44
- package/src/MapCircle.js +0 -150
- package/src/MapHeatmap.js +0 -99
- package/src/MapLocalTile.js +0 -52
- package/src/MapMarker.js +0 -377
- package/src/MapOverlay.js +0 -86
- package/src/MapPolygon.js +0 -202
- package/src/MapPolyline.js +0 -168
- package/src/MapUrlTile.js +0 -131
- package/src/MapView.js +0 -1160
- package/src/MapWMSTile.js +0 -122
- package/src/ProviderConstants.js +0 -2
- package/src/decorateMapComponent.js +0 -112
|
@@ -163,29 +163,6 @@ RCT_EXPORT_METHOD(animateCamera:(nonnull NSNumber *)reactTag
|
|
|
163
163
|
}];
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
RCT_EXPORT_METHOD(animateToNavigation:(nonnull NSNumber *)reactTag
|
|
167
|
-
withRegion:(MKCoordinateRegion)region
|
|
168
|
-
withBearing:(CGFloat)bearing
|
|
169
|
-
withAngle:(double)angle
|
|
170
|
-
withDuration:(CGFloat)duration)
|
|
171
|
-
{
|
|
172
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
173
|
-
id view = viewRegistry[reactTag];
|
|
174
|
-
if (![view isKindOfClass:[AIRGoogleMap class]]) {
|
|
175
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
|
|
176
|
-
} else {
|
|
177
|
-
[CATransaction begin];
|
|
178
|
-
[CATransaction setAnimationDuration:duration/1000];
|
|
179
|
-
AIRGoogleMap *mapView = (AIRGoogleMap *)view;
|
|
180
|
-
GMSCameraPosition *camera = [AIRGoogleMap makeGMSCameraPositionFromMap:mapView andMKCoordinateRegion:region];
|
|
181
|
-
[mapView animateToCameraPosition:camera];
|
|
182
|
-
[mapView animateToViewingAngle:angle];
|
|
183
|
-
[mapView animateToBearing:bearing];
|
|
184
|
-
[CATransaction commit];
|
|
185
|
-
}
|
|
186
|
-
}];
|
|
187
|
-
}
|
|
188
|
-
|
|
189
166
|
RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
|
|
190
167
|
withRegion:(MKCoordinateRegion)region
|
|
191
168
|
withDuration:(CGFloat)duration)
|
|
@@ -207,59 +184,6 @@ RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
|
|
|
207
184
|
}];
|
|
208
185
|
}
|
|
209
186
|
|
|
210
|
-
RCT_EXPORT_METHOD(animateToCoordinate:(nonnull NSNumber *)reactTag
|
|
211
|
-
withRegion:(CLLocationCoordinate2D)latlng
|
|
212
|
-
withDuration:(CGFloat)duration)
|
|
213
|
-
{
|
|
214
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
215
|
-
id view = viewRegistry[reactTag];
|
|
216
|
-
if (![view isKindOfClass:[AIRGoogleMap class]]) {
|
|
217
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
|
|
218
|
-
} else {
|
|
219
|
-
[CATransaction begin];
|
|
220
|
-
[CATransaction setAnimationDuration:duration/1000];
|
|
221
|
-
[(AIRGoogleMap *)view animateToLocation:latlng];
|
|
222
|
-
[CATransaction commit];
|
|
223
|
-
}
|
|
224
|
-
}];
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
RCT_EXPORT_METHOD(animateToViewingAngle:(nonnull NSNumber *)reactTag
|
|
228
|
-
withAngle:(double)angle
|
|
229
|
-
withDuration:(CGFloat)duration)
|
|
230
|
-
{
|
|
231
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
232
|
-
id view = viewRegistry[reactTag];
|
|
233
|
-
if (![view isKindOfClass:[AIRGoogleMap class]]) {
|
|
234
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
|
|
235
|
-
} else {
|
|
236
|
-
[CATransaction begin];
|
|
237
|
-
[CATransaction setAnimationDuration:duration/1000];
|
|
238
|
-
AIRGoogleMap *mapView = (AIRGoogleMap *)view;
|
|
239
|
-
[mapView animateToViewingAngle:angle];
|
|
240
|
-
[CATransaction commit];
|
|
241
|
-
}
|
|
242
|
-
}];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
RCT_EXPORT_METHOD(animateToBearing:(nonnull NSNumber *)reactTag
|
|
246
|
-
withBearing:(CGFloat)bearing
|
|
247
|
-
withDuration:(CGFloat)duration)
|
|
248
|
-
{
|
|
249
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
250
|
-
id view = viewRegistry[reactTag];
|
|
251
|
-
if (![view isKindOfClass:[AIRGoogleMap class]]) {
|
|
252
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRGoogleMap, got: %@", view);
|
|
253
|
-
} else {
|
|
254
|
-
[CATransaction begin];
|
|
255
|
-
[CATransaction setAnimationDuration:duration/1000];
|
|
256
|
-
AIRGoogleMap *mapView = (AIRGoogleMap *)view;
|
|
257
|
-
[mapView animateToBearing:bearing];
|
|
258
|
-
[CATransaction commit];
|
|
259
|
-
}
|
|
260
|
-
}];
|
|
261
|
-
}
|
|
262
|
-
|
|
263
187
|
RCT_EXPORT_METHOD(fitToElements:(nonnull NSNumber *)reactTag
|
|
264
188
|
edgePadding:(nonnull NSDictionary *)edgePadding
|
|
265
189
|
animated:(BOOL)animated)
|
|
@@ -418,25 +342,6 @@ RCT_EXPORT_METHOD(takeSnapshot:(nonnull NSNumber *)reactTag
|
|
|
418
342
|
else if ([result isEqualToString:@"base64"]) {
|
|
419
343
|
callback(@[[NSNull null], [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]]);
|
|
420
344
|
}
|
|
421
|
-
else if ([result isEqualToString:@"legacy"]) {
|
|
422
|
-
|
|
423
|
-
// In the initial (iOS only) implementation of takeSnapshot,
|
|
424
|
-
// both the uri and the base64 encoded string were returned.
|
|
425
|
-
// Returning both is rarely useful and in fact causes a
|
|
426
|
-
// performance penalty when only the file URI is desired.
|
|
427
|
-
// In that case the base64 encoded string was always marshalled
|
|
428
|
-
// over the JS-bridge (which is quite slow).
|
|
429
|
-
// A new more flexible API was created to cover this.
|
|
430
|
-
// This code should be removed in a future release when the
|
|
431
|
-
// old API is fully deprecated.
|
|
432
|
-
[data writeToFile:filePath atomically:YES];
|
|
433
|
-
NSDictionary *snapshotData = @{
|
|
434
|
-
@"uri": filePath,
|
|
435
|
-
@"data": [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]
|
|
436
|
-
};
|
|
437
|
-
callback(@[[NSNull null], snapshotData]);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
345
|
}
|
|
441
346
|
UIGraphicsEndImageContext();
|
|
442
347
|
}];
|
package/ios/AirMaps/AIRMap.m
CHANGED
|
@@ -48,7 +48,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
48
48
|
@implementation AIRMap
|
|
49
49
|
{
|
|
50
50
|
UIView *_legalLabel;
|
|
51
|
-
CLLocationManager *_locationManager;
|
|
52
51
|
BOOL _initialRegionSet;
|
|
53
52
|
BOOL _initialCameraSet;
|
|
54
53
|
|
|
@@ -350,12 +349,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
350
349
|
- (void)setShowsUserLocation:(BOOL)showsUserLocation
|
|
351
350
|
{
|
|
352
351
|
if (self.showsUserLocation != showsUserLocation) {
|
|
353
|
-
if (showsUserLocation && !_locationManager) {
|
|
354
|
-
_locationManager = [CLLocationManager new];
|
|
355
|
-
if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
|
|
356
|
-
[_locationManager requestWhenInUseAuthorization];
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
352
|
super.showsUserLocation = showsUserLocation;
|
|
360
353
|
}
|
|
361
354
|
}
|
|
@@ -278,31 +278,6 @@ RCT_EXPORT_METHOD(animateCamera:(nonnull NSNumber *)reactTag
|
|
|
278
278
|
}];
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
|
|
282
|
-
RCT_EXPORT_METHOD(animateToNavigation:(nonnull NSNumber *)reactTag
|
|
283
|
-
withRegion:(MKCoordinateRegion)region
|
|
284
|
-
withBearing:(CGFloat)bearing
|
|
285
|
-
withAngle:(double)angle
|
|
286
|
-
withDuration:(CGFloat)duration)
|
|
287
|
-
{
|
|
288
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
289
|
-
id view = viewRegistry[reactTag];
|
|
290
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
291
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
292
|
-
} else {
|
|
293
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
294
|
-
MKMapCamera *mapCamera = [[mapView camera] copy];
|
|
295
|
-
[mapCamera setPitch:angle];
|
|
296
|
-
[mapCamera setHeading:bearing];
|
|
297
|
-
|
|
298
|
-
[AIRMap animateWithDuration:duration/1000 animations:^{
|
|
299
|
-
[(AIRMap *)view setRegion:region animated:YES];
|
|
300
|
-
[mapView setCamera:mapCamera animated:YES];
|
|
301
|
-
}];
|
|
302
|
-
}
|
|
303
|
-
}];
|
|
304
|
-
}
|
|
305
|
-
|
|
306
281
|
RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
|
|
307
282
|
withRegion:(MKCoordinateRegion)region
|
|
308
283
|
withDuration:(CGFloat)duration)
|
|
@@ -319,68 +294,6 @@ RCT_EXPORT_METHOD(animateToRegion:(nonnull NSNumber *)reactTag
|
|
|
319
294
|
}];
|
|
320
295
|
}
|
|
321
296
|
|
|
322
|
-
RCT_EXPORT_METHOD(animateToCoordinate:(nonnull NSNumber *)reactTag
|
|
323
|
-
withRegion:(CLLocationCoordinate2D)latlng
|
|
324
|
-
withDuration:(CGFloat)duration)
|
|
325
|
-
{
|
|
326
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
327
|
-
id view = viewRegistry[reactTag];
|
|
328
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
329
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
330
|
-
} else {
|
|
331
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
332
|
-
MKCoordinateRegion region;
|
|
333
|
-
region.span = mapView.region.span;
|
|
334
|
-
region.center = latlng;
|
|
335
|
-
[AIRMap animateWithDuration:duration/1000 animations:^{
|
|
336
|
-
[mapView setRegion:region animated:YES];
|
|
337
|
-
}];
|
|
338
|
-
}
|
|
339
|
-
}];
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
RCT_EXPORT_METHOD(animateToViewingAngle:(nonnull NSNumber *)reactTag
|
|
343
|
-
withAngle:(double)angle
|
|
344
|
-
withDuration:(CGFloat)duration)
|
|
345
|
-
{
|
|
346
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
347
|
-
id view = viewRegistry[reactTag];
|
|
348
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
349
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
350
|
-
} else {
|
|
351
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
352
|
-
|
|
353
|
-
MKMapCamera *mapCamera = [[mapView camera] copy];
|
|
354
|
-
[mapCamera setPitch:angle];
|
|
355
|
-
|
|
356
|
-
[AIRMap animateWithDuration:duration/1000 animations:^{
|
|
357
|
-
[mapView setCamera:mapCamera animated:YES];
|
|
358
|
-
}];
|
|
359
|
-
}
|
|
360
|
-
}];
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
RCT_EXPORT_METHOD(animateToBearing:(nonnull NSNumber *)reactTag
|
|
364
|
-
withBearing:(CGFloat)bearing
|
|
365
|
-
withDuration:(CGFloat)duration)
|
|
366
|
-
{
|
|
367
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
368
|
-
id view = viewRegistry[reactTag];
|
|
369
|
-
if (![view isKindOfClass:[AIRMap class]]) {
|
|
370
|
-
RCTLogError(@"Invalid view returned from registry, expecting AIRMap, got: %@", view);
|
|
371
|
-
} else {
|
|
372
|
-
AIRMap *mapView = (AIRMap *)view;
|
|
373
|
-
|
|
374
|
-
MKMapCamera *mapCamera = [[mapView camera] copy];
|
|
375
|
-
[mapCamera setHeading:bearing];
|
|
376
|
-
|
|
377
|
-
[AIRMap animateWithDuration:duration/1000 animations:^{
|
|
378
|
-
[mapView setCamera:mapCamera animated:YES];
|
|
379
|
-
}];
|
|
380
|
-
}
|
|
381
|
-
}];
|
|
382
|
-
}
|
|
383
|
-
|
|
384
297
|
RCT_EXPORT_METHOD(fitToElements:(nonnull NSNumber *)reactTag
|
|
385
298
|
edgePadding:(nonnull NSDictionary *)edgePadding
|
|
386
299
|
animated:(BOOL)animated)
|
|
@@ -677,24 +590,6 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
677
590
|
else if ([result isEqualToString:@"base64"]) {
|
|
678
591
|
callback(@[[NSNull null], [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]]);
|
|
679
592
|
}
|
|
680
|
-
else if ([result isEqualToString:@"legacy"]) {
|
|
681
|
-
|
|
682
|
-
// In the initial (iOS only) implementation of takeSnapshot,
|
|
683
|
-
// both the uri and the base64 encoded string were returned.
|
|
684
|
-
// Returning both is rarely useful and in fact causes a
|
|
685
|
-
// performance penalty when only the file URI is desired.
|
|
686
|
-
// In that case the base64 encoded string was always marshalled
|
|
687
|
-
// over the JS-bridge (which is quite slow).
|
|
688
|
-
// A new more flexible API was created to cover this.
|
|
689
|
-
// This code should be removed in a future release when the
|
|
690
|
-
// old API is fully deprecated.
|
|
691
|
-
[data writeToFile:filePath atomically:YES];
|
|
692
|
-
NSDictionary *snapshotData = @{
|
|
693
|
-
@"uri": filePath,
|
|
694
|
-
@"data": [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn]
|
|
695
|
-
};
|
|
696
|
-
callback(@[[NSNull null], snapshotData]);
|
|
697
|
-
}
|
|
698
593
|
}
|
|
699
594
|
UIGraphicsEndImageContext();
|
|
700
595
|
}];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
import { Region } from './sharedTypes';
|
|
3
|
+
declare const AnimatedWithChildren: any;
|
|
4
|
+
declare type Props = Partial<Region> | undefined;
|
|
5
|
+
export default class AnimatedMapRegion extends AnimatedWithChildren {
|
|
6
|
+
constructor(valueIn?: Props);
|
|
7
|
+
setValue(value: Region): void;
|
|
8
|
+
setOffset(offset: Region): void;
|
|
9
|
+
flattenOffset(): void;
|
|
10
|
+
private __getValue;
|
|
11
|
+
private __attach;
|
|
12
|
+
private __detach;
|
|
13
|
+
stopAnimation(callback: (region: Region) => void): void;
|
|
14
|
+
addListener(callback: (region: Region) => void): string;
|
|
15
|
+
removeListener(id: string): void;
|
|
16
|
+
spring(config: Animated.SpringAnimationConfig & Region): Animated.CompositeAnimation;
|
|
17
|
+
timing(config: Animated.TimingAnimationConfig & Region): Animated.CompositeAnimation;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_native_1 = require("react-native");
|
|
4
|
+
const AnimatedWithChildren = Object.getPrototypeOf(react_native_1.Animated.ValueXY);
|
|
5
|
+
if (__DEV__) {
|
|
6
|
+
if (AnimatedWithChildren.name !== 'AnimatedWithChildren') {
|
|
7
|
+
console.error('AnimatedRegion could not obtain AnimatedWithChildren base class');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const configTypes = [
|
|
11
|
+
'latitude',
|
|
12
|
+
'longitude',
|
|
13
|
+
'latitudeDelta',
|
|
14
|
+
'longitudeDelta',
|
|
15
|
+
];
|
|
16
|
+
const defaultValues = {
|
|
17
|
+
// probably want to come up with better defaults
|
|
18
|
+
latitude: 0,
|
|
19
|
+
longitude: 0,
|
|
20
|
+
latitudeDelta: 0,
|
|
21
|
+
longitudeDelta: 0,
|
|
22
|
+
};
|
|
23
|
+
let _uniqueId = 1;
|
|
24
|
+
const getAnimatedValue = (valueIn, fallback) => {
|
|
25
|
+
if (valueIn instanceof react_native_1.Animated.Value) {
|
|
26
|
+
return valueIn;
|
|
27
|
+
}
|
|
28
|
+
else if (typeof valueIn === 'number') {
|
|
29
|
+
return new react_native_1.Animated.Value(valueIn);
|
|
30
|
+
}
|
|
31
|
+
return new react_native_1.Animated.Value(fallback);
|
|
32
|
+
};
|
|
33
|
+
class AnimatedMapRegion extends AnimatedWithChildren {
|
|
34
|
+
constructor(valueIn = {}) {
|
|
35
|
+
super();
|
|
36
|
+
this.latitude = getAnimatedValue(valueIn.latitude, defaultValues.latitude);
|
|
37
|
+
this.longitude = getAnimatedValue(valueIn.longitude, defaultValues.longitude);
|
|
38
|
+
this.latitudeDelta = getAnimatedValue(valueIn.latitudeDelta, defaultValues.latitudeDelta);
|
|
39
|
+
this.longitudeDelta = getAnimatedValue(valueIn.longitudeDelta, defaultValues.longitudeDelta);
|
|
40
|
+
this._regionListeners = {};
|
|
41
|
+
}
|
|
42
|
+
setValue(value) {
|
|
43
|
+
this.latitude._value = value.latitude;
|
|
44
|
+
this.longitude._value = value.longitude;
|
|
45
|
+
this.latitudeDelta._value = value.latitudeDelta;
|
|
46
|
+
this.longitudeDelta._value = value.longitudeDelta;
|
|
47
|
+
}
|
|
48
|
+
setOffset(offset) {
|
|
49
|
+
this.latitude.setOffset(offset.latitude);
|
|
50
|
+
this.longitude.setOffset(offset.longitude);
|
|
51
|
+
this.latitudeDelta.setOffset(offset.latitudeDelta);
|
|
52
|
+
this.longitudeDelta.setOffset(offset.longitudeDelta);
|
|
53
|
+
}
|
|
54
|
+
flattenOffset() {
|
|
55
|
+
this.latitude.flattenOffset();
|
|
56
|
+
this.longitude.flattenOffset();
|
|
57
|
+
this.latitudeDelta.flattenOffset();
|
|
58
|
+
this.longitudeDelta.flattenOffset();
|
|
59
|
+
}
|
|
60
|
+
__getValue() {
|
|
61
|
+
return {
|
|
62
|
+
latitude: this.latitude.__getValue(),
|
|
63
|
+
longitude: this.longitude.__getValue(),
|
|
64
|
+
latitudeDelta: this.latitudeDelta.__getValue(),
|
|
65
|
+
longitudeDelta: this.longitudeDelta.__getValue(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
__attach() {
|
|
69
|
+
this.latitude.__addChild(this);
|
|
70
|
+
this.longitude.__addChild(this);
|
|
71
|
+
this.latitudeDelta.__addChild(this);
|
|
72
|
+
this.longitudeDelta.__addChild(this);
|
|
73
|
+
}
|
|
74
|
+
__detach() {
|
|
75
|
+
this.latitude.__removeChild(this);
|
|
76
|
+
this.longitude.__removeChild(this);
|
|
77
|
+
this.latitudeDelta.__removeChild(this);
|
|
78
|
+
this.longitudeDelta.__removeChild(this);
|
|
79
|
+
}
|
|
80
|
+
stopAnimation(callback) {
|
|
81
|
+
this.latitude.stopAnimation();
|
|
82
|
+
this.longitude.stopAnimation();
|
|
83
|
+
this.latitudeDelta.stopAnimation();
|
|
84
|
+
this.longitudeDelta.stopAnimation();
|
|
85
|
+
callback && callback(this.__getValue());
|
|
86
|
+
}
|
|
87
|
+
addListener(callback) {
|
|
88
|
+
const id = String(_uniqueId++);
|
|
89
|
+
const jointCallback = () => /*{value}*/ callback(this.__getValue());
|
|
90
|
+
this._regionListeners[id] = {
|
|
91
|
+
latitude: this.latitude.addListener(jointCallback),
|
|
92
|
+
longitude: this.longitude.addListener(jointCallback),
|
|
93
|
+
latitudeDelta: this.latitudeDelta.addListener(jointCallback),
|
|
94
|
+
longitudeDelta: this.longitudeDelta.addListener(jointCallback),
|
|
95
|
+
};
|
|
96
|
+
return id;
|
|
97
|
+
}
|
|
98
|
+
removeListener(id) {
|
|
99
|
+
this.latitude.removeListener(this._regionListeners[id].latitude);
|
|
100
|
+
this.longitude.removeListener(this._regionListeners[id].longitude);
|
|
101
|
+
this.latitudeDelta.removeListener(this._regionListeners[id].latitudeDelta);
|
|
102
|
+
this.longitudeDelta.removeListener(this._regionListeners[id].longitudeDelta);
|
|
103
|
+
delete this._regionListeners[id];
|
|
104
|
+
}
|
|
105
|
+
spring(config) {
|
|
106
|
+
const animations = [];
|
|
107
|
+
for (const type of configTypes) {
|
|
108
|
+
if (config.hasOwnProperty(type)) {
|
|
109
|
+
animations.push(react_native_1.Animated.spring(this[type], {
|
|
110
|
+
...config,
|
|
111
|
+
toValue: config[type],
|
|
112
|
+
// may help to eliminate some dev warnings and perf issues
|
|
113
|
+
useNativeDriver: !!config?.useNativeDriver,
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return react_native_1.Animated.parallel(animations);
|
|
118
|
+
}
|
|
119
|
+
timing(config) {
|
|
120
|
+
const animations = [];
|
|
121
|
+
for (const type of configTypes) {
|
|
122
|
+
if (config.hasOwnProperty(type)) {
|
|
123
|
+
animations.push(react_native_1.Animated.timing(this[type], {
|
|
124
|
+
...config,
|
|
125
|
+
toValue: config[type],
|
|
126
|
+
// may help to eliminate some dev warnings and perf issues
|
|
127
|
+
useNativeDriver: !!config?.useNativeDriver,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return react_native_1.Animated.parallel(animations);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.default = AnimatedMapRegion;
|
package/lib/Geojson.d.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Feature, FeatureCollection, Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
|
|
3
|
+
import { Props as MarkerProps } from './MapMarker';
|
|
4
|
+
import { Props as PolygonProps } from './MapPolygon';
|
|
5
|
+
import { Props as PolylineProps } from './MapPolyline';
|
|
6
|
+
import { LatLng } from './sharedTypes';
|
|
7
|
+
declare type Props = {
|
|
8
|
+
/**
|
|
9
|
+
* The pincolor used on markers
|
|
10
|
+
*
|
|
11
|
+
* @platform iOS: Supported
|
|
12
|
+
* @platform Android: Supported
|
|
13
|
+
*/
|
|
14
|
+
color?: MarkerProps['pinColor'];
|
|
15
|
+
/**
|
|
16
|
+
* The fill color to use for the path.
|
|
17
|
+
*
|
|
18
|
+
* @platform iOS: Supported
|
|
19
|
+
* @platform Android: Supported
|
|
20
|
+
*/
|
|
21
|
+
fillColor?: PolygonProps['fillColor'];
|
|
22
|
+
/**
|
|
23
|
+
* [Geojson](https://geojson.org/) description of object.
|
|
24
|
+
*
|
|
25
|
+
* @platform iOS: Supported
|
|
26
|
+
* @platform Android: Supported
|
|
27
|
+
*/
|
|
28
|
+
geojson: FeatureCollection;
|
|
29
|
+
/**
|
|
30
|
+
* A custom image to be used as the marker's icon. Only local image resources are allowed to be
|
|
31
|
+
* used.
|
|
32
|
+
*
|
|
33
|
+
* @platform iOS: Supported
|
|
34
|
+
* @platform Android: Supported
|
|
35
|
+
*/
|
|
36
|
+
image?: MarkerProps['image'];
|
|
37
|
+
/**
|
|
38
|
+
* The line cap style to apply to the open ends of the path.
|
|
39
|
+
* The default style is `round`.
|
|
40
|
+
*
|
|
41
|
+
* @platform iOS: Apple Maps only
|
|
42
|
+
* @platform Android: Supported
|
|
43
|
+
*/
|
|
44
|
+
lineCap?: PolylineProps['lineCap'];
|
|
45
|
+
/**
|
|
46
|
+
* An array of numbers specifying the dash pattern to use for the path.
|
|
47
|
+
*
|
|
48
|
+
* The array contains one or more numbers that indicate the lengths (measured in points) of the
|
|
49
|
+
* line segments and gaps in the pattern. The values in the array alternate, starting with the
|
|
50
|
+
* first line segment length, followed by the first gap length, followed by the second line
|
|
51
|
+
* segment length, and so on.
|
|
52
|
+
*
|
|
53
|
+
* This property is set to `null` by default, which indicates no line dash pattern.
|
|
54
|
+
*
|
|
55
|
+
* @platform iOS: Supported
|
|
56
|
+
* @platform Android: Supported
|
|
57
|
+
*/
|
|
58
|
+
lineDashPattern?: PolylineProps['lineDashPattern'];
|
|
59
|
+
/**
|
|
60
|
+
* The offset (in points) at which to start drawing the dash pattern.
|
|
61
|
+
*
|
|
62
|
+
* Use this property to start drawing a dashed line partway through a segment or gap. For
|
|
63
|
+
* example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the
|
|
64
|
+
* middle of the first gap.
|
|
65
|
+
*
|
|
66
|
+
* The default value of this property is 0.
|
|
67
|
+
*
|
|
68
|
+
* @platform iOS: Apple Maps only
|
|
69
|
+
* @platform Android: Not supported
|
|
70
|
+
*/
|
|
71
|
+
lineDashPhase?: PolylineProps['lineDashPhase'];
|
|
72
|
+
/**
|
|
73
|
+
* The line join style to apply to corners of the path.
|
|
74
|
+
* The default style is `round`.
|
|
75
|
+
*
|
|
76
|
+
* @platform iOS: Apple Maps only
|
|
77
|
+
* @platform Android: Not supported
|
|
78
|
+
*/
|
|
79
|
+
lineJoin?: PolylineProps['lineJoin'];
|
|
80
|
+
/**
|
|
81
|
+
* Component to render in place of the default marker when the overlay type is a `point`
|
|
82
|
+
*
|
|
83
|
+
* @platform iOS: Supported
|
|
84
|
+
* @platform Android: Supported
|
|
85
|
+
*/
|
|
86
|
+
markerComponent?: MarkerProps['children'];
|
|
87
|
+
/**
|
|
88
|
+
* The limiting value that helps avoid spikes at junctions between connected line segments.
|
|
89
|
+
* The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If
|
|
90
|
+
* the ratio of the miter length—that is, the diagonal length of the miter join—to the line
|
|
91
|
+
* thickness exceeds the miter limit, the joint is converted to a bevel join. The default
|
|
92
|
+
* miter limit is 10, which results in the conversion of miters whose angle at the joint
|
|
93
|
+
* is less than 11 degrees.
|
|
94
|
+
*
|
|
95
|
+
* @platform iOS: Apple Maps only
|
|
96
|
+
* @platform Android: Not supported
|
|
97
|
+
*/
|
|
98
|
+
miterLimit?: PolylineProps['miterLimit'];
|
|
99
|
+
/**
|
|
100
|
+
* Callback that is called when the user presses any of the overlays
|
|
101
|
+
*/
|
|
102
|
+
onPress?: (event: OverlayPressEvent) => void;
|
|
103
|
+
/**
|
|
104
|
+
* The stroke color to use for the path.
|
|
105
|
+
*
|
|
106
|
+
* @platform — iOS: Supported
|
|
107
|
+
* @platform — Android: Supported
|
|
108
|
+
*/
|
|
109
|
+
strokeColor?: PolygonProps['strokeColor'] | PolylineProps['strokeColor'];
|
|
110
|
+
/**
|
|
111
|
+
* The stroke width to use for the path.
|
|
112
|
+
*
|
|
113
|
+
* @platform — iOS: Supported
|
|
114
|
+
* @platform — Android: Supported
|
|
115
|
+
*/
|
|
116
|
+
strokeWidth?: PolygonProps['strokeWidth'] | PolylineProps['strokeWidth'];
|
|
117
|
+
/**
|
|
118
|
+
* Make the `Polygon` or `Polyline` tappable
|
|
119
|
+
*
|
|
120
|
+
* @platform — iOS: Google Maps only
|
|
121
|
+
* @platform — Android: Supported
|
|
122
|
+
*/
|
|
123
|
+
tappable?: PolygonProps['tappable'] | PolylineProps['tappable'];
|
|
124
|
+
/**
|
|
125
|
+
* The title of the marker. This is only used if the <Marker /> component has no children that
|
|
126
|
+
* are a `<Callout />`, in which case the default callout behavior will be used, which
|
|
127
|
+
* will show both the `title` and the `description`, if provided.
|
|
128
|
+
*
|
|
129
|
+
* @platform — iOS: Supported
|
|
130
|
+
* @platform — Android: Supported
|
|
131
|
+
*/
|
|
132
|
+
title?: MarkerProps['title'];
|
|
133
|
+
/**
|
|
134
|
+
* The order in which this tile overlay is drawn with respect to other overlays. An overlay
|
|
135
|
+
* with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays
|
|
136
|
+
* with the same z-index is arbitrary. The default zIndex is 0.
|
|
137
|
+
*
|
|
138
|
+
* @platform iOS: Apple Maps: [Marker], Google Maps: [Marker, Polygon, Polyline]
|
|
139
|
+
* @platform Android: Supported
|
|
140
|
+
*/
|
|
141
|
+
zIndex?: MarkerProps['zIndex'] | PolygonProps['zIndex'] | PolylineProps['zIndex'];
|
|
142
|
+
};
|
|
143
|
+
declare const Geojson: (props: Props) => JSX.Element;
|
|
144
|
+
export default Geojson;
|
|
145
|
+
declare type OverlayPressEvent = {
|
|
146
|
+
type: AnyPointOverlay['type'] | AnyLineStringOverlay['type'] | AnyPolygonOverlay['type'];
|
|
147
|
+
feature: AnyPointOverlay['feature'] | AnyLineStringOverlay['feature'] | AnyPolygonOverlay['feature'];
|
|
148
|
+
coordinates: AnyPointOverlay['coordinates'] | AnyLineStringOverlay['coordinates'] | AnyPolygonOverlay['coordinates'];
|
|
149
|
+
holes?: AnyPolygonOverlay['holes'];
|
|
150
|
+
};
|
|
151
|
+
declare type AnyPointOverlay = {
|
|
152
|
+
type: 'point';
|
|
153
|
+
feature: Feature<Point | MultiPoint>;
|
|
154
|
+
coordinates: LatLng;
|
|
155
|
+
};
|
|
156
|
+
declare type AnyLineStringOverlay = {
|
|
157
|
+
type: 'polyline';
|
|
158
|
+
feature: Feature<LineString | MultiLineString>;
|
|
159
|
+
coordinates: LatLng[];
|
|
160
|
+
};
|
|
161
|
+
declare type AnyPolygonOverlay = {
|
|
162
|
+
type: 'polygon';
|
|
163
|
+
feature: Feature<Polygon | MultiPolygon>;
|
|
164
|
+
coordinates: LatLng[];
|
|
165
|
+
holes?: LatLng[][];
|
|
166
|
+
};
|