react-native-maps 1.12.0 → 1.13.0

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.
@@ -22,6 +22,8 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
22
22
  import com.google.android.gms.location.Priority;
23
23
  import com.google.android.gms.maps.GoogleMap;
24
24
  import com.google.android.gms.maps.GoogleMapOptions;
25
+ import com.google.android.gms.maps.MapsInitializer;
26
+ import com.google.android.gms.maps.model.CameraPosition;
25
27
  import com.google.android.gms.maps.model.LatLng;
26
28
  import com.google.android.gms.maps.model.LatLngBounds;
27
29
 
@@ -29,437 +31,462 @@ import java.util.Map;
29
31
 
30
32
  public class MapManager extends ViewGroupManager<MapView> {
31
33
 
32
- private static final String REACT_CLASS = "AIRMap";
33
-
34
- private final Map<String, Integer> MAP_TYPES = MapBuilder.of(
35
- "standard", GoogleMap.MAP_TYPE_NORMAL,
36
- "satellite", GoogleMap.MAP_TYPE_SATELLITE,
37
- "hybrid", GoogleMap.MAP_TYPE_HYBRID,
38
- "terrain", GoogleMap.MAP_TYPE_TERRAIN,
39
- "none", GoogleMap.MAP_TYPE_NONE
40
- );
41
-
42
- private final Map<String, Integer> MY_LOCATION_PRIORITY = MapBuilder.of(
43
- "balanced", Priority.PRIORITY_BALANCED_POWER_ACCURACY,
44
- "high", Priority.PRIORITY_HIGH_ACCURACY,
45
- "low", Priority.PRIORITY_LOW_POWER,
46
- "passive", Priority.PRIORITY_PASSIVE
47
- );
48
-
49
- private final ReactApplicationContext appContext;
50
- private MapMarkerManager markerManager;
51
-
52
- protected GoogleMapOptions googleMapOptions;
53
-
54
- public MapManager(ReactApplicationContext context) {
55
- this.appContext = context;
56
- this.googleMapOptions = new GoogleMapOptions();
57
- }
58
-
59
- public MapMarkerManager getMarkerManager() {
60
- return this.markerManager;
61
- }
62
- public void setMarkerManager(MapMarkerManager markerManager) {
63
- this.markerManager = markerManager;
64
- }
65
-
66
- @Override
67
- public String getName() {
68
- return REACT_CLASS;
69
- }
70
-
71
- @Override
72
- protected MapView createViewInstance(@NonNull ThemedReactContext context) {
73
- return new MapView(context, this.appContext, this, googleMapOptions);
74
- }
75
- @Override
76
- protected MapView createViewInstance(int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) {
77
- if (initialProps != null){
78
- if (initialProps.getString("googleMapId") != null) {
79
- googleMapOptions.mapId(initialProps.getString("googleMapId"));
80
- }
81
- if (initialProps.hasKey("liteMode")) {
82
- googleMapOptions.liteMode(initialProps.getBoolean("liteMode", false));
83
- }
84
- }
85
- return super.createViewInstance(reactTag, reactContext, initialProps, stateWrapper);
86
- }
87
-
88
- private void emitMapError(ThemedReactContext context, String message, String type) {
89
- WritableMap error = Arguments.createMap();
90
- error.putString("message", message);
91
- error.putString("type", type);
92
-
93
- context
94
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
95
- .emit("onError", error);
96
- }
97
-
98
- @ReactProp(name = "region")
99
- public void setRegion(MapView view, ReadableMap region) {
100
- view.setRegion(region);
101
- }
102
-
103
- @ReactProp(name = "liteMode", defaultBoolean = false)
104
- public void setLiteMode(MapView view, boolean liteMode) {
105
- googleMapOptions.liteMode(liteMode);
106
- }
107
-
108
- @ReactProp(name = "googleMapId")
109
- public void setGoogleMapId(MapView view, @Nullable String googleMapId) {
110
- if (googleMapId != null) {
111
- googleMapOptions.mapId(googleMapId);
112
- }
113
- }
114
-
115
- @ReactProp(name = "initialRegion")
116
- public void setInitialRegion(MapView view, ReadableMap initialRegion) {
117
- view.setInitialRegion(initialRegion);
118
- }
119
-
120
- @ReactProp(name = "camera")
121
- public void setCamera(MapView view, ReadableMap camera) {
122
- view.setCamera(camera);
123
- }
124
-
125
- @ReactProp(name = "initialCamera")
126
- public void setInitialCamera(MapView view, ReadableMap initialCamera) {
127
- view.setInitialCamera(initialCamera);
128
- }
129
-
130
- @ReactProp(name = "mapType")
131
- public void setMapType(MapView view, @Nullable String mapType) {
132
- int typeId = MAP_TYPES.get(mapType);
133
- view.map.setMapType(typeId);
134
- }
135
-
136
- @ReactProp(name = "customMapStyleString")
137
- public void setMapStyle(MapView view, @Nullable String customMapStyleString) {
138
- view.setMapStyle(customMapStyleString);
139
- }
140
-
141
- @ReactProp(name = "mapPadding")
142
- public void setMapPadding(MapView view, @Nullable ReadableMap padding) {
143
- int left = 0;
144
- int top = 0;
145
- int right = 0;
146
- int bottom = 0;
147
- double density = (double) view.getResources().getDisplayMetrics().density;
148
-
149
- if (padding != null) {
150
- if (padding.hasKey("left")) {
151
- left = (int) (padding.getDouble("left") * density);
152
- }
153
-
154
- if (padding.hasKey("top")) {
155
- top = (int) (padding.getDouble("top") * density);
156
- }
157
-
158
- if (padding.hasKey("right")) {
159
- right = (int) (padding.getDouble("right") * density);
160
- }
161
-
162
- if (padding.hasKey("bottom")) {
163
- bottom = (int) (padding.getDouble("bottom") * density);
164
- }
165
- }
166
-
167
- view.applyBaseMapPadding(left, top, right, bottom);
168
- view.map.setPadding(left, top, right, bottom);
169
- }
170
-
171
- @ReactProp(name = "showsUserLocation", defaultBoolean = false)
172
- public void setShowsUserLocation(MapView view, boolean showUserLocation) {
173
- view.setShowsUserLocation(showUserLocation);
174
- }
175
-
176
- @ReactProp(name = "userLocationPriority")
177
- public void setUserLocationPriority(MapView view, @Nullable String accuracy) {
178
- view.setUserLocationPriority(MY_LOCATION_PRIORITY.get(accuracy));
179
- }
180
-
181
- @ReactProp(name = "userLocationUpdateInterval", defaultInt = 5000)
182
- public void setUserLocationUpdateInterval(MapView view, int updateInterval) {
183
- view.setUserLocationUpdateInterval(updateInterval);
184
- }
185
-
186
- @ReactProp(name = "userLocationFastestInterval", defaultInt = 5000)
187
- public void setUserLocationFastestInterval(MapView view, int fastestInterval) {
188
- view.setUserLocationFastestInterval(fastestInterval);
189
- }
190
-
191
- @ReactProp(name = "showsMyLocationButton", defaultBoolean = true)
192
- public void setShowsMyLocationButton(MapView view, boolean showMyLocationButton) {
193
- view.setShowsMyLocationButton(showMyLocationButton);
194
- }
195
-
196
- @ReactProp(name = "toolbarEnabled", defaultBoolean = true)
197
- public void setToolbarEnabled(MapView view, boolean toolbarEnabled) {
198
- view.setToolbarEnabled(toolbarEnabled);
199
- }
200
-
201
- // This is a private prop to improve performance of panDrag by disabling it when the callback
202
- // is not set
203
- @ReactProp(name = "handlePanDrag", defaultBoolean = false)
204
- public void setHandlePanDrag(MapView view, boolean handlePanDrag) {
205
- view.setHandlePanDrag(handlePanDrag);
206
- }
207
-
208
- @ReactProp(name = "showsTraffic", defaultBoolean = false)
209
- public void setShowTraffic(MapView view, boolean showTraffic) {
210
- view.map.setTrafficEnabled(showTraffic);
211
- }
212
-
213
- @ReactProp(name = "showsBuildings", defaultBoolean = false)
214
- public void setShowBuildings(MapView view, boolean showBuildings) {
215
- view.map.setBuildingsEnabled(showBuildings);
216
- }
217
-
218
- @ReactProp(name = "showsIndoors", defaultBoolean = false)
219
- public void setShowIndoors(MapView view, boolean showIndoors) {
220
- view.map.setIndoorEnabled(showIndoors);
221
- }
222
-
223
- @ReactProp(name = "showsIndoorLevelPicker", defaultBoolean = false)
224
- public void setShowsIndoorLevelPicker(MapView view, boolean showsIndoorLevelPicker) {
225
- view.map.getUiSettings().setIndoorLevelPickerEnabled(showsIndoorLevelPicker);
226
- }
227
-
228
- @ReactProp(name = "showsCompass", defaultBoolean = false)
229
- public void setShowsCompass(MapView view, boolean showsCompass) {
230
- view.map.getUiSettings().setCompassEnabled(showsCompass);
231
- }
232
-
233
- @ReactProp(name = "scrollEnabled", defaultBoolean = false)
234
- public void setScrollEnabled(MapView view, boolean scrollEnabled) {
235
- view.map.getUiSettings().setScrollGesturesEnabled(scrollEnabled);
236
- }
237
-
238
- @ReactProp(name = "zoomEnabled", defaultBoolean = false)
239
- public void setZoomEnabled(MapView view, boolean zoomEnabled) {
240
- view.map.getUiSettings().setZoomGesturesEnabled(zoomEnabled);
241
- }
242
-
243
- @ReactProp(name = "zoomControlEnabled", defaultBoolean = true)
244
- public void setZoomControlEnabled(MapView view, boolean zoomControlEnabled) {
245
- view.map.getUiSettings().setZoomControlsEnabled(zoomControlEnabled);
246
- }
247
-
248
- @ReactProp(name = "rotateEnabled", defaultBoolean = false)
249
- public void setRotateEnabled(MapView view, boolean rotateEnabled) {
250
- view.map.getUiSettings().setRotateGesturesEnabled(rotateEnabled);
251
- }
252
-
253
- @ReactProp(name = "scrollDuringRotateOrZoomEnabled", defaultBoolean = true)
254
- public void setScrollDuringRotateOrZoomEnabled(MapView view, boolean scrollDuringRotateOrZoomEnabled) {
255
- view.map.getUiSettings().setScrollGesturesEnabledDuringRotateOrZoom(scrollDuringRotateOrZoomEnabled);
256
- }
257
-
258
- @ReactProp(name = "cacheEnabled", defaultBoolean = false)
259
- public void setCacheEnabled(MapView view, boolean cacheEnabled) {
260
- view.setCacheEnabled(cacheEnabled);
261
- }
262
-
263
- @ReactProp(name = "loadingEnabled", defaultBoolean = false)
264
- public void setLoadingEnabled(MapView view, boolean loadingEnabled) {
265
- view.enableMapLoading(loadingEnabled);
266
- }
267
-
268
- @ReactProp(name = "moveOnMarkerPress", defaultBoolean = true)
269
- public void setMoveOnMarkerPress(MapView view, boolean moveOnPress) {
270
- view.setMoveOnMarkerPress(moveOnPress);
271
- }
272
-
273
- @ReactProp(name = "loadingBackgroundColor", customType = "Color")
274
- public void setLoadingBackgroundColor(MapView view, @Nullable Integer loadingBackgroundColor) {
275
- view.setLoadingBackgroundColor(loadingBackgroundColor);
276
- }
277
-
278
- @ReactProp(name = "loadingIndicatorColor", customType = "Color")
279
- public void setLoadingIndicatorColor(MapView view, @Nullable Integer loadingIndicatorColor) {
280
- view.setLoadingIndicatorColor(loadingIndicatorColor);
281
- }
282
-
283
- @ReactProp(name = "pitchEnabled", defaultBoolean = false)
284
- public void setPitchEnabled(MapView view, boolean pitchEnabled) {
285
- view.map.getUiSettings().setTiltGesturesEnabled(pitchEnabled);
286
- }
287
-
288
- @ReactProp(name = "minZoomLevel")
289
- public void setMinZoomLevel(MapView view, float minZoomLevel) {
290
- view.map.setMinZoomPreference(minZoomLevel);
291
- }
292
-
293
- @ReactProp(name = "maxZoomLevel")
294
- public void setMaxZoomLevel(MapView view, float maxZoomLevel) {
295
- view.map.setMaxZoomPreference(maxZoomLevel);
296
- }
297
-
298
- @ReactProp(name = "kmlSrc")
299
- public void setKmlSrc(MapView view, String kmlUrl) {
300
- if (kmlUrl != null) {
301
- view.setKmlSrc(kmlUrl);
302
- }
303
- }
304
-
305
- @Override
306
- public void receiveCommand(@NonNull MapView view, String commandId, @Nullable ReadableArray args) {
307
- int duration;
308
- double lat;
309
- double lng;
310
- double lngDelta;
311
- double latDelta;
312
- ReadableMap region;
313
- ReadableMap camera;
314
-
315
- switch (commandId) {
316
- case "setCamera":
317
- if(args == null) {
318
- break;
319
- }
320
- camera = args.getMap(0);
321
- view.animateToCamera(camera, 0);
322
- break;
34
+ private static final String REACT_CLASS = "AIRMap";
323
35
 
324
- case "animateCamera":
325
- if(args == null) {
326
- break;
327
- }
328
- camera = args.getMap(0);
329
- duration = args.getInt(1);
330
- view.animateToCamera(camera, duration);
331
- break;
332
-
333
- case "animateToRegion":
334
- if(args == null) {
335
- break;
336
- }
337
- region = args.getMap(0);
338
- duration = args.getInt(1);
339
- lng = region.getDouble("longitude");
340
- lat = region.getDouble("latitude");
341
- lngDelta = region.getDouble("longitudeDelta");
342
- latDelta = region.getDouble("latitudeDelta");
343
- LatLngBounds bounds = new LatLngBounds(
344
- new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
345
- new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
346
- );
347
- view.animateToRegion(bounds, duration);
348
- break;
36
+ private final Map<String, Integer> MAP_TYPES = MapBuilder.of(
37
+ "standard", GoogleMap.MAP_TYPE_NORMAL,
38
+ "satellite", GoogleMap.MAP_TYPE_SATELLITE,
39
+ "hybrid", GoogleMap.MAP_TYPE_HYBRID,
40
+ "terrain", GoogleMap.MAP_TYPE_TERRAIN,
41
+ "none", GoogleMap.MAP_TYPE_NONE
42
+ );
43
+
44
+ private final Map<String, Integer> MY_LOCATION_PRIORITY = MapBuilder.of(
45
+ "balanced", Priority.PRIORITY_BALANCED_POWER_ACCURACY,
46
+ "high", Priority.PRIORITY_HIGH_ACCURACY,
47
+ "low", Priority.PRIORITY_LOW_POWER,
48
+ "passive", Priority.PRIORITY_PASSIVE
49
+ );
50
+
51
+ private final ReactApplicationContext appContext;
52
+ private MapMarkerManager markerManager;
349
53
 
350
- case "fitToElements":
351
- if(args == null) {
352
- break;
54
+ protected GoogleMapOptions googleMapOptions;
55
+
56
+ protected MapsInitializer.Renderer renderer;
57
+
58
+ public MapManager(ReactApplicationContext context) {
59
+ this.appContext = context;
60
+ this.googleMapOptions = new GoogleMapOptions();
61
+ }
62
+
63
+ public MapMarkerManager getMarkerManager() {
64
+ return this.markerManager;
65
+ }
66
+
67
+ public void setMarkerManager(MapMarkerManager markerManager) {
68
+ this.markerManager = markerManager;
69
+ }
70
+
71
+ @Override
72
+ public String getName() {
73
+ return REACT_CLASS;
74
+ }
75
+
76
+ @Override
77
+ protected MapView createViewInstance(@NonNull ThemedReactContext context) {
78
+ return new MapView(context, this.appContext, this, googleMapOptions);
79
+ }
80
+
81
+ @Override
82
+ protected MapView createViewInstance(int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) {
83
+ if (initialProps != null) {
84
+ if (initialProps.getString("googleMapId") != null) {
85
+ googleMapOptions.mapId(initialProps.getString("googleMapId"));
86
+ }
87
+ if (initialProps.hasKey("liteMode")) {
88
+ googleMapOptions.liteMode(initialProps.getBoolean("liteMode", false));
89
+ }
90
+ if (initialProps.hasKey("initialCamera")) {
91
+ CameraPosition position = MapView.cameraPositionFromMap(initialProps.getMap("initialCamera"));
92
+ if (position != null) {
93
+ googleMapOptions.camera(position);
94
+ }
95
+ } else if (initialProps.hasKey("camera")) {
96
+ CameraPosition position = MapView.cameraPositionFromMap(initialProps.getMap("camera"));
97
+ if (position != null) {
98
+ googleMapOptions.camera(position);
99
+ }
100
+ }
101
+ if (initialProps.hasKey("googleRenderer") && "LEGACY".equals(initialProps.getString("googleRenderer"))) {
102
+ renderer = MapsInitializer.Renderer.LEGACY;
103
+ } else {
104
+ renderer = MapsInitializer.Renderer.LATEST;
105
+ }
353
106
  }
354
- view.fitToElements(args.getMap(0), args.getBoolean(1));
355
- break;
107
+ return super.createViewInstance(reactTag, reactContext, initialProps, stateWrapper);
108
+ }
109
+
110
+ private void emitMapError(ThemedReactContext context, String message, String type) {
111
+ WritableMap error = Arguments.createMap();
112
+ error.putString("message", message);
113
+ error.putString("type", type);
114
+
115
+ context
116
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
117
+ .emit("onError", error);
118
+ }
119
+
120
+ @ReactProp(name = "region")
121
+ public void setRegion(MapView view, ReadableMap region) {
122
+ view.setRegion(region);
123
+ }
124
+
125
+ @ReactProp(name = "googleRenderer")
126
+ public void setGoogleRenderer(MapView view, @Nullable String googleRenderer) {
127
+ // do nothing, passed as part of the InitialProps
128
+ }
129
+
130
+ @ReactProp(name = "liteMode", defaultBoolean = false)
131
+ public void setLiteMode(MapView view, boolean liteMode) {
132
+ googleMapOptions.liteMode(liteMode);
133
+ }
356
134
 
357
- case "fitToSuppliedMarkers":
358
- if(args == null) {
359
- break;
135
+ @ReactProp(name = "googleMapId")
136
+ public void setGoogleMapId(MapView view, @Nullable String googleMapId) {
137
+ if (googleMapId != null) {
138
+ googleMapOptions.mapId(googleMapId);
360
139
  }
361
- view.fitToSuppliedMarkers(args.getArray(0), args.getMap(1), args.getBoolean(2));
362
- break;
140
+ }
141
+
142
+ @ReactProp(name = "initialRegion")
143
+ public void setInitialRegion(MapView view, ReadableMap initialRegion) {
144
+ view.setInitialRegion(initialRegion);
145
+ }
146
+
147
+ @ReactProp(name = "camera")
148
+ public void setCamera(MapView view, ReadableMap camera) {
149
+ view.setCamera(camera);
150
+ }
151
+
152
+ @ReactProp(name = "initialCamera")
153
+ public void setInitialCamera(MapView view, ReadableMap initialCamera) {
154
+ // do nothing, passed as part of the InitialProps
155
+ }
363
156
 
364
- case "fitToCoordinates":
365
- if(args == null) {
366
- break;
157
+ @ReactProp(name = "mapType")
158
+ public void setMapType(MapView view, @Nullable String mapType) {
159
+ int typeId = MAP_TYPES.get(mapType);
160
+ view.map.setMapType(typeId);
161
+ }
162
+
163
+ @ReactProp(name = "customMapStyleString")
164
+ public void setMapStyle(MapView view, @Nullable String customMapStyleString) {
165
+ view.setMapStyle(customMapStyleString);
166
+ }
167
+
168
+ @ReactProp(name = "mapPadding")
169
+ public void setMapPadding(MapView view, @Nullable ReadableMap padding) {
170
+ int left = 0;
171
+ int top = 0;
172
+ int right = 0;
173
+ int bottom = 0;
174
+ double density = (double) view.getResources().getDisplayMetrics().density;
175
+
176
+ if (padding != null) {
177
+ if (padding.hasKey("left")) {
178
+ left = (int) (padding.getDouble("left") * density);
179
+ }
180
+
181
+ if (padding.hasKey("top")) {
182
+ top = (int) (padding.getDouble("top") * density);
183
+ }
184
+
185
+ if (padding.hasKey("right")) {
186
+ right = (int) (padding.getDouble("right") * density);
187
+ }
188
+
189
+ if (padding.hasKey("bottom")) {
190
+ bottom = (int) (padding.getDouble("bottom") * density);
191
+ }
367
192
  }
368
- view.fitToCoordinates(args.getArray(0), args.getMap(1), args.getBoolean(2));
369
- break;
370
193
 
371
- case "setMapBoundaries":
372
- if(args == null) {
373
- break;
194
+ view.applyBaseMapPadding(left, top, right, bottom);
195
+ view.map.setPadding(left, top, right, bottom);
196
+ }
197
+
198
+ @ReactProp(name = "showsUserLocation", defaultBoolean = false)
199
+ public void setShowsUserLocation(MapView view, boolean showUserLocation) {
200
+ view.setShowsUserLocation(showUserLocation);
201
+ }
202
+
203
+ @ReactProp(name = "userLocationPriority")
204
+ public void setUserLocationPriority(MapView view, @Nullable String accuracy) {
205
+ view.setUserLocationPriority(MY_LOCATION_PRIORITY.get(accuracy));
206
+ }
207
+
208
+ @ReactProp(name = "userLocationUpdateInterval", defaultInt = 5000)
209
+ public void setUserLocationUpdateInterval(MapView view, int updateInterval) {
210
+ view.setUserLocationUpdateInterval(updateInterval);
211
+ }
212
+
213
+ @ReactProp(name = "userLocationFastestInterval", defaultInt = 5000)
214
+ public void setUserLocationFastestInterval(MapView view, int fastestInterval) {
215
+ view.setUserLocationFastestInterval(fastestInterval);
216
+ }
217
+
218
+ @ReactProp(name = "showsMyLocationButton", defaultBoolean = true)
219
+ public void setShowsMyLocationButton(MapView view, boolean showMyLocationButton) {
220
+ view.setShowsMyLocationButton(showMyLocationButton);
221
+ }
222
+
223
+ @ReactProp(name = "toolbarEnabled", defaultBoolean = true)
224
+ public void setToolbarEnabled(MapView view, boolean toolbarEnabled) {
225
+ view.setToolbarEnabled(toolbarEnabled);
226
+ }
227
+
228
+ // This is a private prop to improve performance of panDrag by disabling it when the callback
229
+ // is not set
230
+ @ReactProp(name = "handlePanDrag", defaultBoolean = false)
231
+ public void setHandlePanDrag(MapView view, boolean handlePanDrag) {
232
+ view.setHandlePanDrag(handlePanDrag);
233
+ }
234
+
235
+ @ReactProp(name = "showsTraffic", defaultBoolean = false)
236
+ public void setShowTraffic(MapView view, boolean showTraffic) {
237
+ view.map.setTrafficEnabled(showTraffic);
238
+ }
239
+
240
+ @ReactProp(name = "showsBuildings", defaultBoolean = false)
241
+ public void setShowBuildings(MapView view, boolean showBuildings) {
242
+ view.map.setBuildingsEnabled(showBuildings);
243
+ }
244
+
245
+ @ReactProp(name = "showsIndoors", defaultBoolean = false)
246
+ public void setShowIndoors(MapView view, boolean showIndoors) {
247
+ view.map.setIndoorEnabled(showIndoors);
248
+ }
249
+
250
+ @ReactProp(name = "showsIndoorLevelPicker", defaultBoolean = false)
251
+ public void setShowsIndoorLevelPicker(MapView view, boolean showsIndoorLevelPicker) {
252
+ view.map.getUiSettings().setIndoorLevelPickerEnabled(showsIndoorLevelPicker);
253
+ }
254
+
255
+ @ReactProp(name = "showsCompass", defaultBoolean = false)
256
+ public void setShowsCompass(MapView view, boolean showsCompass) {
257
+ view.map.getUiSettings().setCompassEnabled(showsCompass);
258
+ }
259
+
260
+ @ReactProp(name = "scrollEnabled", defaultBoolean = false)
261
+ public void setScrollEnabled(MapView view, boolean scrollEnabled) {
262
+ view.map.getUiSettings().setScrollGesturesEnabled(scrollEnabled);
263
+ }
264
+
265
+ @ReactProp(name = "zoomEnabled", defaultBoolean = false)
266
+ public void setZoomEnabled(MapView view, boolean zoomEnabled) {
267
+ view.map.getUiSettings().setZoomGesturesEnabled(zoomEnabled);
268
+ }
269
+
270
+ @ReactProp(name = "zoomControlEnabled", defaultBoolean = true)
271
+ public void setZoomControlEnabled(MapView view, boolean zoomControlEnabled) {
272
+ view.map.getUiSettings().setZoomControlsEnabled(zoomControlEnabled);
273
+ }
274
+
275
+ @ReactProp(name = "rotateEnabled", defaultBoolean = false)
276
+ public void setRotateEnabled(MapView view, boolean rotateEnabled) {
277
+ view.map.getUiSettings().setRotateGesturesEnabled(rotateEnabled);
278
+ }
279
+
280
+ @ReactProp(name = "scrollDuringRotateOrZoomEnabled", defaultBoolean = true)
281
+ public void setScrollDuringRotateOrZoomEnabled(MapView view, boolean scrollDuringRotateOrZoomEnabled) {
282
+ view.map.getUiSettings().setScrollGesturesEnabledDuringRotateOrZoom(scrollDuringRotateOrZoomEnabled);
283
+ }
284
+
285
+ @ReactProp(name = "cacheEnabled", defaultBoolean = false)
286
+ public void setCacheEnabled(MapView view, boolean cacheEnabled) {
287
+ view.setCacheEnabled(cacheEnabled);
288
+ }
289
+
290
+ @ReactProp(name = "loadingEnabled", defaultBoolean = false)
291
+ public void setLoadingEnabled(MapView view, boolean loadingEnabled) {
292
+ view.enableMapLoading(loadingEnabled);
293
+ }
294
+
295
+ @ReactProp(name = "moveOnMarkerPress", defaultBoolean = true)
296
+ public void setMoveOnMarkerPress(MapView view, boolean moveOnPress) {
297
+ view.setMoveOnMarkerPress(moveOnPress);
298
+ }
299
+
300
+ @ReactProp(name = "loadingBackgroundColor", customType = "Color")
301
+ public void setLoadingBackgroundColor(MapView view, @Nullable Integer loadingBackgroundColor) {
302
+ view.setLoadingBackgroundColor(loadingBackgroundColor);
303
+ }
304
+
305
+ @ReactProp(name = "loadingIndicatorColor", customType = "Color")
306
+ public void setLoadingIndicatorColor(MapView view, @Nullable Integer loadingIndicatorColor) {
307
+ view.setLoadingIndicatorColor(loadingIndicatorColor);
308
+ }
309
+
310
+ @ReactProp(name = "pitchEnabled", defaultBoolean = false)
311
+ public void setPitchEnabled(MapView view, boolean pitchEnabled) {
312
+ view.map.getUiSettings().setTiltGesturesEnabled(pitchEnabled);
313
+ }
314
+
315
+ @ReactProp(name = "minZoomLevel")
316
+ public void setMinZoomLevel(MapView view, float minZoomLevel) {
317
+ view.map.setMinZoomPreference(minZoomLevel);
318
+ }
319
+
320
+ @ReactProp(name = "maxZoomLevel")
321
+ public void setMaxZoomLevel(MapView view, float maxZoomLevel) {
322
+ view.map.setMaxZoomPreference(maxZoomLevel);
323
+ }
324
+
325
+ @ReactProp(name = "kmlSrc")
326
+ public void setKmlSrc(MapView view, String kmlUrl) {
327
+ if (kmlUrl != null) {
328
+ view.setKmlSrc(kmlUrl);
374
329
  }
375
- view.setMapBoundaries(args.getMap(0), args.getMap(1));
376
- break;
330
+ }
377
331
 
378
- case "setIndoorActiveLevelIndex":
379
- if(args == null) {
380
- break;
332
+ @Override
333
+ public void receiveCommand(@NonNull MapView view, String commandId, @Nullable ReadableArray args) {
334
+ int duration;
335
+ double lat;
336
+ double lng;
337
+ double lngDelta;
338
+ double latDelta;
339
+ ReadableMap region;
340
+ ReadableMap camera;
341
+
342
+ switch (commandId) {
343
+ case "setCamera":
344
+ if (args == null) {
345
+ break;
346
+ }
347
+ camera = args.getMap(0);
348
+ view.animateToCamera(camera, 0);
349
+ break;
350
+
351
+ case "animateCamera":
352
+ if (args == null) {
353
+ break;
354
+ }
355
+ camera = args.getMap(0);
356
+ duration = args.getInt(1);
357
+ view.animateToCamera(camera, duration);
358
+ break;
359
+
360
+ case "animateToRegion":
361
+ if (args == null) {
362
+ break;
363
+ }
364
+ region = args.getMap(0);
365
+ duration = args.getInt(1);
366
+ lng = region.getDouble("longitude");
367
+ lat = region.getDouble("latitude");
368
+ lngDelta = region.getDouble("longitudeDelta");
369
+ latDelta = region.getDouble("latitudeDelta");
370
+ LatLngBounds bounds = new LatLngBounds(
371
+ new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
372
+ new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
373
+ );
374
+ view.animateToRegion(bounds, duration);
375
+ break;
376
+
377
+ case "fitToElements":
378
+ if (args == null) {
379
+ break;
380
+ }
381
+ view.fitToElements(args.getMap(0), args.getBoolean(1));
382
+ break;
383
+
384
+ case "fitToSuppliedMarkers":
385
+ if (args == null) {
386
+ break;
387
+ }
388
+ view.fitToSuppliedMarkers(args.getArray(0), args.getMap(1), args.getBoolean(2));
389
+ break;
390
+
391
+ case "fitToCoordinates":
392
+ if (args == null) {
393
+ break;
394
+ }
395
+ view.fitToCoordinates(args.getArray(0), args.getMap(1), args.getBoolean(2));
396
+ break;
397
+
398
+ case "setMapBoundaries":
399
+ if (args == null) {
400
+ break;
401
+ }
402
+ view.setMapBoundaries(args.getMap(0), args.getMap(1));
403
+ break;
404
+
405
+ case "setIndoorActiveLevelIndex":
406
+ if (args == null) {
407
+ break;
408
+ }
409
+ view.setIndoorActiveLevelIndex(args.getInt(0));
410
+ break;
381
411
  }
382
- view.setIndoorActiveLevelIndex(args.getInt(0));
383
- break;
384
- }
385
- }
386
-
387
- @Override
388
- @Nullable
389
- public Map getExportedCustomDirectEventTypeConstants() {
390
- Map<String, Map<String, String>> map = MapBuilder.of(
391
- "onMapReady", MapBuilder.of("registrationName", "onMapReady"),
392
- "onPress", MapBuilder.of("registrationName", "onPress"),
393
- "onLongPress", MapBuilder.of("registrationName", "onLongPress"),
394
- "onMarkerPress", MapBuilder.of("registrationName", "onMarkerPress"),
395
- "onCalloutPress", MapBuilder.of("registrationName", "onCalloutPress")
396
- );
412
+ }
413
+
414
+ @Override
415
+ @Nullable
416
+ public Map getExportedCustomDirectEventTypeConstants() {
417
+ Map<String, Map<String, String>> map = MapBuilder.of(
418
+ "onMapReady", MapBuilder.of("registrationName", "onMapReady"),
419
+ "onPress", MapBuilder.of("registrationName", "onPress"),
420
+ "onLongPress", MapBuilder.of("registrationName", "onLongPress"),
421
+ "onMarkerPress", MapBuilder.of("registrationName", "onMarkerPress"),
422
+ "onCalloutPress", MapBuilder.of("registrationName", "onCalloutPress")
423
+ );
424
+
425
+ map.putAll(MapBuilder.of(
426
+ "onUserLocationChange", MapBuilder.of("registrationName", "onUserLocationChange"),
427
+ "onMarkerDragStart", MapBuilder.of("registrationName", "onMarkerDragStart"),
428
+ "onMarkerDrag", MapBuilder.of("registrationName", "onMarkerDrag"),
429
+ "onMarkerDragEnd", MapBuilder.of("registrationName", "onMarkerDragEnd"),
430
+ "onPanDrag", MapBuilder.of("registrationName", "onPanDrag"),
431
+ "onKmlReady", MapBuilder.of("registrationName", "onKmlReady"),
432
+ "onPoiClick", MapBuilder.of("registrationName", "onPoiClick")
433
+ ));
434
+
435
+ map.putAll(MapBuilder.of(
436
+ "onIndoorLevelActivated", MapBuilder.of("registrationName", "onIndoorLevelActivated"),
437
+ "onIndoorBuildingFocused", MapBuilder.of("registrationName", "onIndoorBuildingFocused"),
438
+ "onDoublePress", MapBuilder.of("registrationName", "onDoublePress"),
439
+ "onMapLoaded", MapBuilder.of("registrationName", "onMapLoaded"),
440
+ "onMarkerSelect", MapBuilder.of("registrationName", "onMarkerSelect"),
441
+ "onMarkerDeselect", MapBuilder.of("registrationName", "onMarkerDeselect")
442
+ ));
443
+
444
+ return map;
445
+ }
446
+
447
+ @Override
448
+ public LayoutShadowNode createShadowNodeInstance() {
449
+ // A custom shadow node is needed in order to pass back the width/height of the map to the
450
+ // view manager so that it can start applying camera moves with bounds.
451
+ return new SizeReportingShadowNode();
452
+ }
453
+
454
+ @Override
455
+ public void addView(MapView parent, View child, int index) {
456
+ parent.addFeature(child, index);
457
+ }
458
+
459
+ @Override
460
+ public int getChildCount(MapView view) {
461
+ return view.getFeatureCount();
462
+ }
463
+
464
+ @Override
465
+ public View getChildAt(MapView view, int index) {
466
+ return view.getFeatureAt(index);
467
+ }
397
468
 
398
- map.putAll(MapBuilder.of(
399
- "onUserLocationChange", MapBuilder.of("registrationName", "onUserLocationChange"),
400
- "onMarkerDragStart", MapBuilder.of("registrationName", "onMarkerDragStart"),
401
- "onMarkerDrag", MapBuilder.of("registrationName", "onMarkerDrag"),
402
- "onMarkerDragEnd", MapBuilder.of("registrationName", "onMarkerDragEnd"),
403
- "onPanDrag", MapBuilder.of("registrationName", "onPanDrag"),
404
- "onKmlReady", MapBuilder.of("registrationName", "onKmlReady"),
405
- "onPoiClick", MapBuilder.of("registrationName", "onPoiClick")
406
- ));
407
-
408
- map.putAll(MapBuilder.of(
409
- "onIndoorLevelActivated", MapBuilder.of("registrationName", "onIndoorLevelActivated"),
410
- "onIndoorBuildingFocused", MapBuilder.of("registrationName", "onIndoorBuildingFocused"),
411
- "onDoublePress", MapBuilder.of("registrationName", "onDoublePress"),
412
- "onMapLoaded", MapBuilder.of("registrationName", "onMapLoaded"),
413
- "onMarkerSelect", MapBuilder.of("registrationName", "onMarkerSelect"),
414
- "onMarkerDeselect", MapBuilder.of("registrationName", "onMarkerDeselect")
415
- ));
416
-
417
- return map;
418
- }
419
-
420
- @Override
421
- public LayoutShadowNode createShadowNodeInstance() {
422
- // A custom shadow node is needed in order to pass back the width/height of the map to the
423
- // view manager so that it can start applying camera moves with bounds.
424
- return new SizeReportingShadowNode();
425
- }
426
-
427
- @Override
428
- public void addView(MapView parent, View child, int index) {
429
- parent.addFeature(child, index);
430
- }
431
-
432
- @Override
433
- public int getChildCount(MapView view) {
434
- return view.getFeatureCount();
435
- }
436
-
437
- @Override
438
- public View getChildAt(MapView view, int index) {
439
- return view.getFeatureAt(index);
440
- }
441
-
442
- @Override
443
- public void removeViewAt(MapView parent, int index) {
444
- parent.removeFeatureAt(index);
445
- }
446
-
447
- @Override
448
- public void updateExtraData(MapView view, Object extraData) {
449
- view.updateExtraData(extraData);
450
- }
451
-
452
- void pushEvent(ThemedReactContext context, View view, String name, WritableMap data) {
453
- context
454
- .getReactApplicationContext()
455
- .getJSModule(RCTEventEmitter.class)
456
- .receiveEvent(view.getId(), name, data);
457
- }
458
-
459
- @Override
460
- public void onDropViewInstance(MapView view) {
461
- view.doDestroy();
462
- super.onDropViewInstance(view);
463
- }
469
+ @Override
470
+ public void removeViewAt(MapView parent, int index) {
471
+ parent.removeFeatureAt(index);
472
+ }
473
+
474
+ @Override
475
+ public void updateExtraData(MapView view, Object extraData) {
476
+ view.updateExtraData(extraData);
477
+ }
478
+
479
+ void pushEvent(ThemedReactContext context, View view, String name, WritableMap data) {
480
+ context
481
+ .getReactApplicationContext()
482
+ .getJSModule(RCTEventEmitter.class)
483
+ .receiveEvent(view.getId(), name, data);
484
+ }
485
+
486
+ @Override
487
+ public void onDropViewInstance(MapView view) {
488
+ view.doDestroy();
489
+ super.onDropViewInstance(view);
490
+ }
464
491
 
465
492
  }
@@ -8,10 +8,8 @@ import android.location.Geocoder;
8
8
  import android.net.Uri;
9
9
  import android.util.Base64;
10
10
  import android.util.DisplayMetrics;
11
- import android.util.Log;
12
11
 
13
12
  import androidx.annotation.Nullable;
14
- import androidx.annotation.NonNull;
15
13
 
16
14
  import com.facebook.react.bridge.Promise;
17
15
  import com.facebook.react.bridge.ReactApplicationContext;
@@ -25,8 +23,6 @@ import com.facebook.react.uimanager.NativeViewHierarchyManager;
25
23
  import com.facebook.react.uimanager.UIBlock;
26
24
  import com.facebook.react.uimanager.UIManagerModule;
27
25
  import com.google.android.gms.maps.GoogleMap;
28
- import com.google.android.gms.maps.MapsInitializer;
29
- import com.google.android.gms.maps.OnMapsSdkInitializedCallback;
30
26
  import com.google.android.gms.maps.model.CameraPosition;
31
27
  import com.google.android.gms.maps.model.LatLng;
32
28
 
@@ -35,10 +31,9 @@ import java.io.Closeable;
35
31
  import java.io.File;
36
32
  import java.io.FileOutputStream;
37
33
  import java.io.IOException;
38
-
34
+ import java.util.HashMap;
39
35
  import java.util.List;
40
36
  import java.util.Map;
41
- import java.util.HashMap;
42
37
 
43
38
  @ReactModule(name = MapModule.NAME)
44
39
  public class MapModule extends ReactContextBaseJavaModule {
@@ -356,25 +351,4 @@ public class MapModule extends ReactContextBaseJavaModule {
356
351
  }
357
352
  });
358
353
  }
359
-
360
- @ReactMethod
361
- public void enableLatestRenderer(final Promise promise) {
362
- final ReactApplicationContext context = getReactApplicationContext();
363
-
364
- UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
365
- uiManager.addUIBlock(new UIBlock()
366
- {
367
- @Override
368
- public void execute(NativeViewHierarchyManager nvhm)
369
- {
370
- MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, new OnMapsSdkInitializedCallback() {
371
- @Override
372
- public void onMapsSdkInitialized(@NonNull MapsInitializer.Renderer renderer) {
373
- Log.d("AirMapRenderer", renderer.toString());
374
- promise.resolve(renderer.toString());
375
- }
376
- });
377
- }
378
- });
379
- }
380
354
  }
@@ -1,16 +1,14 @@
1
1
  package com.rnmaps.maps;
2
2
 
3
+ import static androidx.core.content.PermissionChecker.checkSelfPermission;
4
+
3
5
  import android.content.Context;
4
6
  import android.content.res.ColorStateList;
5
7
  import android.graphics.Bitmap;
6
8
  import android.graphics.Color;
7
9
  import android.graphics.Point;
8
-
9
- import androidx.annotation.NonNull;
10
- import androidx.annotation.Nullable;
11
- import androidx.core.content.PermissionChecker;
12
- import androidx.core.view.GestureDetectorCompat;
13
- import androidx.core.view.MotionEventCompat;
10
+ import android.location.Location;
11
+ import android.util.Log;
14
12
  import android.view.GestureDetector;
15
13
  import android.view.MotionEvent;
16
14
  import android.view.View;
@@ -18,8 +16,14 @@ import android.view.ViewGroup;
18
16
  import android.widget.ImageView;
19
17
  import android.widget.ProgressBar;
20
18
  import android.widget.RelativeLayout;
21
- import android.location.Location;
22
19
 
20
+ import androidx.annotation.NonNull;
21
+ import androidx.annotation.Nullable;
22
+ import androidx.core.content.PermissionChecker;
23
+ import androidx.core.view.GestureDetectorCompat;
24
+ import androidx.core.view.MotionEventCompat;
25
+
26
+ import com.facebook.react.bridge.Arguments;
23
27
  import com.facebook.react.bridge.LifecycleEventListener;
24
28
  import com.facebook.react.bridge.ReactApplicationContext;
25
29
  import com.facebook.react.bridge.ReadableArray;
@@ -28,21 +32,22 @@ import com.facebook.react.bridge.WritableArray;
28
32
  import com.facebook.react.bridge.WritableMap;
29
33
  import com.facebook.react.bridge.WritableNativeArray;
30
34
  import com.facebook.react.bridge.WritableNativeMap;
31
- import com.facebook.react.bridge.Arguments;
32
35
  import com.facebook.react.uimanager.ThemedReactContext;
33
36
  import com.facebook.react.uimanager.UIManagerHelper;
34
- import com.facebook.react.uimanager.UIManagerModule;
35
37
  import com.facebook.react.uimanager.common.UIManagerType;
36
38
  import com.facebook.react.uimanager.events.EventDispatcher;
37
39
  import com.google.android.gms.maps.CameraUpdate;
38
40
  import com.google.android.gms.maps.CameraUpdateFactory;
39
41
  import com.google.android.gms.maps.GoogleMap;
40
42
  import com.google.android.gms.maps.GoogleMapOptions;
43
+ import com.google.android.gms.maps.MapsInitializer;
41
44
  import com.google.android.gms.maps.OnMapReadyCallback;
42
45
  import com.google.android.gms.maps.Projection;
43
46
  import com.google.android.gms.maps.model.BitmapDescriptorFactory;
44
47
  import com.google.android.gms.maps.model.CameraPosition;
45
48
  import com.google.android.gms.maps.model.GroundOverlay;
49
+ import com.google.android.gms.maps.model.IndoorBuilding;
50
+ import com.google.android.gms.maps.model.IndoorLevel;
46
51
  import com.google.android.gms.maps.model.LatLng;
47
52
  import com.google.android.gms.maps.model.LatLngBounds;
48
53
  import com.google.android.gms.maps.model.MapStyleOptions;
@@ -52,8 +57,6 @@ import com.google.android.gms.maps.model.PointOfInterest;
52
57
  import com.google.android.gms.maps.model.Polygon;
53
58
  import com.google.android.gms.maps.model.Polyline;
54
59
  import com.google.android.gms.maps.model.TileOverlay;
55
- import com.google.android.gms.maps.model.IndoorBuilding;
56
- import com.google.android.gms.maps.model.IndoorLevel;
57
60
  import com.google.maps.android.collections.CircleManager;
58
61
  import com.google.maps.android.collections.GroundOverlayManager;
59
62
  import com.google.maps.android.collections.MarkerManager;
@@ -75,8 +78,6 @@ import java.util.List;
75
78
  import java.util.Map;
76
79
  import java.util.concurrent.ExecutionException;
77
80
 
78
- import static androidx.core.content.PermissionChecker.checkSelfPermission;
79
-
80
81
  public class MapView extends com.google.android.gms.maps.MapView implements GoogleMap.InfoWindowAdapter,
81
82
  GoogleMap.OnMarkerDragListener, OnMapReadyCallback, GoogleMap.OnPoiClickListener, GoogleMap.OnIndoorStateChangeListener {
82
83
  public GoogleMap map;
@@ -104,12 +105,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
104
105
  private boolean moveOnMarkerPress = true;
105
106
  private boolean cacheEnabled = false;
106
107
  private ReadableMap initialRegion;
107
- private ReadableMap initialCamera;
108
108
  private ReadableMap region;
109
109
  private ReadableMap camera;
110
110
  private String customMapStyleString;
111
111
  private boolean initialRegionSet = false;
112
- private boolean initialCameraSet = false;
113
112
  private LatLngBounds cameraLastIdleBounds;
114
113
  private int cameraMoveReason = 0;
115
114
  private MapMarker selectedMarker;
@@ -173,9 +172,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
173
172
 
174
173
  this.manager = manager;
175
174
  this.context = reactContext;
176
-
175
+ MapsInitializer.initialize(context, this.manager.renderer, renderer -> Log.d("AirMapRenderer", renderer.toString()));
177
176
  super.onCreate(null);
178
- // TODO(lmr): what about onStart????
179
177
  super.onResume();
180
178
  super.getMapAsync(this);
181
179
 
@@ -538,23 +536,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
538
536
  }
539
537
  }
