react-native-maps 1.21.0-alpha.86 → 1.21.0-alpha.88
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/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +39 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnKmlReadyEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/maps/MapView.java +24 -21
- package/lib/MapView.d.ts +1 -0
- package/lib/MapView.js +8 -7
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ import static com.rnmaps.maps.MapModule.SNAPSHOT_RESULT_FILE;
|
|
|
7
7
|
import static com.rnmaps.maps.MapModule.closeQuietly;
|
|
8
8
|
|
|
9
9
|
import android.graphics.Bitmap;
|
|
10
|
+
import android.location.Address;
|
|
11
|
+
import android.location.Geocoder;
|
|
10
12
|
import android.net.Uri;
|
|
11
13
|
import android.util.Base64;
|
|
12
14
|
import android.util.DisplayMetrics;
|
|
@@ -33,6 +35,8 @@ import org.json.JSONObject;
|
|
|
33
35
|
import java.io.ByteArrayOutputStream;
|
|
34
36
|
import java.io.File;
|
|
35
37
|
import java.io.FileOutputStream;
|
|
38
|
+
import java.io.IOException;
|
|
39
|
+
import java.util.List;
|
|
36
40
|
|
|
37
41
|
public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
38
42
|
public NativeAirMapsModule(ReactApplicationContext reactContext) {
|
|
@@ -188,6 +192,41 @@ public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
|
188
192
|
|
|
189
193
|
@Override
|
|
190
194
|
public void getAddressFromCoordinates(double tag, ReadableMap coordinate, Promise promise) {
|
|
195
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
196
|
+
|
|
197
|
+
if (coordinate == null ||
|
|
198
|
+
!coordinate.hasKey("latitude") ||
|
|
199
|
+
!coordinate.hasKey("longitude")) {
|
|
200
|
+
promise.reject("Invalid coordinate format");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
Geocoder geocoder = new Geocoder(context);
|
|
204
|
+
try {
|
|
205
|
+
List<Address> list =
|
|
206
|
+
geocoder.getFromLocation(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"), 1);
|
|
207
|
+
if (list.isEmpty()) {
|
|
208
|
+
promise.reject("Can not get address location");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
Address address = list.get(0);
|
|
212
|
+
|
|
213
|
+
WritableMap addressJson = new WritableNativeMap();
|
|
214
|
+
addressJson.putString("name", address.getFeatureName());
|
|
215
|
+
addressJson.putString("locality", address.getLocality());
|
|
216
|
+
addressJson.putString("thoroughfare", address.getThoroughfare());
|
|
217
|
+
addressJson.putString("subThoroughfare", address.getSubThoroughfare());
|
|
218
|
+
addressJson.putString("subLocality", address.getSubLocality());
|
|
219
|
+
addressJson.putString("administrativeArea", address.getAdminArea());
|
|
220
|
+
addressJson.putString("subAdministrativeArea", address.getSubAdminArea());
|
|
221
|
+
addressJson.putString("postalCode", address.getPostalCode());
|
|
222
|
+
addressJson.putString("countryCode", address.getCountryCode());
|
|
223
|
+
addressJson.putString("country", address.getCountryName());
|
|
224
|
+
|
|
225
|
+
promise.resolve(addressJson);
|
|
226
|
+
} catch (IOException e) {
|
|
227
|
+
promise.reject("Can not get address location");
|
|
228
|
+
}
|
|
229
|
+
|
|
191
230
|
|
|
192
231
|
}
|
|
193
232
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.rnmaps.fabric.event;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.WritableMap;
|
|
6
|
+
import com.facebook.react.uimanager.events.Event;
|
|
7
|
+
|
|
8
|
+
public class OnKmlReadyEvent extends Event<OnKmlReadyEvent> {
|
|
9
|
+
public static final String EVENT_NAME = "topKmlReady";
|
|
10
|
+
|
|
11
|
+
private final WritableMap payload;
|
|
12
|
+
|
|
13
|
+
public OnKmlReadyEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
14
|
+
super(surfaceId, viewId);
|
|
15
|
+
this.payload = payload;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@NonNull
|
|
19
|
+
@Override
|
|
20
|
+
public String getEventName() {
|
|
21
|
+
return EVENT_NAME;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public WritableMap getEventData() {
|
|
26
|
+
return payload;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -12,7 +12,6 @@ import android.location.Location;
|
|
|
12
12
|
import androidx.lifecycle.DefaultLifecycleObserver;
|
|
13
13
|
import androidx.lifecycle.LifecycleOwner;
|
|
14
14
|
|
|
15
|
-
import android.util.Log;
|
|
16
15
|
import android.view.GestureDetector;
|
|
17
16
|
import android.view.MotionEvent;
|
|
18
17
|
import android.view.View;
|
|
@@ -80,6 +79,7 @@ import java.io.InputStream;
|
|
|
80
79
|
import java.util.ArrayList;
|
|
81
80
|
import java.util.Arrays;
|
|
82
81
|
import java.util.HashMap;
|
|
82
|
+
import java.util.Iterator;
|
|
83
83
|
import java.util.List;
|
|
84
84
|
import java.util.Map;
|
|
85
85
|
import java.util.concurrent.ExecutionException;
|
|
@@ -501,8 +501,10 @@ public void onCreate(LifecycleOwner owner) {
|
|
|
501
501
|
public void onPolylineClick(@NonNull Polyline polyline) {
|
|
502
502
|
WritableMap event = makeClickEventData(tapLocation);
|
|
503
503
|
event.putString("action", "polyline-press");
|
|
504
|
-
|
|
505
|
-
|
|
504
|
+
dispatchEvent(event, OnPressEvent::new);
|
|
505
|
+
event = makeClickEventData(tapLocation);
|
|
506
|
+
dispatchEvent(event, OnPressEvent::new, polylineMap.get(polyline).getId(), context);
|
|
507
|
+
|
|
506
508
|
}
|
|
507
509
|
});
|
|
508
510
|
|
|
@@ -550,8 +552,10 @@ public void onCreate(LifecycleOwner owner) {
|
|
|
550
552
|
public void onGroundOverlayClick(@NonNull GroundOverlay groundOverlay) {
|
|
551
553
|
WritableMap event = makeClickEventData(groundOverlay.getPosition());
|
|
552
554
|
event.putString("action", "overlay-press");
|
|
553
|
-
|
|
554
|
-
|
|
555
|
+
|
|
556
|
+
dispatchEvent(event, OnPressEvent::new);
|
|
557
|
+
event = makeClickEventData(groundOverlay.getPosition());
|
|
558
|
+
dispatchEvent(event, OnPressEvent::new,overlayMap.get(groundOverlay).getId(), context);
|
|
555
559
|
}
|
|
556
560
|
});
|
|
557
561
|
|
|
@@ -664,7 +668,8 @@ public void onCreate(LifecycleOwner owner) {
|
|
|
664
668
|
OnUserLocationChangeEvent.EVENT_NAME, MapBuilder.of("registrationName", OnUserLocationChangeEvent.EVENT_NAME),
|
|
665
669
|
OnRegionChangeEvent.EVENT_NAME, MapBuilder.of("registrationName", OnRegionChangeEvent.EVENT_NAME),
|
|
666
670
|
OnIndoorBuildingFocusedEvent.EVENT_NAME, MapBuilder.of("registrationName", OnIndoorBuildingFocusedEvent.EVENT_NAME),
|
|
667
|
-
OnIndoorLevelActivatedEvent.EVENT_NAME, MapBuilder.of("registrationName", OnIndoorLevelActivatedEvent.EVENT_NAME)
|
|
671
|
+
OnIndoorLevelActivatedEvent.EVENT_NAME, MapBuilder.of("registrationName", OnIndoorLevelActivatedEvent.EVENT_NAME),
|
|
672
|
+
OnKmlReadyEvent.EVENT_NAME, MapBuilder.of("registrationName", OnKmlReadyEvent.EVENT_NAME)
|
|
668
673
|
);
|
|
669
674
|
}
|
|
670
675
|
|
|
@@ -1255,15 +1260,16 @@ public void onCreate(LifecycleOwner owner) {
|
|
|
1255
1260
|
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
1256
1261
|
|
|
1257
1262
|
boolean addedPosition = false;
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1263
|
+
if (features.size() > 0) {
|
|
1264
|
+
for (MapFeature feature : features) {
|
|
1265
|
+
if (feature instanceof MapMarker) {
|
|
1266
|
+
Marker marker = (Marker) feature.getFeature();
|
|
1267
|
+
builder.include(marker.getPosition());
|
|
1268
|
+
addedPosition = true;
|
|
1269
|
+
}
|
|
1270
|
+
// TODO(lmr): may want to include shapes / etc.
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1267
1273
|
if (addedPosition) {
|
|
1268
1274
|
LatLngBounds bounds = builder.build();
|
|
1269
1275
|
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 0);
|
|
@@ -1642,16 +1648,14 @@ public void onCreate(LifecycleOwner owner) {
|
|
|
1642
1648
|
WritableArray markers = new WritableNativeArray();
|
|
1643
1649
|
|
|
1644
1650
|
if (kmlLayer.getContainers() == null) {
|
|
1645
|
-
|
|
1646
|
-
// manager.pushEvent(context, this, "onKmlReady", pointers);
|
|
1651
|
+
dispatchEvent(pointers, OnKmlReadyEvent::new);
|
|
1647
1652
|
return;
|
|
1648
1653
|
}
|
|
1649
1654
|
|
|
1650
1655
|
//Retrieve a nested container within the first container
|
|
1651
1656
|
KmlContainer container = kmlLayer.getContainers().iterator().next();
|
|
1652
1657
|
if (container == null || container.getContainers() == null) {
|
|
1653
|
-
|
|
1654
|
-
// manager.pushEvent(context, this, "onKmlReady", pointers);
|
|
1658
|
+
dispatchEvent(pointers, OnKmlReadyEvent::new);
|
|
1655
1659
|
return;
|
|
1656
1660
|
}
|
|
1657
1661
|
|
|
@@ -1714,8 +1718,7 @@ public void onCreate(LifecycleOwner owner) {
|
|
|
1714
1718
|
}
|
|
1715
1719
|
|
|
1716
1720
|
pointers.putArray("markers", markers);
|
|
1717
|
-
|
|
1718
|
-
// manager.pushEvent(context, this, "onKmlReady", pointers);
|
|
1721
|
+
dispatchEvent(new WritableNativeMap(), OnKmlReadyEvent::new);
|
|
1719
1722
|
|
|
1720
1723
|
} catch (XmlPullParserException | IOException | InterruptedException |
|
|
1721
1724
|
ExecutionException e) {
|
package/lib/MapView.d.ts
CHANGED
|
@@ -690,6 +690,7 @@ declare class MapView extends React.Component<MapViewProps, State> {
|
|
|
690
690
|
private handleMapPress;
|
|
691
691
|
private handleMarkerPress;
|
|
692
692
|
private handleMarkerSelect;
|
|
693
|
+
private handleKmlReady;
|
|
693
694
|
private handleMarkerDeselect;
|
|
694
695
|
private handleRegionChange;
|
|
695
696
|
private handleRegionChangeStarted;
|
package/lib/MapView.js
CHANGED
|
@@ -218,13 +218,8 @@ class MapView extends React.Component {
|
|
|
218
218
|
* @return Promise with return type Address
|
|
219
219
|
*/
|
|
220
220
|
addressForCoordinate(coordinate) {
|
|
221
|
-
if (
|
|
222
|
-
return
|
|
223
|
-
}
|
|
224
|
-
else if (react_native_1.Platform.OS === 'ios') {
|
|
225
|
-
if (this.fabricMap.current) {
|
|
226
|
-
return this.fabricMap.current.getAddressFromCoordinates(coordinate);
|
|
227
|
-
}
|
|
221
|
+
if (this.fabricMap.current) {
|
|
222
|
+
return this.fabricMap.current.getAddressFromCoordinates(coordinate);
|
|
228
223
|
}
|
|
229
224
|
return Promise.reject('getAddress not supported on this platform');
|
|
230
225
|
}
|
|
@@ -319,6 +314,11 @@ class MapView extends React.Component {
|
|
|
319
314
|
this.props.onMarkerSelect(event);
|
|
320
315
|
}
|
|
321
316
|
};
|
|
317
|
+
handleKmlReady = (event) => {
|
|
318
|
+
if (this.props.onKmlReady) {
|
|
319
|
+
this.props.onKmlReady(event);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
322
|
handleMarkerDeselect = (event) => {
|
|
323
323
|
if (this.props.onMarkerDeselect) {
|
|
324
324
|
this.props.onMarkerDeselect(event);
|
|
@@ -373,6 +373,7 @@ class MapView extends React.Component {
|
|
|
373
373
|
onMarkerPress: this.handleMarkerPress,
|
|
374
374
|
onMarkerSelect: this.handleMarkerSelect,
|
|
375
375
|
onMarkerDeselect: this.handleMarkerDeselect,
|
|
376
|
+
onKmlReady: this.handleKmlReady,
|
|
376
377
|
userInterfaceStyle: userInterfaceStyle,
|
|
377
378
|
minZoom: minZoomLevel,
|
|
378
379
|
maxZoom: maxZoomLevel,
|
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.88",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|