react-native-maps 1.21.0-alpha.54 → 1.21.0-alpha.55
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.
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
package com.rnmaps.fabric;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import android.util.Log;
|
|
6
5
|
import android.view.View;
|
|
7
6
|
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
8
|
import androidx.annotation.Nullable;
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
11
|
import com.facebook.react.bridge.ReadableMap;
|
|
12
|
+
import com.facebook.react.bridge.UiThreadUtil;
|
|
12
13
|
import com.facebook.react.module.annotations.ReactModule;
|
|
14
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
13
15
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
14
16
|
import com.facebook.react.uimanager.ViewGroupManager;
|
|
15
17
|
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
@@ -17,23 +19,31 @@ import com.facebook.react.viewmanagers.RNMapsMapViewManagerInterface;
|
|
|
17
19
|
import com.facebook.react.viewmanagers.RNMapsMapViewManagerDelegate;
|
|
18
20
|
import com.google.android.gms.maps.GoogleMap;
|
|
19
21
|
import com.google.android.gms.maps.GoogleMapOptions;
|
|
22
|
+
import com.google.android.gms.maps.MapsInitializer;
|
|
23
|
+
import com.google.android.gms.maps.model.CameraPosition;
|
|
20
24
|
import com.rnmaps.maps.MapView;
|
|
25
|
+
import com.rnmaps.maps.SizeReportingShadowNode;
|
|
21
26
|
|
|
27
|
+
import java.util.List;
|
|
22
28
|
import java.util.Map;
|
|
23
29
|
|
|
24
30
|
@ReactModule(name = MapViewManager.REACT_CLASS)
|
|
25
|
-
public class MapViewManager extends ViewGroupManager<
|
|
31
|
+
public class MapViewManager extends ViewGroupManager<MapViewWrapper> implements RNMapsMapViewManagerInterface<MapViewWrapper> {
|
|
32
|
+
|
|
33
|
+
private GoogleMapOptions options;
|
|
34
|
+
private boolean rendererInitialized = false;
|
|
35
|
+
private final RNMapsMapViewManagerDelegate<MapViewWrapper, MapViewManager> delegate =
|
|
36
|
+
new RNMapsMapViewManagerDelegate<>(this);
|
|
26
37
|
|
|
27
38
|
|
|
28
39
|
public MapViewManager(ReactApplicationContext context) {
|
|
29
40
|
super(context);
|
|
41
|
+
options = new GoogleMapOptions();
|
|
30
42
|
}
|
|
31
|
-
|
|
32
|
-
private final RNMapsMapViewManagerDelegate<MapView, MapViewManager> delegate =
|
|
33
|
-
new RNMapsMapViewManagerDelegate<>(this);
|
|
43
|
+
|
|
34
44
|
|
|
35
45
|
@Override
|
|
36
|
-
public ViewManagerDelegate<
|
|
46
|
+
public ViewManagerDelegate<MapViewWrapper> getDelegate() {
|
|
37
47
|
return delegate;
|
|
38
48
|
}
|
|
39
49
|
|
|
@@ -43,8 +53,9 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
|
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
@Override
|
|
46
|
-
public
|
|
47
|
-
|
|
56
|
+
public MapViewWrapper createViewInstance(ThemedReactContext context) {
|
|
57
|
+
Log.e(MapViewManager.class.getName(), "createViewInstance");
|
|
58
|
+
return new MapViewWrapper(context);
|
|
48
59
|
}
|
|
49
60
|
|
|
50
61
|
|
|
@@ -56,6 +67,14 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
|
|
|
56
67
|
return MapView.getExportedCustomBubblingEventTypeConstants();
|
|
57
68
|
}
|
|
58
69
|
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
public LayoutShadowNode createShadowNodeInstance() {
|
|
73
|
+
// A custom shadow node is needed in order to pass back the width/height of the map to the
|
|
74
|
+
// view manager so that it can start applying camera moves with bounds.
|
|
75
|
+
return new SizeReportingShadowNode();
|
|
76
|
+
}
|
|
77
|
+
|
|
59
78
|
@Nullable
|
|
60
79
|
@Override
|
|
61
80
|
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
@@ -63,313 +82,396 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
|
|
|
63
82
|
}
|
|
64
83
|
|
|
65
84
|
@Override
|
|
66
|
-
public void setCacheEnabled(
|
|
85
|
+
public void setCacheEnabled(MapViewWrapper view, boolean value) {
|
|
67
86
|
view.setCacheEnabled(value);
|
|
68
87
|
}
|
|
69
88
|
|
|
70
89
|
@Override
|
|
71
|
-
public void setCamera(
|
|
90
|
+
public void setCamera(MapViewWrapper view, @Nullable ReadableMap value) {
|
|
72
91
|
view.setCamera(value);
|
|
73
92
|
}
|
|
74
93
|
|
|
75
94
|
@Override
|
|
76
|
-
public void setCompassOffset(
|
|
95
|
+
public void setCompassOffset(MapViewWrapper view, @Nullable ReadableMap value) {
|
|
77
96
|
// not supported
|
|
78
97
|
}
|
|
79
98
|
|
|
80
99
|
@Override
|
|
81
|
-
public void setFollowsUserLocation(
|
|
100
|
+
public void setFollowsUserLocation(MapViewWrapper view, boolean value) {
|
|
82
101
|
// not supported
|
|
83
102
|
}
|
|
84
103
|
|
|
85
104
|
@Override
|
|
86
|
-
public void setPoiClickEnabled(
|
|
105
|
+
public void setPoiClickEnabled(MapViewWrapper view, boolean value) {
|
|
87
106
|
view.setPoiClickEnabled(value);
|
|
88
107
|
}
|
|
89
108
|
|
|
90
109
|
@Override
|
|
91
|
-
public void setInitialCamera(
|
|
92
|
-
|
|
110
|
+
public void setInitialCamera(MapViewWrapper view, @Nullable ReadableMap value) {
|
|
111
|
+
CameraPosition camera = MapView.cameraPositionFromMap(value);
|
|
112
|
+
if (camera != null){
|
|
113
|
+
options.camera(camera);
|
|
114
|
+
view.setInitialCameraSet(true);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@Override
|
|
119
|
+
protected MapViewWrapper recycleView(@NonNull ThemedReactContext var1, @NonNull MapViewWrapper wrapper){
|
|
120
|
+
wrapper.prepareToRecycleView();
|
|
121
|
+
return wrapper;
|
|
93
122
|
}
|
|
94
123
|
|
|
124
|
+
|
|
95
125
|
@Override
|
|
96
|
-
public void setInitialRegion(
|
|
126
|
+
public void setInitialRegion(MapViewWrapper view, @Nullable ReadableMap value) {
|
|
97
127
|
view.setInitialRegion(value);
|
|
98
128
|
}
|
|
99
129
|
|
|
100
130
|
@Override
|
|
101
|
-
public void setKmlSrc(
|
|
131
|
+
public void setKmlSrc(MapViewWrapper view, @Nullable String value) {
|
|
102
132
|
view.setKmlSrc(value);
|
|
103
133
|
}
|
|
104
134
|
|
|
105
135
|
@Override
|
|
106
|
-
public void setLegalLabelInsets(
|
|
136
|
+
public void setLegalLabelInsets(MapViewWrapper view, @Nullable ReadableMap value) {
|
|
107
137
|
// not supported
|
|
108
138
|
}
|
|
109
139
|
|
|
110
140
|
@Override
|
|
111
|
-
public void setLiteMode(
|
|
112
|
-
|
|
141
|
+
public void setLiteMode(MapViewWrapper view, boolean value) {
|
|
142
|
+
options.liteMode(value);
|
|
113
143
|
}
|
|
114
144
|
|
|
115
145
|
@Override
|
|
116
|
-
public void setGoogleMapId(
|
|
117
|
-
|
|
146
|
+
public void setGoogleMapId(MapViewWrapper view, @Nullable String value) {
|
|
147
|
+
options.mapId(value);
|
|
118
148
|
}
|
|
119
149
|
|
|
120
150
|
@Override
|
|
121
|
-
public void setGoogleRenderer(
|
|
151
|
+
public void setGoogleRenderer(MapViewWrapper view, @Nullable String value) {
|
|
152
|
+
if (!rendererInitialized) {
|
|
153
|
+
MapsInitializer.Renderer renderer = MapsInitializer.Renderer.LATEST;
|
|
154
|
+
if ("LEGACY".equals(value)){
|
|
155
|
+
renderer = MapsInitializer.Renderer.LEGACY;
|
|
156
|
+
}
|
|
157
|
+
MapsInitializer.initialize(getReactApplicationContext(), renderer, r -> Log.d("AirMapRenderer", "Init with renderer: " + r));
|
|
158
|
+
rendererInitialized = true;
|
|
159
|
+
}
|
|
122
160
|
|
|
123
161
|
}
|
|
124
162
|
|
|
125
163
|
@Override
|
|
126
|
-
public void setLoadingBackgroundColor(
|
|
164
|
+
public void setLoadingBackgroundColor(MapViewWrapper view, @Nullable Integer value) {
|
|
127
165
|
view.setLoadingBackgroundColor(value);
|
|
128
166
|
}
|
|
129
167
|
|
|
130
168
|
@Override
|
|
131
|
-
public void setLoadingEnabled(
|
|
169
|
+
public void setLoadingEnabled(MapViewWrapper view, boolean value) {
|
|
132
170
|
view.setLoadingEnabled(value);
|
|
133
171
|
}
|
|
134
172
|
|
|
135
173
|
@Override
|
|
136
|
-
public void setLoadingIndicatorColor(
|
|
174
|
+
public void setLoadingIndicatorColor(MapViewWrapper view, @Nullable Integer value) {
|
|
137
175
|
view.setLoadingIndicatorColor(value);
|
|
138
176
|
}
|
|
139
177
|
|
|
140
178
|
@Override
|
|
141
|
-
public void setMapPadding(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
int right = 0;
|
|
145
|
-
int bottom = 0;
|
|
146
|
-
double density = (double) view.getResources().getDisplayMetrics().density;
|
|
147
|
-
|
|
148
|
-
if (padding != null) {
|
|
149
|
-
if (padding.hasKey("left")) {
|
|
150
|
-
left = (int) (padding.getDouble("left") * density);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (padding.hasKey("top")) {
|
|
154
|
-
top = (int) (padding.getDouble("top") * density);
|
|
155
|
-
}
|
|
179
|
+
public void setMapPadding(MapViewWrapper view, @Nullable ReadableMap padding) {
|
|
180
|
+
view.setMapPadding(padding);
|
|
181
|
+
}
|
|
156
182
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
183
|
+
@Override
|
|
184
|
+
public void addView(MapViewWrapper parent, View child, int index) {
|
|
185
|
+
parent.getMapView().addFeature(child, index);
|
|
186
|
+
Log.e("MapViewManager", "addView " + child.getId() + " at index: " + index);
|
|
160
187
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
188
|
+
}
|
|
189
|
+
@Override
|
|
190
|
+
public void addViews(MapViewWrapper parent, List<View> views){
|
|
191
|
+
for (View view : views){
|
|
192
|
+
parent.getMapView().addView(view);
|
|
193
|
+
Log.e("MapViewManager", "addViews " + view.getId());
|
|
164
194
|
}
|
|
165
195
|
|
|
166
|
-
view.applyBaseMapPadding(left, top, right, bottom);
|
|
167
|
-
view.map.setPadding(left, top, right, bottom);
|
|
168
196
|
}
|
|
169
197
|
|
|
170
|
-
@Override
|
|
171
|
-
public void addView(MapView parent, View child, int index) {
|
|
172
|
-
parent.addFeature(child, index);
|
|
173
|
-
}
|
|
174
198
|
|
|
175
199
|
@Override
|
|
176
|
-
public void setMapType(
|
|
200
|
+
public void setMapType(MapViewWrapper view, @Nullable String value) {
|
|
201
|
+
int mapType;
|
|
177
202
|
//hybrid | none | satellite | standard | terrain
|
|
178
203
|
if ("hybrid".equals(value)) {
|
|
179
|
-
|
|
204
|
+
mapType = GoogleMap.MAP_TYPE_HYBRID;
|
|
180
205
|
} else if ("none".equals(value)) {
|
|
181
|
-
|
|
206
|
+
mapType = GoogleMap.MAP_TYPE_NONE;
|
|
182
207
|
} else if ("satellite".equals(value)) {
|
|
183
|
-
|
|
208
|
+
mapType = GoogleMap.MAP_TYPE_SATELLITE;
|
|
184
209
|
} else if ("standard".equals(value)) {
|
|
185
|
-
|
|
210
|
+
mapType = GoogleMap.MAP_TYPE_NORMAL;
|
|
186
211
|
} else if ("terrain".equals(value)) {
|
|
187
|
-
|
|
212
|
+
mapType = GoogleMap.MAP_TYPE_TERRAIN;
|
|
213
|
+
} else {
|
|
214
|
+
mapType = GoogleMap.MAP_TYPE_NORMAL;
|
|
215
|
+
}
|
|
216
|
+
options.mapType(mapType);
|
|
217
|
+
if (view.getMapView() != null){
|
|
218
|
+
view.getMapView().setMapType(mapType);
|
|
188
219
|
}
|
|
189
220
|
}
|
|
190
221
|
|
|
191
222
|
@Override
|
|
192
|
-
public void setMaxDelta(
|
|
223
|
+
public void setMaxDelta(MapViewWrapper view, double value) {
|
|
193
224
|
// not supported
|
|
194
225
|
}
|
|
195
226
|
|
|
196
227
|
@Override
|
|
197
|
-
public void setMaxZoom(
|
|
198
|
-
|
|
228
|
+
public void setMaxZoom(MapViewWrapper view, float value) {
|
|
229
|
+
options.maxZoomPreference(value);
|
|
230
|
+
if (view.getMapView() != null) {
|
|
231
|
+
view.getMapView().setMaxZoomLevel(value);
|
|
232
|
+
}
|
|
199
233
|
}
|
|
200
234
|
|
|
201
235
|
@Override
|
|
202
|
-
public void setMinDelta(
|
|
236
|
+
public void setMinDelta(MapViewWrapper view, double value) {
|
|
203
237
|
// not supported
|
|
204
238
|
}
|
|
205
239
|
|
|
206
240
|
@Override
|
|
207
|
-
public void setMinZoom(
|
|
208
|
-
|
|
241
|
+
public void setMinZoom(MapViewWrapper view, float value) {
|
|
242
|
+
options.minZoomPreference(value);
|
|
243
|
+
if (view.getMapView() != null) {
|
|
244
|
+
view.getMapView().setMinZoomLevel(value);
|
|
245
|
+
}
|
|
209
246
|
}
|
|
210
247
|
|
|
211
248
|
@Override
|
|
212
|
-
public void setMoveOnMarkerPress(
|
|
249
|
+
public void setMoveOnMarkerPress(MapViewWrapper view, boolean value) {
|
|
213
250
|
view.setMoveOnMarkerPress(value);
|
|
214
251
|
}
|
|
215
252
|
|
|
216
253
|
@Override
|
|
217
|
-
public void setHandlePanDrag(
|
|
254
|
+
public void setHandlePanDrag(MapViewWrapper view, boolean value) {
|
|
218
255
|
view.setHandlePanDrag(value);
|
|
219
256
|
}
|
|
220
257
|
|
|
221
258
|
@Override
|
|
222
|
-
public void setPaddingAdjustmentBehavior(
|
|
223
|
-
|
|
259
|
+
public void setPaddingAdjustmentBehavior(MapViewWrapper view, @Nullable String value) {
|
|
260
|
+
// not supported
|
|
224
261
|
}
|
|
225
262
|
|
|
226
263
|
@Override
|
|
227
|
-
public void setPitchEnabled(
|
|
228
|
-
|
|
264
|
+
public void setPitchEnabled(MapViewWrapper view, boolean value) {
|
|
265
|
+
options.tiltGesturesEnabled(value);
|
|
266
|
+
if (view.getMapView() != null) {
|
|
267
|
+
view.getMapView().setPitchEnabled(value);
|
|
268
|
+
}
|
|
229
269
|
}
|
|
230
270
|
|
|
231
271
|
@Override
|
|
232
|
-
public void setRegion(
|
|
272
|
+
public void setRegion(MapViewWrapper view, @Nullable ReadableMap value) {
|
|
233
273
|
view.setRegion(value);
|
|
234
274
|
}
|
|
235
275
|
|
|
236
276
|
@Override
|
|
237
|
-
public void setRotateEnabled(
|
|
238
|
-
|
|
277
|
+
public void setRotateEnabled(MapViewWrapper view, boolean value) {
|
|
278
|
+
options.rotateGesturesEnabled(value);
|
|
279
|
+
if (view.getMapView() != null) {
|
|
280
|
+
view.getMapView().setRotateEnabled(value);
|
|
281
|
+
}
|
|
239
282
|
}
|
|
240
283
|
|
|
241
284
|
@Override
|
|
242
|
-
public void setScrollDuringRotateOrZoomEnabled(
|
|
243
|
-
|
|
285
|
+
public void setScrollDuringRotateOrZoomEnabled(MapViewWrapper view, boolean value) {
|
|
286
|
+
options.scrollGesturesEnabledDuringRotateOrZoom(value);
|
|
287
|
+
if (view.getMapView() != null) {
|
|
288
|
+
view.getMapView().setScrollDuringRotateOrZoomEnabled(value);
|
|
289
|
+
}
|
|
244
290
|
}
|
|
245
291
|
|
|
246
292
|
@Override
|
|
247
|
-
public void setScrollEnabled(
|
|
248
|
-
|
|
293
|
+
public void setScrollEnabled(MapViewWrapper view, boolean value) {
|
|
294
|
+
options.scrollGesturesEnabled(value);
|
|
295
|
+
if (view.getMapView() != null) {
|
|
296
|
+
view.getMapView().setScrollEnabled(value);
|
|
297
|
+
}
|
|
249
298
|
}
|
|
250
299
|
|
|
251
300
|
@Override
|
|
252
|
-
public void setShowsBuildings(
|
|
253
|
-
|
|
301
|
+
public void setShowsBuildings(MapViewWrapper view, boolean value) {
|
|
302
|
+
view.setShowsBuildings(value);
|
|
254
303
|
}
|
|
255
304
|
|
|
256
305
|
@Override
|
|
257
|
-
public void setShowsCompass(
|
|
306
|
+
public void setShowsCompass(MapViewWrapper view, boolean value) {
|
|
307
|
+
options.compassEnabled(value);
|
|
258
308
|
view.setShowsCompass(value);
|
|
259
309
|
}
|
|
260
310
|
|
|
261
311
|
@Override
|
|
262
|
-
public void setShowsIndoorLevelPicker(
|
|
312
|
+
public void setShowsIndoorLevelPicker(MapViewWrapper view, boolean value) {
|
|
263
313
|
view.setShowsIndoorLevelPicker(value);
|
|
264
314
|
}
|
|
265
315
|
|
|
266
316
|
@Override
|
|
267
|
-
public void setShowsIndoors(
|
|
268
|
-
view.
|
|
317
|
+
public void setShowsIndoors(MapViewWrapper view, boolean value) {
|
|
318
|
+
view.setShowsIndoors(value);
|
|
269
319
|
}
|
|
270
320
|
|
|
271
321
|
@Override
|
|
272
|
-
public void setShowsMyLocationButton(
|
|
322
|
+
public void setShowsMyLocationButton(MapViewWrapper view, boolean value) {
|
|
273
323
|
view.setShowsMyLocationButton(value);
|
|
274
324
|
}
|
|
275
325
|
|
|
276
326
|
@Override
|
|
277
|
-
public void setShowsScale(
|
|
327
|
+
public void setShowsScale(MapViewWrapper view, boolean value) {
|
|
278
328
|
// not supported
|
|
279
329
|
}
|
|
280
330
|
|
|
281
331
|
@Override
|
|
282
|
-
public void setShowsUserLocation(
|
|
332
|
+
public void setShowsUserLocation(MapViewWrapper view, boolean value) {
|
|
283
333
|
view.setShowsUserLocation(value);
|
|
284
334
|
}
|
|
285
335
|
|
|
286
336
|
@Override
|
|
287
|
-
public void setTintColor(
|
|
337
|
+
public void setTintColor(MapViewWrapper view, @Nullable Integer value) {
|
|
288
338
|
// not supported
|
|
289
339
|
}
|
|
290
340
|
|
|
291
341
|
@Override
|
|
292
|
-
public void setToolbarEnabled(
|
|
293
|
-
|
|
342
|
+
public void setToolbarEnabled(MapViewWrapper view, boolean value) {
|
|
343
|
+
options.mapToolbarEnabled(value);
|
|
344
|
+
if (view.getMapView() != null) {
|
|
345
|
+
view.getMapView().setToolbarEnabled(value);
|
|
346
|
+
}
|
|
294
347
|
}
|
|
295
348
|
|
|
296
349
|
@Override
|
|
297
|
-
public void setUserInterfaceStyle(
|
|
298
|
-
//
|
|
350
|
+
public void setUserInterfaceStyle(MapViewWrapper view, @Nullable String value) {
|
|
351
|
+
// todo update google maps SDK and add support for MapColorScheme
|
|
299
352
|
}
|
|
300
353
|
|
|
301
354
|
@Override
|
|
302
|
-
public void setUserLocationAnnotationTitle(
|
|
355
|
+
public void setUserLocationAnnotationTitle(MapViewWrapper view, @Nullable String value) {
|
|
303
356
|
// not supported
|
|
304
357
|
}
|
|
305
358
|
|
|
306
359
|
@Override
|
|
307
|
-
public void setUserLocationCalloutEnabled(
|
|
360
|
+
public void setUserLocationCalloutEnabled(MapViewWrapper view, boolean value) {
|
|
308
361
|
// not supported
|
|
309
362
|
}
|
|
310
363
|
|
|
311
364
|
@Override
|
|
312
|
-
public void setUserLocationFastestInterval(
|
|
365
|
+
public void setUserLocationFastestInterval(MapViewWrapper view, int value) {
|
|
313
366
|
view.setUserLocationFastestInterval(value);
|
|
314
367
|
}
|
|
315
368
|
|
|
316
369
|
@Override
|
|
317
|
-
public void setUserLocationPriority(
|
|
318
|
-
view.setUserLocationPriority(
|
|
370
|
+
public void setUserLocationPriority(MapViewWrapper view, @Nullable String value) {
|
|
371
|
+
view.setUserLocationPriority(value);
|
|
319
372
|
}
|
|
320
373
|
|
|
321
374
|
@Override
|
|
322
|
-
public void setUserLocationUpdateInterval(
|
|
375
|
+
public void setUserLocationUpdateInterval(MapViewWrapper view, int value) {
|
|
323
376
|
view.setUserLocationUpdateInterval(value);
|
|
324
377
|
}
|
|
325
378
|
|
|
326
379
|
@Override
|
|
327
|
-
public void setZoomControlEnabled(
|
|
328
|
-
|
|
380
|
+
public void setZoomControlEnabled(MapViewWrapper view, boolean value) {
|
|
381
|
+
options.zoomControlsEnabled(value);
|
|
382
|
+
if (view.getMapView() != null) {
|
|
383
|
+
view.setZoomControlEnabled(value);
|
|
384
|
+
}
|
|
329
385
|
}
|
|
330
386
|
|
|
331
387
|
@Override
|
|
332
|
-
public void setZoomEnabled(
|
|
333
|
-
|
|
388
|
+
public void setZoomEnabled(MapViewWrapper view, boolean value) {
|
|
389
|
+
options.zoomGesturesEnabled(value);
|
|
390
|
+
if (view.getMapView() != null) {
|
|
391
|
+
view.setZoomEnabled(value);
|
|
392
|
+
}
|
|
334
393
|
}
|
|
335
394
|
|
|
336
395
|
@Override
|
|
337
|
-
public void setZoomTapEnabled(
|
|
396
|
+
public void setZoomTapEnabled(MapViewWrapper view, boolean value) {
|
|
338
397
|
// not supported
|
|
339
398
|
}
|
|
340
399
|
|
|
341
400
|
@Override
|
|
342
|
-
public void setCameraZoomRange(
|
|
401
|
+
public void setCameraZoomRange(MapViewWrapper view, @Nullable ReadableMap value) {
|
|
343
402
|
// not supported
|
|
344
403
|
}
|
|
345
404
|
|
|
346
405
|
@Override
|
|
347
|
-
public void animateToRegion(
|
|
406
|
+
public void animateToRegion(MapViewWrapper view, String regionJSON, int duration) {
|
|
348
407
|
|
|
349
408
|
}
|
|
350
409
|
|
|
351
410
|
@Override
|
|
352
|
-
public void setCamera(
|
|
411
|
+
public void setCamera(MapViewWrapper view, String cameraJSON) {
|
|
353
412
|
|
|
354
413
|
}
|
|
355
414
|
|
|
356
415
|
@Override
|
|
357
|
-
public void animateCamera(
|
|
416
|
+
public void animateCamera(MapViewWrapper view, String cameraJSON, int duration) {
|
|
358
417
|
|
|
359
418
|
}
|
|
360
419
|
|
|
361
420
|
@Override
|
|
362
|
-
public void fitToElements(
|
|
421
|
+
public void fitToElements(MapViewWrapper view, String edgePaddingJSON, boolean animated) {
|
|
363
422
|
|
|
364
423
|
}
|
|
365
424
|
|
|
366
425
|
@Override
|
|
367
|
-
public void fitToSuppliedMarkers(
|
|
426
|
+
public void fitToSuppliedMarkers(MapViewWrapper view, String markersJSON, String edgePaddingJSON, boolean animated) {
|
|
368
427
|
|
|
369
428
|
}
|
|
370
429
|
|
|
371
430
|
@Override
|
|
372
|
-
public void fitToCoordinates(
|
|
431
|
+
public void fitToCoordinates(MapViewWrapper view, String coordinatesJSON, String edgePaddingJSON, boolean animated) {
|
|
373
432
|
|
|
374
433
|
}
|
|
434
|
+
@Override
|
|
435
|
+
public int getChildCount(MapViewWrapper parent) {
|
|
436
|
+
if (parent.getMapView() != null) {
|
|
437
|
+
return parent.getMapView().getChildCount();
|
|
438
|
+
}
|
|
439
|
+
return 0;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
@Override
|
|
443
|
+
public View getChildAt(MapViewWrapper parent, int index) {
|
|
444
|
+
if (parent.getMapView() != null) {
|
|
445
|
+
return parent.getMapView().getChildAt(index);
|
|
446
|
+
}
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
@Override
|
|
451
|
+
public void removeViewAt(MapViewWrapper parent, int index) {
|
|
452
|
+
if (parent.getMapView() != null) {
|
|
453
|
+
parent.getMapView().removeViewAt(index);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
public void removeView(MapViewWrapper parent, View view) {
|
|
458
|
+
if (parent.getMapView() != null) {
|
|
459
|
+
parent.getMapView().removeView(view);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
@Override
|
|
465
|
+
protected void onAfterUpdateTransaction(@NonNull MapViewWrapper view) {
|
|
466
|
+
super.onAfterUpdateTransaction(view);
|
|
467
|
+
setGoogleRenderer(view, null);
|
|
468
|
+
view.initializeMapView(options);
|
|
469
|
+
options = new GoogleMapOptions();
|
|
470
|
+
Log.e("MapViewManager", "onAfterUpdateTransaction tag: " + view.getId());
|
|
471
|
+
}
|
|
472
|
+
@Override
|
|
473
|
+
public void onDropViewInstance(MapViewWrapper view) {
|
|
474
|
+
super.onDropViewInstance(view);
|
|
475
|
+
view.prepareToRecycleView();
|
|
476
|
+
}
|
|
375
477
|
}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
package com.rnmaps.fabric;
|
|
2
|
+
|
|
3
|
+
import static com.rnmaps.maps.MapManager.MY_LOCATION_PRIORITY;
|
|
4
|
+
|
|
5
|
+
import android.annotation.SuppressLint;
|
|
6
|
+
import android.content.Context;
|
|
7
|
+
import android.view.View;
|
|
8
|
+
import android.widget.FrameLayout;
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
11
|
+
import androidx.annotation.Nullable;
|
|
12
|
+
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
14
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
15
|
+
import com.google.android.gms.maps.GoogleMapOptions;
|
|
16
|
+
import com.rnmaps.maps.MapView;
|
|
17
|
+
|
|
18
|
+
@SuppressLint("ViewConstructor")
|
|
19
|
+
public class MapViewWrapper extends FrameLayout {
|
|
20
|
+
private MapView mapView;
|
|
21
|
+
private Boolean cacheEnabled;
|
|
22
|
+
private Boolean initialCameraSet;
|
|
23
|
+
|
|
24
|
+
private Boolean showsBuildings;
|
|
25
|
+
private Boolean poiClickEnabled;
|
|
26
|
+
private Boolean moveOnMarkerPress;
|
|
27
|
+
private Boolean handlePanDrag;
|
|
28
|
+
private Boolean showsIndoorLevelPicker;
|
|
29
|
+
private Boolean showIndoors;
|
|
30
|
+
private Boolean showsMyLocationButton;
|
|
31
|
+
private Boolean showsUserLocation;
|
|
32
|
+
private Boolean loadingEnabled;
|
|
33
|
+
|
|
34
|
+
private ReadableMap camera;
|
|
35
|
+
|
|
36
|
+
private ReadableMap initialRegion;
|
|
37
|
+
|
|
38
|
+
private String kmlSrc;
|
|
39
|
+
private ReadableMap region;
|
|
40
|
+
private ReadableMap mapPadding;
|
|
41
|
+
|
|
42
|
+
private Integer userLocationPriority;
|
|
43
|
+
private Integer userLocationFastestInterval;
|
|
44
|
+
private Integer userLocationUpdateInterval;
|
|
45
|
+
private Integer loadingIndicatorColor;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
public MapViewWrapper(@NonNull Context context) {
|
|
49
|
+
super(context);
|
|
50
|
+
setLayoutParams(new LayoutParams(
|
|
51
|
+
LayoutParams.MATCH_PARENT,
|
|
52
|
+
LayoutParams.MATCH_PARENT
|
|
53
|
+
));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
public MapView getMapView() {
|
|
58
|
+
return mapView;
|
|
59
|
+
}
|
|
60
|
+
public void initializeMapView(GoogleMapOptions options) {
|
|
61
|
+
if (mapView == null) {
|
|
62
|
+
mapView = new MapView((ThemedReactContext) getContext(), options);
|
|
63
|
+
mapView.setLayoutParams(new LayoutParams(
|
|
64
|
+
LayoutParams.MATCH_PARENT,
|
|
65
|
+
LayoutParams.MATCH_PARENT
|
|
66
|
+
));
|
|
67
|
+
addView(mapView);
|
|
68
|
+
if (cacheEnabled != null){
|
|
69
|
+
setCacheEnabled(cacheEnabled);
|
|
70
|
+
}
|
|
71
|
+
if (showsBuildings != null){
|
|
72
|
+
setShowsBuildings(showsBuildings);
|
|
73
|
+
}
|
|
74
|
+
if (poiClickEnabled != null){
|
|
75
|
+
setPoiClickEnabled(poiClickEnabled);
|
|
76
|
+
}
|
|
77
|
+
if (moveOnMarkerPress != null){
|
|
78
|
+
setMoveOnMarkerPress(moveOnMarkerPress);
|
|
79
|
+
}
|
|
80
|
+
if (handlePanDrag != null){
|
|
81
|
+
setHandlePanDrag(handlePanDrag);
|
|
82
|
+
}
|
|
83
|
+
if (showsIndoorLevelPicker != null){
|
|
84
|
+
setShowsIndoorLevelPicker(showsIndoorLevelPicker);
|
|
85
|
+
}
|
|
86
|
+
if (showIndoors != null){
|
|
87
|
+
setShowsIndoors(showIndoors);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (showsMyLocationButton != null){
|
|
91
|
+
setShowsMyLocationButton(showsMyLocationButton);
|
|
92
|
+
}
|
|
93
|
+
if (showsUserLocation != null) {
|
|
94
|
+
setShowsUserLocation(showsUserLocation);
|
|
95
|
+
}
|
|
96
|
+
if (loadingEnabled != null) {
|
|
97
|
+
setLoadingEnabled(loadingEnabled);
|
|
98
|
+
}
|
|
99
|
+
if (camera != null){
|
|
100
|
+
setCamera(camera);
|
|
101
|
+
}
|
|
102
|
+
if (kmlSrc != null){
|
|
103
|
+
setKmlSrc(kmlSrc);
|
|
104
|
+
}
|
|
105
|
+
if (region != null){
|
|
106
|
+
setRegion(region);
|
|
107
|
+
}
|
|
108
|
+
if (mapPadding != null){
|
|
109
|
+
setMapPadding(mapPadding);
|
|
110
|
+
}
|
|
111
|
+
if (userLocationPriority != null) {
|
|
112
|
+
mapView.setUserLocationPriority(userLocationPriority);
|
|
113
|
+
}
|
|
114
|
+
if (userLocationFastestInterval != null) {
|
|
115
|
+
setUserLocationFastestInterval(userLocationFastestInterval);
|
|
116
|
+
}
|
|
117
|
+
if (userLocationUpdateInterval != null) {
|
|
118
|
+
setUserLocationUpdateInterval(userLocationUpdateInterval);
|
|
119
|
+
}
|
|
120
|
+
if (loadingIndicatorColor != null) {
|
|
121
|
+
setLoadingIndicatorColor(loadingIndicatorColor);
|
|
122
|
+
}
|
|
123
|
+
if (initialRegion != null){
|
|
124
|
+
mapView.setInitialRegion(initialRegion);
|
|
125
|
+
}
|
|
126
|
+
if (initialCameraSet != null){
|
|
127
|
+
mapView.setInitialCameraSet(initialCameraSet);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
protected void onDetachedFromWindow() {
|
|
133
|
+
super.onDetachedFromWindow();
|
|
134
|
+
if (mapView != null) {
|
|
135
|
+
mapView.onDestroy();
|
|
136
|
+
removeView(mapView);
|
|
137
|
+
mapView = null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public void setInitialCameraSet(boolean initialCameraSet) {
|
|
142
|
+
this.initialCameraSet = initialCameraSet;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public void setInitialRegion(ReadableMap initialRegion) {
|
|
146
|
+
this.initialRegion = initialRegion;
|
|
147
|
+
if (getMapView() != null){
|
|
148
|
+
getMapView().setInitialRegion(initialRegion);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public void setCacheEnabled(boolean value) {
|
|
153
|
+
if (getMapView() != null) {
|
|
154
|
+
getMapView().setCacheEnabled(value);
|
|
155
|
+
} else {
|
|
156
|
+
cacheEnabled = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
public void setCamera(@Nullable ReadableMap value) {
|
|
162
|
+
if (getMapView() != null) {
|
|
163
|
+
getMapView().setCamera(value);
|
|
164
|
+
} else {
|
|
165
|
+
camera = value;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
public void setPoiClickEnabled(boolean value) {
|
|
171
|
+
if (getMapView() != null) {
|
|
172
|
+
getMapView().setPoiClickEnabled(value);
|
|
173
|
+
} else {
|
|
174
|
+
poiClickEnabled = value;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
public void prepareToRecycleView(){
|
|
179
|
+
mapView = null;
|
|
180
|
+
cacheEnabled = null;
|
|
181
|
+
initialCameraSet = null;
|
|
182
|
+
showsBuildings = null;
|
|
183
|
+
poiClickEnabled = null;
|
|
184
|
+
moveOnMarkerPress = null;
|
|
185
|
+
handlePanDrag = null;
|
|
186
|
+
showsIndoorLevelPicker = null;
|
|
187
|
+
showIndoors = null;
|
|
188
|
+
showsMyLocationButton = null;
|
|
189
|
+
showsUserLocation = null;
|
|
190
|
+
loadingEnabled = null;
|
|
191
|
+
camera = null;
|
|
192
|
+
initialRegion = null;
|
|
193
|
+
userLocationPriority = null;
|
|
194
|
+
userLocationFastestInterval = null;
|
|
195
|
+
userLocationUpdateInterval = null;
|
|
196
|
+
loadingIndicatorColor = null;
|
|
197
|
+
if (getMapView() != null) {
|
|
198
|
+
getMapView().onDestroy();
|
|
199
|
+
}
|
|
200
|
+
mapView = null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
public void setKmlSrc(@Nullable String value) {
|
|
206
|
+
if (getMapView() != null) {
|
|
207
|
+
getMapView().setKmlSrc(value);
|
|
208
|
+
}
|
|
209
|
+
kmlSrc = value;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
public void setLoadingBackgroundColor(@Nullable Integer value) {
|
|
214
|
+
getMapView().setLoadingBackgroundColor(value);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
public void setLoadingEnabled(boolean value) {
|
|
219
|
+
if (getMapView() != null) {
|
|
220
|
+
getMapView().setLoadingEnabled(value);
|
|
221
|
+
}
|
|
222
|
+
loadingEnabled = value;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
public void setLoadingIndicatorColor(@Nullable Integer value) {
|
|
227
|
+
if (getMapView() != null) {
|
|
228
|
+
getMapView().setLoadingIndicatorColor(value);
|
|
229
|
+
}
|
|
230
|
+
loadingIndicatorColor = value;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
public void setMapPadding(@Nullable ReadableMap padding) {
|
|
235
|
+
if (getMapView() != null) {
|
|
236
|
+
int left = 0;
|
|
237
|
+
int top = 0;
|
|
238
|
+
int right = 0;
|
|
239
|
+
int bottom = 0;
|
|
240
|
+
double density = (double) getMapView().getResources().getDisplayMetrics().density;
|
|
241
|
+
|
|
242
|
+
if (padding != null) {
|
|
243
|
+
if (padding.hasKey("left")) {
|
|
244
|
+
left = (int) (padding.getDouble("left") * density);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (padding.hasKey("top")) {
|
|
248
|
+
top = (int) (padding.getDouble("top") * density);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (padding.hasKey("right")) {
|
|
252
|
+
right = (int) (padding.getDouble("right") * density);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (padding.hasKey("bottom")) {
|
|
256
|
+
bottom = (int) (padding.getDouble("bottom") * density);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
getMapView().applyBaseMapPadding(left, top, right, bottom);
|
|
261
|
+
getMapView().map.setPadding(left, top, right, bottom);
|
|
262
|
+
}
|
|
263
|
+
this.mapPadding = padding;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
public void setMoveOnMarkerPress(boolean value) {
|
|
267
|
+
if (getMapView() != null){
|
|
268
|
+
getMapView().setMoveOnMarkerPress(value);
|
|
269
|
+
}
|
|
270
|
+
moveOnMarkerPress = value;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
public void setHandlePanDrag(boolean value) {
|
|
275
|
+
if (getMapView() != null) {
|
|
276
|
+
getMapView().setHandlePanDrag(value);
|
|
277
|
+
}
|
|
278
|
+
handlePanDrag = value;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
public void setRegion(@Nullable ReadableMap value) {
|
|
282
|
+
if (getMapView() != null) {
|
|
283
|
+
getMapView().setRegion(value);
|
|
284
|
+
}
|
|
285
|
+
region = value;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
public void setShowsBuildings(boolean value) {
|
|
290
|
+
showsBuildings = value;
|
|
291
|
+
if (getMapView() != null){
|
|
292
|
+
getMapView().setShowBuildings(value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
public void setShowsCompass(boolean value) {
|
|
298
|
+
if (getMapView() != null) {
|
|
299
|
+
getMapView().setShowsCompass(value);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
public void setShowsIndoorLevelPicker(boolean value) {
|
|
305
|
+
if (getMapView() != null) {
|
|
306
|
+
getMapView().setShowsIndoorLevelPicker(value);
|
|
307
|
+
}
|
|
308
|
+
showsIndoorLevelPicker = value;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
public void setShowsIndoors(boolean value) {
|
|
313
|
+
if (getMapView() != null){
|
|
314
|
+
getMapView().setShowIndoors(value);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
showIndoors = value;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
public void setShowsMyLocationButton(boolean value) {
|
|
322
|
+
if (getMapView() != null) {
|
|
323
|
+
getMapView().setShowsMyLocationButton(value);
|
|
324
|
+
}
|
|
325
|
+
showsMyLocationButton = value;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
public void setShowsUserLocation(boolean value) {
|
|
329
|
+
if (getMapView() != null) {
|
|
330
|
+
getMapView().setShowsUserLocation(value);
|
|
331
|
+
}
|
|
332
|
+
showsUserLocation = value;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
public void setUserLocationFastestInterval(int value) {
|
|
336
|
+
if (getMapView() != null) {
|
|
337
|
+
getMapView().setUserLocationFastestInterval(value);
|
|
338
|
+
}
|
|
339
|
+
userLocationFastestInterval = value;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
public void setUserLocationPriority(@Nullable String value) {
|
|
344
|
+
if (mapView != null) {
|
|
345
|
+
mapView.setUserLocationPriority(MY_LOCATION_PRIORITY.get(value));
|
|
346
|
+
} else {
|
|
347
|
+
userLocationPriority = MY_LOCATION_PRIORITY.get(value);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
public void setUserLocationUpdateInterval(int value) {
|
|
353
|
+
if (getMapView() != null) {
|
|
354
|
+
getMapView().setUserLocationUpdateInterval(value);
|
|
355
|
+
}
|
|
356
|
+
userLocationUpdateInterval = value;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
public void setZoomControlEnabled(boolean value) {
|
|
361
|
+
getMapView().setZoomControlEnabled(value);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
public void setZoomEnabled(boolean value) {
|
|
366
|
+
getMapView().setZoomEnabled(value);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
}
|
|
@@ -43,7 +43,6 @@ import com.google.android.gms.maps.CameraUpdate;
|
|
|
43
43
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
44
44
|
import com.google.android.gms.maps.GoogleMap;
|
|
45
45
|
import com.google.android.gms.maps.GoogleMapOptions;
|
|
46
|
-
import com.google.android.gms.maps.MapsInitializer;
|
|
47
46
|
import com.google.android.gms.maps.OnMapReadyCallback;
|
|
48
47
|
import com.google.android.gms.maps.Projection;
|
|
49
48
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
@@ -185,7 +184,6 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
185
184
|
GoogleMapOptions googleMapOptions) {
|
|
186
185
|
super(context, googleMapOptions);
|
|
187
186
|
// todo add support for legacy renderer
|
|
188
|
-
MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, renderer -> Log.d("AirMapRenderer", renderer.toString()));
|
|
189
187
|
this.context = context;
|
|
190
188
|
super.onCreate(null);
|
|
191
189
|
super.onResume();
|
|
@@ -634,6 +632,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
634
632
|
onDestroy();
|
|
635
633
|
}
|
|
636
634
|
|
|
635
|
+
public void setInitialCameraSet(boolean initialCameraSet){
|
|
636
|
+
this.initialCameraSet = initialCameraSet;
|
|
637
|
+
}
|
|
638
|
+
|
|
637
639
|
public void setInitialRegion(ReadableMap initialRegion) {
|
|
638
640
|
this.initialRegion = initialRegion;
|
|
639
641
|
// Theoretically onMapReady might be called before setInitialRegion
|
|
@@ -669,18 +671,23 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
669
671
|
}
|
|
670
672
|
this.setPoiClickEnabled(poiClickEnabled);
|
|
671
673
|
}
|
|
672
|
-
|
|
674
|
+
public static LatLngBounds latLngBoundsFromRegion(ReadableMap region){
|
|
675
|
+
if (region == null) return null;
|
|
676
|
+
|
|
677
|
+
double lng = region.getDouble("longitude");
|
|
678
|
+
double lat = region.getDouble("latitude");
|
|
679
|
+
double lngDelta = region.getDouble("longitudeDelta");
|
|
680
|
+
double latDelta = region.getDouble("latitudeDelta");
|
|
681
|
+
return new LatLngBounds(
|
|
682
|
+
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
|
|
683
|
+
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
|
|
684
|
+
);
|
|
685
|
+
}
|
|
673
686
|
private void moveToRegion(ReadableMap region) {
|
|
674
|
-
|
|
675
|
-
|
|
687
|
+
LatLngBounds bounds = latLngBoundsFromRegion(region);
|
|
688
|
+
if (bounds == null) return;
|
|
676
689
|
double lng = region.getDouble("longitude");
|
|
677
690
|
double lat = region.getDouble("latitude");
|
|
678
|
-
double lngDelta = region.getDouble("longitudeDelta");
|
|
679
|
-
double latDelta = region.getDouble("latitudeDelta");
|
|
680
|
-
LatLngBounds bounds = new LatLngBounds(
|
|
681
|
-
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
|
|
682
|
-
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
|
|
683
|
-
);
|
|
684
691
|
if (super.getHeight() <= 0 || super.getWidth() <= 0) {
|
|
685
692
|
// in this case, our map has not been laid out yet, so we save the bounds in a local
|
|
686
693
|
// variable, and make a guess of zoomLevel 10. Not to worry, though: as soon as layout
|
|
@@ -770,18 +777,24 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
770
777
|
}
|
|
771
778
|
|
|
772
779
|
public void setShowsMyLocationButton(boolean showMyLocationButton) {
|
|
773
|
-
if (
|
|
774
|
-
|
|
780
|
+
if (map != null) {
|
|
781
|
+
if (hasPermissions() || !showMyLocationButton) {
|
|
782
|
+
map.getUiSettings().setMyLocationButtonEnabled(showMyLocationButton);
|
|
783
|
+
}
|
|
775
784
|
}
|
|
776
785
|
}
|
|
777
786
|
|
|
778
787
|
public void setToolbarEnabled(boolean toolbarEnabled) {
|
|
779
|
-
if (
|
|
780
|
-
|
|
788
|
+
if (map != null) {
|
|
789
|
+
if (hasPermissions() || !toolbarEnabled) {
|
|
790
|
+
map.getUiSettings().setMapToolbarEnabled(toolbarEnabled);
|
|
791
|
+
}
|
|
781
792
|
}
|
|
782
793
|
}
|
|
783
794
|
public void setMapType(int mapType){
|
|
784
|
-
map
|
|
795
|
+
if (map != null) {
|
|
796
|
+
map.setMapType(mapType);
|
|
797
|
+
}
|
|
785
798
|
}
|
|
786
799
|
|
|
787
800
|
public void setCacheEnabled(boolean cacheEnabled) {
|
|
@@ -791,7 +804,9 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
791
804
|
|
|
792
805
|
public void setPoiClickEnabled(boolean poiClickEnabled) {
|
|
793
806
|
this.poiClickEnabled = poiClickEnabled;
|
|
794
|
-
map
|
|
807
|
+
if (map != null) {
|
|
808
|
+
map.setOnPoiClickListener(poiClickEnabled ? this : null);
|
|
809
|
+
}
|
|
795
810
|
}
|
|
796
811
|
|
|
797
812
|
public void setLoadingEnabled(boolean loadingEnabled) {
|
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.21.0-alpha.
|
|
8
|
+
"version": "1.21.0-alpha.55",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|