react-native-maps 1.21.0-alpha.50 → 1.21.0-alpha.51
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/android/build.gradle +2 -2
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +199 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +71 -0
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +345 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMapReadyEvent.java +26 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerPressEvent.java +25 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnPressEvent.java +24 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +43 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnUserLocationChangeEvent.java +25 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +14 -1
- package/android/src/main/java/com/rnmaps/maps/MapView.java +153 -86
- package/lib/MapView.js +50 -77
- package/lib/specs/NativeComponentMapView.js +1 -3
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.rnmaps.fabric.event;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap;
|
|
4
|
+
import com.facebook.react.uimanager.events.Event;
|
|
5
|
+
|
|
6
|
+
public class OnPressEvent extends Event<OnPressEvent> {
|
|
7
|
+
public static final String EVENT_NAME = "topPress";
|
|
8
|
+
private final WritableMap payload;
|
|
9
|
+
|
|
10
|
+
public OnPressEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
11
|
+
super(surfaceId, viewId);
|
|
12
|
+
this.payload = payload;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
public String getEventName() {
|
|
17
|
+
return EVENT_NAME;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public WritableMap getEventData() {
|
|
22
|
+
return payload;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package com.rnmaps.fabric.event;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap;
|
|
4
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
5
|
+
import com.facebook.react.uimanager.events.Event;
|
|
6
|
+
import com.google.android.gms.maps.model.LatLng;
|
|
7
|
+
import com.google.android.gms.maps.model.LatLngBounds;
|
|
8
|
+
|
|
9
|
+
public class OnRegionChangeEvent extends Event<OnRegionChangeEvent> {
|
|
10
|
+
public static final String EVENT_NAME = "topChange";
|
|
11
|
+
|
|
12
|
+
private final WritableMap payload;
|
|
13
|
+
|
|
14
|
+
public OnRegionChangeEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
15
|
+
super(surfaceId, viewId);
|
|
16
|
+
this.payload = payload;
|
|
17
|
+
}
|
|
18
|
+
public static WritableMap payLoadFor(LatLngBounds bounds, boolean continuous, boolean isGesture){
|
|
19
|
+
|
|
20
|
+
WritableMap event = new WritableNativeMap();
|
|
21
|
+
event.putBoolean("continuous", continuous);
|
|
22
|
+
WritableMap region = new WritableNativeMap();
|
|
23
|
+
LatLng center = bounds.getCenter();
|
|
24
|
+
region.putDouble("latitude", center.latitude);
|
|
25
|
+
region.putDouble("longitude", center.longitude);
|
|
26
|
+
region.putDouble("latitudeDelta", bounds.northeast.latitude - bounds.southwest.latitude);
|
|
27
|
+
region.putDouble("longitudeDelta", bounds.northeast.longitude - bounds.southwest.longitude);
|
|
28
|
+
event.putMap("region", region);
|
|
29
|
+
event.putBoolean("isGesture", isGesture);
|
|
30
|
+
return event;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Override
|
|
34
|
+
public String getEventName() {
|
|
35
|
+
return EVENT_NAME;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public boolean canCoalesce() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.rnmaps.fabric.event;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap;
|
|
4
|
+
import com.facebook.react.uimanager.events.Event;
|
|
5
|
+
|
|
6
|
+
public class OnUserLocationChangeEvent extends Event<OnUserLocationChangeEvent> {
|
|
7
|
+
public static final String EVENT_NAME = "topUserLocationChange";
|
|
8
|
+
|
|
9
|
+
private final WritableMap payload;
|
|
10
|
+
|
|
11
|
+
public OnUserLocationChangeEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
12
|
+
super(surfaceId, viewId);
|
|
13
|
+
this.payload = payload;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
public String getEventName() {
|
|
18
|
+
return EVENT_NAME;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Override
|
|
22
|
+
public WritableMap getEventData() {
|
|
23
|
+
return payload;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -7,17 +7,30 @@ import com.facebook.react.bridge.NativeModule;
|
|
|
7
7
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
8
|
import com.facebook.react.module.model.ReactModuleInfo;
|
|
9
9
|
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
10
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
11
|
+
import com.rnmaps.fabric.MapViewManager;
|
|
10
12
|
import com.rnmaps.fabric.NativeAirMapsModule;
|
|
11
13
|
import com.facebook.fbreact.specs.NativeAirMapsModuleSpec;
|
|
12
14
|
|
|
15
|
+
import java.util.Collections;
|
|
13
16
|
import java.util.HashMap;
|
|
17
|
+
import java.util.List;
|
|
14
18
|
import java.util.Map;
|
|
15
19
|
|
|
16
20
|
public class MapAirModulePackage extends TurboReactPackage {
|
|
17
21
|
|
|
22
|
+
@Override
|
|
23
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
24
|
+
return Collections.singletonList(new MapViewManager(reactContext));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
18
28
|
@Override
|
|
19
29
|
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
20
|
-
if (
|
|
30
|
+
if (MapViewManager.REACT_CLASS.equals(name)) {
|
|
31
|
+
return new MapViewManager(reactContext);
|
|
32
|
+
}
|
|
33
|
+
if (NativeAirMapsModuleSpec.NAME.equals(name)) {
|
|
21
34
|
return new NativeAirMapsModule(reactContext);
|
|
22
35
|
} else {
|
|
23
36
|
return null;
|
|
@@ -23,9 +23,12 @@ import androidx.core.content.PermissionChecker;
|
|
|
23
23
|
import androidx.core.view.GestureDetectorCompat;
|
|
24
24
|
import androidx.core.view.MotionEventCompat;
|
|
25
25
|
|
|
26
|
+
import com.facebook.react.common.MapBuilder;
|
|
27
|
+
|
|
26
28
|
import com.facebook.react.bridge.Arguments;
|
|
27
29
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
28
30
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
31
|
+
import com.facebook.react.bridge.ReactContext;
|
|
29
32
|
import com.facebook.react.bridge.ReadableArray;
|
|
30
33
|
import com.facebook.react.bridge.ReadableMap;
|
|
31
34
|
import com.facebook.react.bridge.WritableArray;
|
|
@@ -35,6 +38,7 @@ import com.facebook.react.bridge.WritableNativeMap;
|
|
|
35
38
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
36
39
|
import com.facebook.react.uimanager.UIManagerHelper;
|
|
37
40
|
import com.facebook.react.uimanager.common.UIManagerType;
|
|
41
|
+
import com.facebook.react.uimanager.events.Event;
|
|
38
42
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
39
43
|
import com.google.android.gms.maps.CameraUpdate;
|
|
40
44
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
@@ -77,6 +81,7 @@ import java.util.HashMap;
|
|
|
77
81
|
import java.util.List;
|
|
78
82
|
import java.util.Map;
|
|
79
83
|
import java.util.concurrent.ExecutionException;
|
|
84
|
+
import com.rnmaps.fabric.event.*;
|
|
80
85
|
|
|
81
86
|
public class MapView extends com.google.android.gms.maps.MapView implements GoogleMap.InfoWindowAdapter,
|
|
82
87
|
GoogleMap.OnMarkerDragListener, OnMapReadyCallback, GoogleMap.OnPoiClickListener, GoogleMap.OnIndoorStateChangeListener {
|
|
@@ -128,12 +133,10 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
128
133
|
private final Map<TileOverlay, MapHeatmap> heatmapMap = new HashMap<>();
|
|
129
134
|
private final Map<TileOverlay, MapGradientPolyline> gradientPolylineMap = new HashMap<>();
|
|
130
135
|
private final GestureDetectorCompat gestureDetector;
|
|
131
|
-
private final MapManager manager;
|
|
132
136
|
private LifecycleEventListener lifecycleListener;
|
|
133
137
|
private boolean paused = false;
|
|
134
138
|
private boolean destroyed = false;
|
|
135
139
|
private final ThemedReactContext context;
|
|
136
|
-
private final EventDispatcher eventDispatcher;
|
|
137
140
|
private final FusedLocationSource fusedLocationSource;
|
|
138
141
|
|
|
139
142
|
private final ViewAttacherGroup attacherGroup;
|
|
@@ -168,15 +171,12 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
168
171
|
}
|
|
169
172
|
return superContext;
|
|
170
173
|
}
|
|
171
|
-
|
|
172
|
-
public MapView(ThemedReactContext reactContext, ReactApplicationContext appContext,
|
|
173
|
-
MapManager manager,
|
|
174
|
+
public MapView(ThemedReactContext context,
|
|
174
175
|
GoogleMapOptions googleMapOptions) {
|
|
175
|
-
super(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
this.context =
|
|
179
|
-
MapsInitializer.initialize(context, this.manager.renderer, renderer -> Log.d("AirMapRenderer", renderer.toString()));
|
|
176
|
+
super(context, googleMapOptions);
|
|
177
|
+
// todo add support for legacy renderer
|
|
178
|
+
MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, renderer -> Log.d("AirMapRenderer", renderer.toString()));
|
|
179
|
+
this.context = context;
|
|
180
180
|
super.onCreate(null);
|
|
181
181
|
super.onResume();
|
|
182
182
|
super.getMapAsync(this);
|
|
@@ -186,41 +186,34 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
186
186
|
fusedLocationSource = new FusedLocationSource(context);
|
|
187
187
|
|
|
188
188
|
gestureDetector =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
189
|
+
new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
|
|
190
|
+
|
|
191
|
+
@Override
|
|
192
|
+
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
|
|
193
|
+
float distanceY) {
|
|
194
|
+
if (handlePanDrag) {
|
|
195
|
+
onPanDrag(e2);
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@Override
|
|
201
|
+
public boolean onDoubleTap(MotionEvent ev) {
|
|
202
|
+
onDoublePress(ev);
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
206
|
|
|
207
207
|
this.addOnLayoutChangeListener(new OnLayoutChangeListener() {
|
|
208
208
|
@Override public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
|
209
|
-
|
|
209
|
+
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
|
210
210
|
if (!paused) {
|
|
211
211
|
MapView.this.cacheView();
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
-
int uiManagerType = UIManagerType.DEFAULT;
|
|
217
|
-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
218
|
-
uiManagerType = UIManagerType.FABRIC;
|
|
219
|
-
}
|
|
220
216
|
|
|
221
|
-
eventDispatcher = UIManagerHelper
|
|
222
|
-
.getUIManager(reactContext, uiManagerType)
|
|
223
|
-
.getEventDispatcher();
|
|
224
217
|
|
|
225
218
|
// Set up a parent view for triggering visibility in subviews that depend on it.
|
|
226
219
|
// Mainly ReactImageView depends on Fresco which depends on onVisibilityChanged() event
|
|
@@ -234,6 +227,33 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
234
227
|
addView(attacherGroup);
|
|
235
228
|
}
|
|
236
229
|
|
|
230
|
+
public MapView(ThemedReactContext reactContext, ReactApplicationContext appContext,
|
|
231
|
+
MapManager manager,
|
|
232
|
+
GoogleMapOptions googleMapOptions) {
|
|
233
|
+
this(null, googleMapOptions);
|
|
234
|
+
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
@FunctionalInterface
|
|
239
|
+
public interface EventCreator<T extends Event> {
|
|
240
|
+
T create(int surfaceId, int viewId, WritableMap payload);
|
|
241
|
+
}
|
|
242
|
+
private <T extends Event> void dispatchEvent(WritableMap payload, EventCreator<T> creator) {
|
|
243
|
+
// Cast context to ReactContext
|
|
244
|
+
ReactContext reactContext = context;
|
|
245
|
+
|
|
246
|
+
// Get the event dispatcher
|
|
247
|
+
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, getId());
|
|
248
|
+
|
|
249
|
+
// If there is a dispatcher, create and dispatch the event
|
|
250
|
+
if (eventDispatcher != null) {
|
|
251
|
+
int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
|
|
252
|
+
T event = creator.create(surfaceId, getId(), payload);
|
|
253
|
+
eventDispatcher.dispatchEvent(event);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
237
257
|
@Override
|
|
238
258
|
public void onMapReady(@NonNull final GoogleMap map) {
|
|
239
259
|
if (destroyed) {
|
|
@@ -257,8 +277,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
257
277
|
this.map.setOnIndoorStateChangeListener(this);
|
|
258
278
|
|
|
259
279
|
applyBridgedProps();
|
|
260
|
-
|
|
261
|
-
manager.pushEvent(context, this, "onMapReady", new WritableNativeMap());
|
|
280
|
+
dispatchEvent(new WritableNativeMap(), OnMapReadyEvent::new);
|
|
262
281
|
|
|
263
282
|
final MapView view = this;
|
|
264
283
|
|
|
@@ -278,8 +297,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
278
297
|
coordinate.putBoolean("isFromMockProvider", location.isFromMockProvider());
|
|
279
298
|
|
|
280
299
|
event.putMap("coordinate", coordinate);
|
|
281
|
-
|
|
282
|
-
manager.pushEvent(context, view, "onUserLocationChange", event);
|
|
300
|
+
dispatchEvent(event, OnUserLocationChangeEvent::new);
|
|
283
301
|
}
|
|
284
302
|
});
|
|
285
303
|
|
|
@@ -288,15 +306,19 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
288
306
|
public boolean onMarkerClick(@NonNull Marker marker) {
|
|
289
307
|
MapMarker airMapMarker = getMarkerMap(marker);
|
|
290
308
|
|
|
291
|
-
WritableMap
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
309
|
+
WritableMap eventData = makeClickEventData(marker.getPosition());
|
|
310
|
+
eventData.putString("action", "marker-press");
|
|
311
|
+
eventData.putString("id", airMapMarker.getIdentifier());
|
|
312
|
+
|
|
313
|
+
dispatchEvent(eventData, OnMarkerPressEvent::new);
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
eventData = makeClickEventData(marker.getPosition());
|
|
317
|
+
eventData.putString("action", "marker-press");
|
|
318
|
+
eventData.putString("id", airMapMarker.getIdentifier());
|
|
319
|
+
|
|
320
|
+
dispatchEvent(eventData, OnPressEvent::new);
|
|
295
321
|
|
|
296
|
-
event = makeClickEventData(marker.getPosition());
|
|
297
|
-
event.putString("action", "marker-press");
|
|
298
|
-
event.putString("id", airMapMarker.getIdentifier());
|
|
299
|
-
manager.pushEvent(context, airMapMarker, "onPress", event);
|
|
300
322
|
|
|
301
323
|
handleMarkerSelection(airMapMarker);
|
|
302
324
|
|
|
@@ -317,7 +339,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
317
339
|
public void onPolygonClick(@NonNull Polygon polygon) {
|
|
318
340
|
WritableMap event = makeClickEventData(tapLocation);
|
|
319
341
|
event.putString("action", "polygon-press");
|
|
320
|
-
|
|
342
|
+
// todo: use Fabric events
|
|
343
|
+
// manager.pushEvent(context, polygonMap.get(polygon), "onPress", event);
|
|
321
344
|
}
|
|
322
345
|
});
|
|
323
346
|
|
|
@@ -326,7 +349,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
326
349
|
public void onPolylineClick(@NonNull Polyline polyline) {
|
|
327
350
|
WritableMap event = makeClickEventData(tapLocation);
|
|
328
351
|
event.putString("action", "polyline-press");
|
|
329
|
-
|
|
352
|
+
// todo: use Fabric events
|
|
353
|
+
// manager.pushEvent(context, polylineMap.get(polyline), "onPress", event);
|
|
330
354
|
}
|
|
331
355
|
});
|
|
332
356
|
|
|
@@ -335,17 +359,20 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
335
359
|
public void onInfoWindowClick(@NonNull Marker marker) {
|
|
336
360
|
WritableMap event = makeClickEventData(marker.getPosition());
|
|
337
361
|
event.putString("action", "callout-press");
|
|
338
|
-
|
|
362
|
+
// todo: use Fabric events
|
|
363
|
+
// manager.pushEvent(context, view, "onCalloutPress", event);
|
|
339
364
|
|
|
340
365
|
event = makeClickEventData(marker.getPosition());
|
|
341
366
|
event.putString("action", "callout-press");
|
|
342
367
|
MapMarker markerView = getMarkerMap(marker);
|
|
343
|
-
|
|
368
|
+
// todo: use Fabric events
|
|
369
|
+
// manager.pushEvent(context, markerView, "onCalloutPress", event);
|
|
344
370
|
|
|
345
371
|
event = makeClickEventData(marker.getPosition());
|
|
346
372
|
event.putString("action", "callout-press");
|
|
347
373
|
MapCallout infoWindow = markerView.getCalloutView();
|
|
348
|
-
|
|
374
|
+
// todo: use Fabric events
|
|
375
|
+
// if (infoWindow != null) manager.pushEvent(context, infoWindow, "onPress", event);
|
|
349
376
|
}
|
|
350
377
|
});
|
|
351
378
|
|
|
@@ -354,7 +381,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
354
381
|
public void onMapClick(@NonNull LatLng point) {
|
|
355
382
|
WritableMap event = makeClickEventData(point);
|
|
356
383
|
event.putString("action", "press");
|
|
357
|
-
|
|
384
|
+
dispatchEvent(event, OnPressEvent::new);
|
|
358
385
|
|
|
359
386
|
handleMarkerSelection(null);
|
|
360
387
|
}
|
|
@@ -365,7 +392,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
365
392
|
public void onMapLongClick(@NonNull LatLng point) {
|
|
366
393
|
WritableMap event = makeClickEventData(point);
|
|
367
394
|
event.putString("action", "long-press");
|
|
368
|
-
|
|
395
|
+
// todo: use Fabric events
|
|
396
|
+
// manager.pushEvent(context, view, "onLongPress", makeClickEventData(point));
|
|
369
397
|
}
|
|
370
398
|
});
|
|
371
399
|
|
|
@@ -374,7 +402,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
374
402
|
public void onGroundOverlayClick(@NonNull GroundOverlay groundOverlay) {
|
|
375
403
|
WritableMap event = makeClickEventData(groundOverlay.getPosition());
|
|
376
404
|
event.putString("action", "overlay-press");
|
|
377
|
-
|
|
405
|
+
// todo: use Fabric events
|
|
406
|
+
// manager.pushEvent(context, overlayMap.get(groundOverlay), "onPress", event);
|
|
378
407
|
}
|
|
379
408
|
});
|
|
380
409
|
|
|
@@ -385,7 +414,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
385
414
|
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == reason;
|
|
386
415
|
WritableMap event = new WritableNativeMap();
|
|
387
416
|
event.putBoolean("isGesture", isGesture);
|
|
388
|
-
|
|
417
|
+
// todo: use Fabric events
|
|
418
|
+
// manager.pushEvent(context, view, "onRegionChangeStart", event);
|
|
389
419
|
}
|
|
390
420
|
});
|
|
391
421
|
|
|
@@ -396,9 +426,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
396
426
|
|
|
397
427
|
cameraLastIdleBounds = null;
|
|
398
428
|
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
eventDispatcher.dispatchEvent(event);
|
|
429
|
+
WritableMap payload = OnRegionChangeEvent.payLoadFor(bounds, true, isGesture);
|
|
430
|
+
dispatchEvent(payload, OnRegionChangeEvent::new);
|
|
402
431
|
}
|
|
403
432
|
});
|
|
404
433
|
|
|
@@ -414,7 +443,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
414
443
|
boolean isGesture = GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE == cameraMoveReason;
|
|
415
444
|
|
|
416
445
|
RegionChangeEvent event = new RegionChangeEvent(getId(), bounds, false, isGesture);
|
|
417
|
-
|
|
446
|
+
// todo: use Fabric events
|
|
447
|
+
// eventDispatcher.dispatchEvent(event);
|
|
418
448
|
}
|
|
419
449
|
}
|
|
420
450
|
});
|
|
@@ -422,7 +452,8 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
422
452
|
map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
|
|
423
453
|
@Override public void onMapLoaded() {
|
|
424
454
|
isMapLoaded = true;
|
|
425
|
-
|
|
455
|
+
// todo: use Fabric events
|
|
456
|
+
// manager.pushEvent(context, view, "onMapLoaded", new WritableNativeMap());
|
|
426
457
|
MapView.this.cacheView();
|
|
427
458
|
}
|
|
428
459
|
});
|
|
@@ -484,24 +515,28 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
484
515
|
event = makeClickEventData(selectedMarker.getPosition());
|
|
485
516
|
event.putString("action", "marker-deselect");
|
|
486
517
|
event.putString("id", selectedMarker.getIdentifier());
|
|
487
|
-
|
|
518
|
+
// todo: use Fabric events
|
|
519
|
+
// manager.pushEvent(context, selectedMarker, "onDeselect", event);
|
|
488
520
|
|
|
489
521
|
event = makeClickEventData(selectedMarker.getPosition());
|
|
490
522
|
event.putString("action", "marker-deselect");
|
|
491
523
|
event.putString("id", selectedMarker.getIdentifier());
|
|
492
|
-
|
|
524
|
+
// todo: use Fabric events
|
|
525
|
+
// manager.pushEvent(context, this, "onMarkerDeselect", event);
|
|
493
526
|
}
|
|
494
527
|
|
|
495
528
|
if (target != null) {
|
|
496
529
|
event = makeClickEventData(target.getPosition());
|
|
497
530
|
event.putString("action", "marker-select");
|
|
498
531
|
event.putString("id", target.getIdentifier());
|
|
499
|
-
|
|
532
|
+
// todo: use Fabric events
|
|
533
|
+
// manager.pushEvent(context, target, "onSelect", event);
|
|
500
534
|
|
|
501
535
|
event = makeClickEventData(target.getPosition());
|
|
502
536
|
event.putString("action", "marker-select");
|
|
503
537
|
event.putString("id", target.getIdentifier());
|
|
504
|
-
|
|
538
|
+
// todo: use Fabric events
|
|
539
|
+
// manager.pushEvent(context, this, "onMarkerSelect", event);
|
|
505
540
|
}
|
|
506
541
|
|
|
507
542
|
selectedMarker = target;
|
|
@@ -513,6 +548,22 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
513
548
|
}
|
|
514
549
|
|
|
515
550
|
|
|
551
|
+
public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
552
|
+
return MapBuilder.of(
|
|
553
|
+
OnMarkerPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnMarkerPressEvent.EVENT_NAME),
|
|
554
|
+
OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME)
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
public static Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
559
|
+
return MapBuilder.of(
|
|
560
|
+
OnMapReadyEvent.EVENT_NAME, MapBuilder.of("registrationName", OnMapReadyEvent.EVENT_NAME),
|
|
561
|
+
OnUserLocationChangeEvent.EVENT_NAME, MapBuilder.of("registrationName", OnUserLocationChangeEvent.EVENT_NAME),
|
|
562
|
+
OnRegionChangeEvent.EVENT_NAME, MapBuilder.of("registrationName", OnRegionChangeEvent.EVENT_NAME)
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
|
|
516
567
|
/*
|
|
517
568
|
onDestroy is final method so I can't override it.
|
|
518
569
|
*/
|
|
@@ -679,6 +730,9 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
679
730
|
map.getUiSettings().setMapToolbarEnabled(toolbarEnabled);
|
|
680
731
|
}
|
|
681
732
|
}
|
|
733
|
+
public void setMapType(int mapType){
|
|
734
|
+
map.setMapType(mapType);
|
|
735
|
+
}
|
|
682
736
|
|
|
683
737
|
public void setCacheEnabled(boolean cacheEnabled) {
|
|
684
738
|
this.cacheEnabled = cacheEnabled;
|
|
@@ -1182,31 +1236,37 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1182
1236
|
@Override
|
|
1183
1237
|
public void onMarkerDragStart(Marker marker) {
|
|
1184
1238
|
WritableMap event = makeClickEventData(marker.getPosition());
|
|
1185
|
-
|
|
1239
|
+
// todo: use Fabric events
|
|
1240
|
+
// manager.pushEvent(context, this, "onMarkerDragStart", event);
|
|
1186
1241
|
|
|
1187
1242
|
MapMarker markerView = getMarkerMap(marker);
|
|
1188
1243
|
event = makeClickEventData(marker.getPosition());
|
|
1189
|
-
|
|
1244
|
+
// todo: use Fabric events
|
|
1245
|
+
// manager.pushEvent(context, markerView, "onDragStart", event);
|
|
1190
1246
|
}
|
|
1191
1247
|
|
|
1192
1248
|
@Override
|
|
1193
1249
|
public void onMarkerDrag(Marker marker) {
|
|
1194
1250
|
WritableMap event = makeClickEventData(marker.getPosition());
|
|
1195
|
-
|
|
1251
|
+
// todo: use Fabric events
|
|
1252
|
+
/// manager.pushEvent(context, this, "onMarkerDrag", event);
|
|
1196
1253
|
|
|
1197
1254
|
MapMarker markerView = getMarkerMap(marker);
|
|
1198
1255
|
event = makeClickEventData(marker.getPosition());
|
|
1199
|
-
|
|
1256
|
+
// todo: use Fabric events
|
|
1257
|
+
// manager.pushEvent(context, markerView, "onDrag", event);
|
|
1200
1258
|
}
|
|
1201
1259
|
|
|
1202
1260
|
@Override
|
|
1203
1261
|
public void onMarkerDragEnd(Marker marker) {
|
|
1204
1262
|
WritableMap event = makeClickEventData(marker.getPosition());
|
|
1205
|
-
|
|
1263
|
+
// todo: use Fabric events
|
|
1264
|
+
// manager.pushEvent(context, this, "onMarkerDragEnd", event);
|
|
1206
1265
|
|
|
1207
1266
|
MapMarker markerView = getMarkerMap(marker);
|
|
1208
1267
|
event = makeClickEventData(marker.getPosition());
|
|
1209
|
-
|
|
1268
|
+
// todo: use Fabric events
|
|
1269
|
+
// manager.pushEvent(context, markerView, "onDragEnd", event);
|
|
1210
1270
|
}
|
|
1211
1271
|
|
|
1212
1272
|
@Override
|
|
@@ -1215,8 +1275,8 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1215
1275
|
|
|
1216
1276
|
event.putString("placeId", poi.placeId);
|
|
1217
1277
|
event.putString("name", poi.name);
|
|
1218
|
-
|
|
1219
|
-
manager.pushEvent(context, this, "onPoiClick", event);
|
|
1278
|
+
// todo: use Fabric events
|
|
1279
|
+
// manager.pushEvent(context, this, "onPoiClick", event);
|
|
1220
1280
|
}
|
|
1221
1281
|
|
|
1222
1282
|
private ProgressBar getMapLoadingProgressBar() {
|
|
@@ -1309,7 +1369,8 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1309
1369
|
Point point = new Point((int) ev.getX(), (int) ev.getY());
|
|
1310
1370
|
LatLng coords = this.map.getProjection().fromScreenLocation(point);
|
|
1311
1371
|
WritableMap event = makeClickEventData(coords);
|
|
1312
|
-
|
|
1372
|
+
// todo: use Fabric events
|
|
1373
|
+
// manager.pushEvent(context, this, "onPanDrag", event);
|
|
1313
1374
|
}
|
|
1314
1375
|
|
|
1315
1376
|
public void onDoublePress(MotionEvent ev) {
|
|
@@ -1317,7 +1378,8 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1317
1378
|
Point point = new Point((int) ev.getX(), (int) ev.getY());
|
|
1318
1379
|
LatLng coords = this.map.getProjection().fromScreenLocation(point);
|
|
1319
1380
|
WritableMap event = makeClickEventData(coords);
|
|
1320
|
-
|
|
1381
|
+
// todo: use Fabric events
|
|
1382
|
+
// manager.pushEvent(context, this, "onDoublePress", event);
|
|
1321
1383
|
}
|
|
1322
1384
|
|
|
1323
1385
|
public void setKmlSrc(String kmlSrc) {
|
|
@@ -1335,14 +1397,16 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1335
1397
|
WritableArray markers = new WritableNativeArray();
|
|
1336
1398
|
|
|
1337
1399
|
if (kmlLayer.getContainers() == null) {
|
|
1338
|
-
|
|
1400
|
+
// todo: use Fabric events
|
|
1401
|
+
// manager.pushEvent(context, this, "onKmlReady", pointers);
|
|
1339
1402
|
return;
|
|
1340
1403
|
}
|
|
1341
1404
|
|
|
1342
1405
|
//Retrieve a nested container within the first container
|
|
1343
1406
|
KmlContainer container = kmlLayer.getContainers().iterator().next();
|
|
1344
1407
|
if (container == null || container.getContainers() == null) {
|
|
1345
|
-
|
|
1408
|
+
// todo: use Fabric events
|
|
1409
|
+
// manager.pushEvent(context, this, "onKmlReady", pointers);
|
|
1346
1410
|
return;
|
|
1347
1411
|
}
|
|
1348
1412
|
|
|
@@ -1376,7 +1440,8 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1376
1440
|
options.position(latLng);
|
|
1377
1441
|
options.title(title);
|
|
1378
1442
|
options.snippet(snippet);
|
|
1379
|
-
|
|
1443
|
+
// FIXME: get markerManager from somewhere
|
|
1444
|
+
/*
|
|
1380
1445
|
MapMarker marker = new MapMarker(context, options, this.manager.getMarkerManager());
|
|
1381
1446
|
|
|
1382
1447
|
if (placemark.getInlineStyle() != null
|
|
@@ -1393,17 +1458,19 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1393
1458
|
|
|
1394
1459
|
addFeature(marker, index++);
|
|
1395
1460
|
|
|
1461
|
+
|
|
1396
1462
|
WritableMap loadedMarker = makeClickEventData(latLng);
|
|
1397
1463
|
loadedMarker.putString("id", identifier);
|
|
1398
1464
|
loadedMarker.putString("title", title);
|
|
1399
1465
|
loadedMarker.putString("description", snippet);
|
|
1400
1466
|
|
|
1401
1467
|
markers.pushMap(loadedMarker);
|
|
1468
|
+
*/
|
|
1402
1469
|
}
|
|
1403
1470
|
|
|
1404
1471
|
pointers.putArray("markers", markers);
|
|
1405
|
-
|
|
1406
|
-
|
|
1472
|
+
// todo: use Fabric events
|
|
1473
|
+
// manager.pushEvent(context, this, "onKmlReady", pointers);
|
|
1407
1474
|
|
|
1408
1475
|
} catch (XmlPullParserException | IOException | InterruptedException | ExecutionException e) {
|
|
1409
1476
|
e.printStackTrace();
|
|
@@ -1432,8 +1499,8 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1432
1499
|
indoorBuilding.putBoolean("underground", building.isUnderground());
|
|
1433
1500
|
|
|
1434
1501
|
event.putMap("IndoorBuilding", indoorBuilding);
|
|
1435
|
-
|
|
1436
|
-
|
|
1502
|
+
// todo: use Fabric events
|
|
1503
|
+
// manager.pushEvent(context, this, "onIndoorBuildingFocused", event);
|
|
1437
1504
|
} else {
|
|
1438
1505
|
WritableMap event = Arguments.createMap();
|
|
1439
1506
|
WritableArray levelsArray = Arguments.createArray();
|
|
@@ -1443,8 +1510,8 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1443
1510
|
indoorBuilding.putBoolean("underground", false);
|
|
1444
1511
|
|
|
1445
1512
|
event.putMap("IndoorBuilding", indoorBuilding);
|
|
1446
|
-
|
|
1447
|
-
|
|
1513
|
+
// todo: use Fabric events
|
|
1514
|
+
// manager.pushEvent(context, this, "onIndoorBuildingFocused", event);
|
|
1448
1515
|
}
|
|
1449
1516
|
}
|
|
1450
1517
|
|
|
@@ -1467,8 +1534,8 @@ public static CameraPosition cameraPositionFromMap(ReadableMap camera){
|
|
|
1467
1534
|
indoorlevel.putString("shortName", level.getShortName());
|
|
1468
1535
|
|
|
1469
1536
|
event.putMap("IndoorLevel", indoorlevel);
|
|
1470
|
-
|
|
1471
|
-
|
|
1537
|
+
// todo: use Fabric events
|
|
1538
|
+
// manager.pushEvent(context, this, "onIndoorLevelActivated", event);
|
|
1472
1539
|
}
|
|
1473
1540
|
|
|
1474
1541
|
public void setIndoorActiveLevelIndex(int activeLevelIndex) {
|