540
538
 
541
- public void setInitialCamera(ReadableMap initialCamera) {
542
- this.initialCamera = initialCamera;
543
- // Theoretically onMapReady might be called before setInitialCamera
544
- // In that case, trigger moveToCamera manually
545
- if (!initialCameraSet && map != null) {
546
- moveToCamera(initialCamera);
547
- initialCameraSet = true;
548
- }
549
- }
550
-
551
539
  private void applyBridgedProps() {
552
540
  if(initialRegion != null) {
553
541
  moveToRegion(initialRegion);
554
542
  initialRegionSet = true;
555
- } else if(initialCamera != null) {
556
- moveToCamera(initialCamera);
557
- initialCameraSet = true;
558
543
  } else if(region != null) {
559
544
  moveToRegion(region);
560
545
  } else {
@@ -602,24 +587,28 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
602
587
  moveToCamera(camera);
603
588
  }
604
589
  }
590
+ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
591
+ if (camera == null) return null;
605
592
 
606
- public void moveToCamera(ReadableMap camera) {
607
- if (camera == null) return;
608
-
609
- CameraPosition.Builder builder = new CameraPosition.Builder();
593
+ CameraPosition.Builder builder = new CameraPosition.Builder();
610
594
 
611
- ReadableMap center = camera.getMap("center");
612
- if (center != null) {
613
- double lng = center.getDouble("longitude");
614
- double lat = center.getDouble("latitude");
615
- builder.target(new LatLng(lat, lng));
616
- }
595
+ ReadableMap center = camera.getMap("center");
596
+ if (center != null) {
597
+ double lng = center.getDouble("longitude");
598
+ double lat = center.getDouble("latitude");
599
+ builder.target(new LatLng(lat, lng));
600
+ }
617
601
 
618
- builder.tilt((float)camera.getDouble("pitch"));
619
- builder.bearing((float)camera.getDouble("heading"));
620
- builder.zoom((float)camera.getDouble("zoom"));
602
+ builder.tilt((float)camera.getDouble("pitch"));
603
+ builder.bearing((float)camera.getDouble("heading"));
604
+ builder.zoom((float)camera.getDouble("zoom"));
621
605
 
622
- CameraUpdate update = CameraUpdateFactory.newCameraPosition(builder.build());
606
+ return builder.build();
607
+ }
608
+ public void moveToCamera(ReadableMap cameraMap) {
609
+ CameraPosition camera = cameraPositionFromMap(cameraMap);
610
+ if (camera == null) return;
611
+ CameraUpdate update = CameraUpdateFactory.newCameraPosition(camera);
623
612
 
624
613
  if (super.getHeight() <= 0 || super.getWidth() <= 0) {
625
614
  // in this case, our map has not been laid out yet, so we save the camera update in a
package/lib/MapView.d.ts CHANGED
@@ -101,6 +101,14 @@ export type MapViewProps = ViewProps & {
101
101
  * google cloud mapId to enable cloud styling and more
102
102
  */
103
103
  googleMapId?: string;
104
+ /**
105
+ * https://developers.google.com/maps/documentation/android-sdk/renderer
106
+ * google maps renderer
107
+ * @default `LATEST`
108
+ * @platform iOS: Not supported
109
+ * @platform Android: Supported
110
+ */
111
+ googleRenderer?: 'LATEST' | 'LEGACY';
104
112
  /**
105
113
  * Sets loading background color.
106
114
  *
@@ -682,5 +690,4 @@ declare class MapView extends React.Component<MapViewProps, State> {
682
690
  render(): React.JSX.Element;
683
691
  }
684
692
  export declare const AnimatedMapView: RNAnimated.AnimatedComponent<typeof MapView>;
685
- export declare const enableLatestRenderer: () => any;
686
693
  export default MapView;
package/lib/MapView.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.enableLatestRenderer = exports.AnimatedMapView = exports.MAP_TYPES = void 0;
26
+ exports.AnimatedMapView = exports.MAP_TYPES = void 0;
27
27
  const React = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
29
  const decorateMapComponent_1 = require("./decorateMapComponent");
@@ -308,6 +308,7 @@ class MapView extends React.Component {
308
308
  onMapReady: this._onMapReady,
309
309
  liteMode: this.props.liteMode,
310
310
  googleMapId: this.props.googleMapId,
311
+ googleRenderer: this.props.googleRenderer,
311
312
  ref: this.map,
312
313
  customMapStyleString: this.props.customMapStyle
313
314
  ? JSON.stringify(this.props.customMapStyle)
@@ -330,6 +331,7 @@ class MapView extends React.Component {
330
331
  region: null,
331
332
  liteMode: this.props.liteMode,
332
333
  googleMapId: this.props.googleMapId,
334
+ googleRenderer: this.props.googleRenderer,
333
335
  initialRegion: this.props.initialRegion || null,
334
336
  initialCamera: this.props.initialCamera,
335
337
  ref: this.map,
@@ -361,12 +363,5 @@ else {
361
363
  }
362
364
  const getNativeMapComponent = (provider) => airMaps[provider || 'default'];
363
365
  exports.AnimatedMapView = react_native_1.Animated.createAnimatedComponent(MapView);
364
- const enableLatestRenderer = () => {
365
- if (react_native_1.Platform.OS !== 'android') {
366
- return;
367
- }
368
- return react_native_1.NativeModules.AirMapModule.enableLatestRenderer();
369
- };
370
- exports.enableLatestRenderer = enableLatestRenderer;
371
366
  MapView.Animated = exports.AnimatedMapView;
372
367
  exports.default = MapView;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import MapView, { AnimatedMapView as Animated, MAP_TYPES, enableLatestRenderer, MapViewProps } from './MapView';
1
+ import MapView, { AnimatedMapView as Animated, MAP_TYPES, MapViewProps } from './MapView';
2
2
  import Marker from './MapMarker';
3
3
  export { MapMarker } from './MapMarker';
4
4
  export type { MapMarkerProps } from './MapMarker';
@@ -28,7 +28,7 @@ export { default as Geojson } from './Geojson';
28
28
  export type { GeojsonProps } from './Geojson';
29
29
  export { Marker, Overlay };
30
30
  export type { MapViewProps };
31
- export { Animated, MAP_TYPES, enableLatestRenderer };
31
+ export { Animated, MAP_TYPES };
32
32
  export * from './ProviderConstants';
33
33
  export * from './MapView.types';
34
34
  export * from './MapPolygon.types';
package/lib/index.js CHANGED
@@ -29,11 +29,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.OverlayAnimated = exports.MarkerAnimated = exports.enableLatestRenderer = exports.MAP_TYPES = exports.Animated = exports.Overlay = exports.Marker = exports.Geojson = exports.AnimatedRegion = exports.MapCalloutSubview = exports.CalloutSubview = exports.MapCallout = exports.Callout = exports.MapLocalTile = exports.LocalTile = exports.MapWMSTile = exports.WMSTile = exports.MapUrlTile = exports.UrlTile = exports.MapCircle = exports.Circle = exports.MapPolygon = exports.Polygon = exports.MapHeatmap = exports.Heatmap = exports.MapPolyline = exports.Polyline = exports.MapOverlay = exports.MapMarker = void 0;
32
+ exports.OverlayAnimated = exports.MarkerAnimated = exports.MAP_TYPES = exports.Animated = exports.Overlay = exports.Marker = exports.Geojson = exports.AnimatedRegion = exports.MapCalloutSubview = exports.CalloutSubview = exports.MapCallout = exports.Callout = exports.MapLocalTile = exports.LocalTile = exports.MapWMSTile = exports.WMSTile = exports.MapUrlTile = exports.UrlTile = exports.MapCircle = exports.Circle = exports.MapPolygon = exports.Polygon = exports.MapHeatmap = exports.Heatmap = exports.MapPolyline = exports.Polyline = exports.MapOverlay = exports.MapMarker = void 0;
33
33
  const MapView_1 = __importStar(require("./MapView"));
34
34
  Object.defineProperty(exports, "Animated", { enumerable: true, get: function () { return MapView_1.AnimatedMapView; } });
35
35
  Object.defineProperty(exports, "MAP_TYPES", { enumerable: true, get: function () { return MapView_1.MAP_TYPES; } });
36
- Object.defineProperty(exports, "enableLatestRenderer", { enumerable: true, get: function () { return MapView_1.enableLatestRenderer; } });
37
36
  const MapMarker_1 = __importDefault(require("./MapMarker"));
38
37
  exports.Marker = MapMarker_1.default;
39
38
  var MapMarker_2 = require("./MapMarker");
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "main": "lib/index.js",
6
6
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
7
7
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
8
- "version": "1.12.0",
8
+ "version": "1.13.0",
9
9
  "license": "MIT",
10
10
  "scripts": {
11
11
  "lint": "eslint . --max-warnings 0",