react-native-maps 0.31.0 → 1.0.0-beta.10
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 +2 -6
- 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 -19
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -95
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +6 -0
- package/ios/AirMaps/AIRMap.h +0 -1
- package/ios/AirMaps/AIRMap.m +0 -12
- package/ios/AirMaps/AIRMapManager.m +4 -135
- 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 +78 -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 +290 -0
- package/lib/MapMarker.js +113 -0
- package/lib/MapOverlay.d.ts +87 -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 +677 -0
- package/lib/MapView.js +418 -0
- package/lib/MapView.types.d.ts +153 -0
- package/lib/MapView.types.js +2 -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/lib/index.d.ts +37 -0
- package/lib/index.js +81 -0
- package/lib/sharedTypes.d.ts +81 -0
- package/lib/sharedTypes.js +2 -0
- package/lib/sharedTypesInternal.d.ts +1 -0
- package/lib/sharedTypesInternal.js +2 -0
- package/package.json +21 -29
- package/react-native-google-maps.podspec +6 -7
- package/react-native-maps.podspec +5 -6
- 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/src/index.js +0 -31
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
|
|
|
@@ -118,7 +114,7 @@ import { Marker } from 'react-native-maps';
|
|
|
118
114
|
```
|
|
119
115
|
|
|
120
116
|
### Rendering a Marker with a custom image
|
|
121
|
-
1. You need to generate an `png` image with various resolution (lets call them `custom_pin`) - for more information go to [Android](https://developer.android.com/studio/write/image-asset-studio#access), [iOS](https://developer.apple.com/
|
|
117
|
+
1. You need to generate an `png` image with various resolution (lets call them `custom_pin`) - for more information go to [Android](https://developer.android.com/studio/write/image-asset-studio#access), [iOS](https://developer.apple.com/documentation/xcode/adding-images-to-your-xcode-project)
|
|
122
118
|
2. put all images in Android drawables and iOS assets dir
|
|
123
119
|
3. Now you can use the following code:
|
|
124
120
|
```jsx
|
|
@@ -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,11 @@ 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 _didLayoutSubviews;
|
|
68
|
+
BOOL _didPrepareMap;
|
|
66
69
|
BOOL _didCallOnMapReady;
|
|
67
|
-
BOOL _didMoveToWindow;
|
|
68
70
|
BOOL _zoomTapEnabled;
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -83,9 +85,11 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
83
85
|
_cameraProp = nil;
|
|
84
86
|
_initialRegion = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0, 0.0), MKCoordinateSpanMake(0.0, 0.0));
|
|
85
87
|
_region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0, 0.0), MKCoordinateSpanMake(0.0, 0.0));
|
|
86
|
-
|
|
88
|
+
_initialRegionSet = false;
|
|
89
|
+
_initialCameraSet = false;
|
|
90
|
+
_didLayoutSubviews = false;
|
|
91
|
+
_didPrepareMap = false;
|
|
87
92
|
_didCallOnMapReady = false;
|
|
88
|
-
_didMoveToWindow = false;
|
|
89
93
|
_zoomTapEnabled = YES;
|
|
90
94
|
|
|
91
95
|
// Listen to the myLocation property of GMSMapView.
|
|
@@ -245,42 +249,47 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
245
249
|
];
|
|
246
250
|
}
|
|
247
251
|
|
|
248
|
-
- (void)
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
- (void)layoutSubviews {
|
|
253
|
+
[super layoutSubviews];
|
|
254
|
+
if(_didLayoutSubviews) return;
|
|
255
|
+
_didLayoutSubviews = true;
|
|
251
256
|
|
|
252
257
|
if (_initialCamera != nil) {
|
|
253
258
|
self.camera = _initialCamera;
|
|
259
|
+
_initialCameraSet = true;
|
|
254
260
|
}
|
|
255
261
|
else if (_initialRegion.span.latitudeDelta != 0.0 &&
|
|
256
262
|
_initialRegion.span.longitudeDelta != 0.0) {
|
|
257
263
|
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_initialRegion];
|
|
264
|
+
_initialRegionSet = true;
|
|
258
265
|
} else if (_region.span.latitudeDelta != 0.0 &&
|
|
259
266
|
_region.span.longitudeDelta != 0.0) {
|
|
260
267
|
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:_region];
|
|
261
268
|
}
|
|
262
|
-
|
|
263
|
-
[super didMoveToWindow];
|
|
264
269
|
}
|
|
265
270
|
|
|
266
271
|
- (void)setInitialRegion:(MKCoordinateRegion)initialRegion {
|
|
267
|
-
if (_initialCameraSetOnLoad) return;
|
|
268
272
|
_initialRegion = initialRegion;
|
|
269
|
-
|
|
270
|
-
|
|
273
|
+
if(!_initialRegionSet && _didLayoutSubviews){
|
|
274
|
+
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:initialRegion];
|
|
275
|
+
_initialRegionSet = true;
|
|
276
|
+
}
|
|
271
277
|
}
|
|
272
278
|
|
|
273
279
|
- (void)setInitialCamera:(GMSCameraPosition*)initialCamera {
|
|
274
|
-
if (_initialCameraSetOnLoad) return;
|
|
275
280
|
_initialCamera = initialCamera;
|
|
276
|
-
|
|
277
|
-
|
|
281
|
+
if(!_initialCameraSet && _didLayoutSubviews){
|
|
282
|
+
self.camera = initialCamera;
|
|
283
|
+
_initialCameraSet = true;
|
|
284
|
+
}
|
|
278
285
|
}
|
|
279
286
|
|
|
280
287
|
- (void)setRegion:(MKCoordinateRegion)region {
|
|
281
288
|
// TODO: The JS component is repeatedly setting region unnecessarily. We might want to deal with that in here.
|
|
282
289
|
_region = region;
|
|
283
|
-
|
|
290
|
+
if(_didLayoutSubviews) {
|
|
291
|
+
self.camera = [AIRGoogleMap makeGMSCameraPositionFromMap:self andMKCoordinateRegion:region];
|
|
292
|
+
}
|
|
284
293
|
}
|
|
285
294
|
|
|
286
295
|
- (void)setCameraProp:(GMSCameraPosition*)camera {
|
|
@@ -288,14 +297,23 @@ id regionAsJSON(MKCoordinateRegion region) {
|
|
|
288
297
|
self.camera = camera;
|
|
289
298
|
}
|
|
290
299
|
|
|
300
|
+
- (void)setOnMapReady:(RCTBubblingEventBlock)onMapReady {
|
|
301
|
+
_onMapReady = onMapReady;
|
|
302
|
+
if(!_didCallOnMapReady && _didPrepareMap) {
|
|
303
|
+
self.onMapReady(@{});
|
|
304
|
+
_didCallOnMapReady = true;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
291
307
|
|
|
292
308
|
- (void)didPrepareMap {
|
|
293
309
|
UIView* mapView = [self valueForKey:@"mapView"]; //GMSVectorMapView
|
|
294
310
|
[self overrideGestureRecognizersForView:mapView];
|
|
295
311
|
|
|
296
|
-
if (_didCallOnMapReady)
|
|
297
|
-
|
|
298
|
-
|
|
312
|
+
if (!_didCallOnMapReady && self.onMapReady) {
|
|
313
|
+
self.onMapReady(@{});
|
|
314
|
+
_didCallOnMapReady = true;
|
|
315
|
+
}
|
|
316
|
+
_didPrepareMap = true;
|
|
299
317
|
}
|
|
300
318
|
|
|
301
319
|
- (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
|
}];
|
|
@@ -326,6 +326,12 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
326
326
|
_reloadImageCancellationBlock = nil;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
if (!_realMarker.icon) {
|
|
330
|
+
// prevent glitch with marker (cf. https://github.com/react-native-maps/react-native-maps/issues/3657)
|
|
331
|
+
UIImage *emptyImage = [[UIImage alloc] init];
|
|
332
|
+
_realMarker.icon = emptyImage;
|
|
333
|
+
}
|
|
334
|
+
|
|
329
335
|
_reloadImageCancellationBlock =
|
|
330
336
|
[[_bridge moduleForName:@"ImageLoader"] loadImageWithURLRequest:[RCTConvert NSURLRequest:_iconSrc]
|
|
331
337
|
size:self.bounds.size
|
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
|
}
|