react-native-maps 0.31.1 → 1.0.0-beta.3
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/src/main/AndroidManifest.xml +0 -3
- 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 +2 -41
- 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 +1 -33
- package/ios/AirGoogleMaps/AIRGoogleMap.m +37 -31
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -95
- package/ios/AirMaps/AIRMap.h +0 -1
- package/ios/AirMaps/AIRMap.m +0 -12
- package/ios/AirMaps/AIRMapManager.m +2 -132
- 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 +19 -28
- package/react-native-google-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
package/README.md
CHANGED
|
@@ -14,11 +14,7 @@ See [Setup Instructions for the Included Example Project](docs/examples-setup.md
|
|
|
14
14
|
|
|
15
15
|
## Compatibility
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
support this module on anything but the latest version of React Native. With that said, we will do
|
|
19
|
-
our best to stay compatible with older versions as much that is practical, and the peer dependency
|
|
20
|
-
of this requirement is set to `"react-native": "*"` explicitly for this reason. If you are using
|
|
21
|
-
an older version of React Native with this module though, some features may be buggy.
|
|
17
|
+
`react-native-maps` requires `react-native >= 0.64.3`.
|
|
22
18
|
|
|
23
19
|
## Component API
|
|
24
20
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
2
|
package="com.airbnb.android.react.maps" >
|
|
4
|
-
<uses-permission android:name="android.permission.INTERNET" />
|
|
5
|
-
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
6
3
|
</manifest>
|
|
@@ -20,11 +20,13 @@ public class AirMapLocalTile extends AirMapFeature {
|
|
|
20
20
|
private static final int BUFFER_SIZE = 16 * 1024;
|
|
21
21
|
private int tileSize;
|
|
22
22
|
private String pathTemplate;
|
|
23
|
+
private boolean useAssets;
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
public AIRMapLocalTileProvider(int tileSizet, String pathTemplate) {
|
|
26
|
+
public AIRMapLocalTileProvider(int tileSizet, String pathTemplate, boolean useAssets) {
|
|
26
27
|
this.tileSize = tileSizet;
|
|
27
28
|
this.pathTemplate = pathTemplate;
|
|
29
|
+
this.useAssets = useAssets;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
@Override
|
|
@@ -44,10 +46,10 @@ public class AirMapLocalTile extends AirMapFeature {
|
|
|
44
46
|
private byte[] readTileImage(int x, int y, int zoom) {
|
|
45
47
|
InputStream in = null;
|
|
46
48
|
ByteArrayOutputStream buffer = null;
|
|
47
|
-
|
|
49
|
+
String tileFilename = getTileFilename(x, y, zoom);
|
|
48
50
|
|
|
49
51
|
try {
|
|
50
|
-
in = new FileInputStream(
|
|
52
|
+
in = useAssets ? getContext().getAssets().open(tileFilename) : new FileInputStream(tileFilename);
|
|
51
53
|
buffer = new ByteArrayOutputStream();
|
|
52
54
|
|
|
53
55
|
int nRead;
|
|
@@ -87,6 +89,7 @@ public class AirMapLocalTile extends AirMapFeature {
|
|
|
87
89
|
private String pathTemplate;
|
|
88
90
|
private float tileSize;
|
|
89
91
|
private float zIndex;
|
|
92
|
+
private boolean useAssets;
|
|
90
93
|
|
|
91
94
|
public AirMapLocalTile(Context context) {
|
|
92
95
|
super(context);
|
|
@@ -116,6 +119,10 @@ public class AirMapLocalTile extends AirMapFeature {
|
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
|
|
122
|
+
public void setUseAssets(boolean useAssets) {
|
|
123
|
+
this.useAssets = useAssets;
|
|
124
|
+
}
|
|
125
|
+
|
|
119
126
|
public TileOverlayOptions getTileOverlayOptions() {
|
|
120
127
|
if (tileOverlayOptions == null) {
|
|
121
128
|
tileOverlayOptions = createTileOverlayOptions();
|
|
@@ -126,7 +133,7 @@ public class AirMapLocalTile extends AirMapFeature {
|
|
|
126
133
|
private TileOverlayOptions createTileOverlayOptions() {
|
|
127
134
|
TileOverlayOptions options = new TileOverlayOptions();
|
|
128
135
|
options.zIndex(zIndex);
|
|
129
|
-
this.tileProvider = new AirMapLocalTile.AIRMapLocalTileProvider((int)this.tileSize, this.pathTemplate);
|
|
136
|
+
this.tileProvider = new AirMapLocalTile.AIRMapLocalTileProvider((int)this.tileSize, this.pathTemplate, this.useAssets);
|
|
130
137
|
options.tileProvider(this.tileProvider);
|
|
131
138
|
return options;
|
|
132
139
|
}
|
|
@@ -53,4 +53,8 @@ public class AirMapLocalTileManager extends ViewGroupManager<AirMapLocalTile> {
|
|
|
53
53
|
view.setZIndex(zIndex);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
@ReactProp(name = "useAssets", defaultBoolean = false)
|
|
57
|
+
public void setUseAssets(AirMapLocalTile view, boolean useAssets) {
|
|
58
|
+
view.setUseAssets(useAssets);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -314,17 +314,6 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
|
|
|
314
314
|
view.animateToCamera(camera, duration);
|
|
315
315
|
break;
|
|
316
316
|
|
|
317
|
-
case ANIMATE_TO_NAVIGATION:
|
|
318
|
-
region = args.getMap(0);
|
|
319
|
-
lng = region.getDouble("longitude");
|
|
320
|
-
lat = region.getDouble("latitude");
|
|
321
|
-
LatLng location = new LatLng(lat, lng);
|
|
322
|
-
bearing = (float)args.getDouble(1);
|
|
323
|
-
angle = (float)args.getDouble(2);
|
|
324
|
-
duration = args.getInt(3);
|
|
325
|
-
view.animateToNavigation(location, bearing, angle, duration);
|
|
326
|
-
break;
|
|
327
|
-
|
|
328
317
|
case ANIMATE_TO_REGION:
|
|
329
318
|
region = args.getMap(0);
|
|
330
319
|
duration = args.getInt(1);
|
|
@@ -339,26 +328,6 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
|
|
|
339
328
|
view.animateToRegion(bounds, duration);
|
|
340
329
|
break;
|
|
341
330
|
|
|
342
|
-
case ANIMATE_TO_COORDINATE:
|
|
343
|
-
region = args.getMap(0);
|
|
344
|
-
duration = args.getInt(1);
|
|
345
|
-
lng = region.getDouble("longitude");
|
|
346
|
-
lat = region.getDouble("latitude");
|
|
347
|
-
view.animateToCoordinate(new LatLng(lat, lng), duration);
|
|
348
|
-
break;
|
|
349
|
-
|
|
350
|
-
case ANIMATE_TO_VIEWING_ANGLE:
|
|
351
|
-
angle = (float)args.getDouble(0);
|
|
352
|
-
duration = args.getInt(1);
|
|
353
|
-
view.animateToViewingAngle(angle, duration);
|
|
354
|
-
break;
|
|
355
|
-
|
|
356
|
-
case ANIMATE_TO_BEARING:
|
|
357
|
-
bearing = (float)args.getDouble(0);
|
|
358
|
-
duration = args.getInt(1);
|
|
359
|
-
view.animateToBearing(bearing, duration);
|
|
360
|
-
break;
|
|
361
|
-
|
|
362
331
|
case FIT_TO_ELEMENTS:
|
|
363
332
|
view.fitToElements(args.getMap(0), args.getBoolean(1));
|
|
364
333
|
break;
|
|
@@ -421,13 +390,9 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
|
|
|
421
390
|
"setCamera", SET_CAMERA,
|
|
422
391
|
"animateCamera", ANIMATE_CAMERA,
|
|
423
392
|
"animateToRegion", ANIMATE_TO_REGION,
|
|
424
|
-
"animateToCoordinate", ANIMATE_TO_COORDINATE,
|
|
425
|
-
"animateToViewingAngle", ANIMATE_TO_VIEWING_ANGLE,
|
|
426
|
-
"animateToBearing", ANIMATE_TO_BEARING,
|
|
427
393
|
"fitToElements", FIT_TO_ELEMENTS,
|
|
428
394
|
"fitToSuppliedMarkers", FIT_TO_SUPPLIED_MARKERS,
|
|
429
|
-
"fitToCoordinates", FIT_TO_COORDINATES
|
|
430
|
-
"animateToNavigation", ANIMATE_TO_NAVIGATION
|
|
395
|
+
"fitToCoordinates", FIT_TO_COORDINATES
|
|
431
396
|
);
|
|
432
397
|
|
|
433
398
|
map.putAll(MapBuilder.of(
|
|
@@ -439,7 +404,7 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
|
|
|
439
404
|
}
|
|
440
405
|
|
|
441
406
|
public static <K, V> Map<K, V> CreateMap(
|
|
442
|
-
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6
|
|
407
|
+
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
|
|
443
408
|
Map map = new HashMap<K, V>();
|
|
444
409
|
map.put(k1, v1);
|
|
445
410
|
map.put(k2, v2);
|
|
@@ -447,10 +412,6 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
|
|
|
447
412
|
map.put(k4, v4);
|
|
448
413
|
map.put(k5, v5);
|
|
449
414
|
map.put(k6, v6);
|
|
450
|
-
map.put(k7, v7);
|
|
451
|
-
map.put(k8, v8);
|
|
452
|
-
map.put(k9, v9);
|
|
453
|
-
map.put(k10, v10);
|
|
454
415
|
return map;
|
|
455
416
|
}
|
|
456
417
|
|
|
@@ -171,10 +171,10 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
171
171
|
if (this.tileCachePath != null) {
|
|
172
172
|
image = readTileImage(x, y, zoom);
|
|
173
173
|
if (image != null) {
|
|
174
|
-
Log.d("urlTile
|
|
174
|
+
Log.d("urlTile", "tile cache HIT for " + Integer.toString(zoom) +
|
|
175
175
|
"/" + Integer.toString(x) + "/" + Integer.toString(y));
|
|
176
176
|
} else {
|
|
177
|
-
Log.d("urlTile
|
|
177
|
+
Log.d("urlTile", "tile cache MISS for " + Integer.toString(zoom) +
|
|
178
178
|
"/" + Integer.toString(x) + "/" + Integer.toString(y));
|
|
179
179
|
}
|
|
180
180
|
if (image != null && !this.offlineMode) {
|
|
@@ -212,10 +212,10 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
212
212
|
if (this.tileCachePath != null) {
|
|
213
213
|
image = readTileImage(x, y, zoom);
|
|
214
214
|
if (image != null) {
|
|
215
|
-
Log.d("urlTile
|
|
215
|
+
Log.d("urlTile","tile cache fetch HIT for " + Integer.toString(zoom) +
|
|
216
216
|
"/" + Integer.toString(x) + "/" + Integer.toString(y));
|
|
217
217
|
} else {
|
|
218
|
-
Log.d("urlTile
|
|
218
|
+
Log.d("urlTile","tile cache fetch MISS for " + Integer.toString(zoom) +
|
|
219
219
|
"/" + Integer.toString(x) + "/" + Integer.toString(y));
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -229,7 +229,7 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
229
229
|
Log.d("urlTile", "Normal fetch");
|
|
230
230
|
image = fetchTile(x, y, zoom);
|
|
231
231
|
if (image == null) {
|
|
232
|
-
Log.d("urlTile
|
|
232
|
+
Log.d("urlTile", "tile fetch TIMEOUT / FAIL for " + Integer.toString(zoom) +
|
|
233
233
|
"/" + Integer.toString(x) + "/" + Integer.toString(y));
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -291,7 +291,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
291
291
|
map.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
|
|
292
292
|
@Override
|
|
293
293
|
public void onPolylineClick(Polyline polyline) {
|
|
294
|
-
WritableMap event = makeClickEventData(
|
|
294
|
+
WritableMap event = makeClickEventData(tapLocation);
|
|
295
295
|
event.putString("action", "polyline-press");
|
|
296
296
|
manager.pushEvent(context, polylineMap.get(polyline), "onPress", event);
|
|
297
297
|
}
|
|
@@ -799,43 +799,11 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
799
799
|
}
|
|
800
800
|
}
|
|
801
801
|
|
|
802
|
-
public void animateToNavigation(LatLng location, float bearing, float angle, int duration) {
|
|
803
|
-
if (map == null) return;
|
|
804
|
-
CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
|
|
805
|
-
.bearing(bearing)
|
|
806
|
-
.tilt(angle)
|
|
807
|
-
.target(location)
|
|
808
|
-
.build();
|
|
809
|
-
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
|
|
810
|
-
}
|
|
811
|
-
|
|
812
802
|
public void animateToRegion(LatLngBounds bounds, int duration) {
|
|
813
803
|
if (map == null) return;
|
|
814
804
|
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0), duration, null);
|
|
815
805
|
}
|
|
816
806
|
|
|
817
|
-
public void animateToViewingAngle(float angle, int duration) {
|
|
818
|
-
if (map == null) return;
|
|
819
|
-
|
|
820
|
-
CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
|
|
821
|
-
.tilt(angle)
|
|
822
|
-
.build();
|
|
823
|
-
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
public void animateToBearing(float bearing, int duration) {
|
|
827
|
-
if (map == null) return;
|
|
828
|
-
CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
|
|
829
|
-
.bearing(bearing)
|
|
830
|
-
.build();
|
|
831
|
-
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
public void animateToCoordinate(LatLng coordinate, int duration) {
|
|
835
|
-
if (map == null) return;
|
|
836
|
-
map.animateCamera(CameraUpdateFactory.newLatLng(coordinate), duration, null);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
807
|
public void fitToElements(ReadableMap edgePadding, boolean animated) {
|
|
840
808
|
if (map == null) return;
|
|
841
809
|
|
|
@@ -62,9 +62,10 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
62
62
|
NSMutableArray<UIView *> *_reactSubviews;
|
|
63
63
|
MKCoordinateRegion _initialRegion;
|
|
64
64
|
MKCoordinateRegion _region;
|
|
65
|
-
BOOL
|
|
65
|
+
BOOL _initialRegionSet;
|
|
66
|
+
BOOL _initialCameraSet;
|
|
67
|
+
BOOL _didPrepareMap;
|
|
66
68
|
BOOL _didCallOnMapReady;
|
|
67
|
-
BOOL _didMoveToWindow;
|
|
68
69
|
BOOL _zoomTapEnabled;
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -83,9 +84,10 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
83
84
|
_cameraProp = nil;
|
|
84
85
|
_initialRegion = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0, 0.0), MKCoordinateSpanMake(0.0, 0.0));
|
|
85
86
|
_region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0, 0.0), MKCoordinateSpanMake(0.0, 0.0));
|
|
86
|
-
|
|
87
|
+
_initialRegionSet = false;
|
|
88
|
+
_initialCameraSet = false;
|
|
89
|
+
_didPrepareMap = false;
|
|
87
90
|
_didCallOnMapReady = false;
|
|
88
|
-
_didMoveToWindow = false;
|
|
89
91
|
_zoomTapEnabled = YES;
|
|
90
92
|
|
|
91
93
|
// Listen to the myLocation property of GMSMapView.
|
|
@@ -245,36 +247,20 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
245
247
|
];
|
|
246
248
|
}
|
|
247
249
|
|
|
248
|
-
- (void)didMoveToWindow {
|
|
249
|
-
if (_didMoveToWindow) return;
|
|
250
|
-
_didMoveToWindow = true;
|
|
251
|
-
|
|
252
|
-
if (_initialCamera != nil) {
|
|
253
|
-
self.camera = _initialCamera;
|
|
254
|
-
}
|
|
255
|
-
else if (_initialRegion.span.latitudeDelta != 0.0 &&
|
|
256
|
-
_initialRegion.span.longitudeDelta != 0.0) {
|
|
257
|
-
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_initialRegion];
|
|
258
|
-
} else if (_region.span.latitudeDelta != 0.0 &&
|
|
259
|
-
_region.span.longitudeDelta != 0.0) {
|
|
260
|
-
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_region];
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
[super didMoveToWindow];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
250
|
- (void)setInitialRegion:(MKCoordinateRegion)initialRegion {
|
|
267
|
-
if (_initialCameraSetOnLoad) return;
|
|
268
251
|
_initialRegion = initialRegion;
|
|
269
|
-
|
|
270
|
-
|
|
252
|
+
if(!_initialRegionSet && _didPrepareMap){
|
|
253
|
+
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:initialRegion];
|
|
254
|
+
_initialRegionSet = true;
|
|
255
|
+
}
|
|
271
256
|
}
|
|
272
257
|
|
|
273
258
|
- (void)setInitialCamera:(GMSCameraPosition*)initialCamera {
|
|
274
|
-
if (_initialCameraSetOnLoad) return;
|
|
275
259
|
_initialCamera = initialCamera;
|
|
276
|
-
|
|
277
|
-
|
|
260
|
+
if(!_initialCameraSet && _didPrepareMap){
|
|
261
|
+
self.camera = initialCamera;
|
|
262
|
+
_initialCameraSet = true;
|
|
263
|
+
}
|
|
278
264
|
}
|
|
279
265
|
|
|
280
266
|
- (void)setRegion:(MKCoordinateRegion)region {
|
|
@@ -288,14 +274,34 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
288
274
|
self.camera = camera;
|
|
289
275
|
}
|
|
290
276
|
|
|
277
|
+
- (void)setOnMapReady:(RCTBubblingEventBlock)onMapReady {
|
|
278
|
+
_onMapReady = onMapReady;
|
|
279
|
+
if(!_didCallOnMapReady && _didPrepareMap) {
|
|
280
|
+
self.onMapReady(@{});
|
|
281
|
+
_didCallOnMapReady = true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
291
284
|
|
|
292
285
|
- (void)didPrepareMap {
|
|
293
286
|
UIView* mapView = [self valueForKey:@"mapView"]; //GMSVectorMapView
|
|
294
287
|
[self overrideGestureRecognizersForView:mapView];
|
|
295
288
|
|
|
296
|
-
if
|
|
297
|
-
|
|
298
|
-
|
|
289
|
+
if(!_didPrepareMap && !_initialRegionSet && !_initialCameraSet){
|
|
290
|
+
if(_initialRegion.span.latitudeDelta != 0.0 && _initialRegion.span.longitudeDelta != 0.0){
|
|
291
|
+
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_initialRegion];
|
|
292
|
+
_initialRegionSet = true;
|
|
293
|
+
} else if(_initialCamera != nil) {
|
|
294
|
+
self.camera = _initialCamera;
|
|
295
|
+
_initialCameraSet = true;
|
|
296
|
+
} else if(_region.span.latitudeDelta != 0.0 && _region.span.longitudeDelta != 0.0) {
|
|
297
|
+
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_region];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (!_didCallOnMapReady && self.onMapReady) {
|
|
301
|
+
self.onMapReady(@{});
|
|
302
|
+
_didCallOnMapReady = true;
|
|
303
|
+
}
|
|
304
|
+
_didPrepareMap = true;
|
|
299
305
|
}
|
|
300
306
|
|
|
301
307
|
- (void)mapViewDidFinishTileRendering {
|
|
@@ -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.h
CHANGED
|
@@ -40,7 +40,6 @@ extern const NSInteger AIRMapMaxZoomLevel;
|
|
|
40
40
|
@property (nonatomic, assign) CGFloat minDelta;
|
|
41
41
|
@property (nonatomic, assign) CGFloat maxDelta;
|
|
42
42
|
@property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
|
|
43
|
-
@property (nonatomic, strong) NSTimer *regionChangeObserveTimer;
|
|
44
43
|
@property (nonatomic, assign) MKCoordinateRegion initialRegion;
|
|
45
44
|
@property (nonatomic, assign) MKMapCamera *initialCamera;
|
|
46
45
|
@property (nonatomic, assign) CGFloat minZoomLevel;
|
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
|
|
|
@@ -92,11 +91,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
92
91
|
return self;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
- (void)dealloc
|
|
96
|
-
{
|
|
97
|
-
[_regionChangeObserveTimer invalidate];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
94
|
-(void)addSubview:(UIView *)view {
|
|
101
95
|
if([view isKindOfClass:[AIRMapMarker class]]) {
|
|
102
96
|
[self addAnnotation:(id <MKAnnotation>)view];
|
|
@@ -350,12 +344,6 @@ const NSInteger AIRMapMaxZoomLevel = 20;
|
|
|
350
344
|
- (void)setShowsUserLocation:(BOOL)showsUserLocation
|
|
351
345
|
{
|
|
352
346
|
if (self.showsUserLocation != showsUserLocation) {
|
|
353
|
-
if (showsUserLocation && !_locationManager) {
|
|
354
|
-
_locationManager = [CLLocationManager new];
|
|
355
|
-
if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
|
|
356
|
-
[_locationManager requestWhenInUseAuthorization];
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
347
|
super.showsUserLocation = showsUserLocation;
|
|
360
348
|
}
|
|
361
349
|
}
|