react-native-maps 2.0.0-beta.5 → 2.0.0-beta.7
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/maps/MapCalloutManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapCircleManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapGradientPolyline.java +4 -4
- package/android/src/main/java/com/rnmaps/maps/MapGradientPolylineManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapHeatmapManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapLiteManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapLocalTile.java +4 -4
- package/android/src/main/java/com/rnmaps/maps/MapLocalTileManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapManager.java +1 -56
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapMarkerManager.java +9 -26
- package/android/src/main/java/com/rnmaps/maps/MapOverlayManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapPolygonManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapPolylineManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapTileProvider.java +4 -4
- package/android/src/main/java/com/rnmaps/maps/MapUrlTileManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapView.java +24 -131
- package/android/src/main/java/com/rnmaps/maps/MapViewModule.java +598 -0
- package/android/src/main/java/com/rnmaps/maps/MapWMSTile.java +6 -6
- package/android/src/main/java/com/rnmaps/maps/MapWMSTileManager.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapsPackage.java +1 -1
- package/android/src/main/java/com/rnmaps/maps/SizeReportingShadowNode.java +1 -1
- package/ios/{AirGoogleMaps/AIRDummyView.h → GoogleMaps/RNMDummyView.h} +3 -3
- package/ios/{AirGoogleMaps/AIRDummyView.m → GoogleMaps/RNMDummyView.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSMarker.h → GoogleMaps/RNMGMSMarker.h} +6 -6
- package/ios/{AirGoogleMaps/AIRGMSMarker.m → GoogleMaps/RNMGMSMarker.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolygon.h → GoogleMaps/RNMGMSPolygon.h} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolygon.m → GoogleMaps/RNMGMSPolygon.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolyline.h → GoogleMaps/RNMGMSPolyline.h} +4 -4
- package/ios/{AirGoogleMaps/AIRGMSPolyline.m → GoogleMaps/RNMGMSPolyline.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMap.h → GoogleMaps/RNMGoogleMap.h} +5 -5
- package/ios/{AirGoogleMaps/AIRGoogleMap.m → GoogleMaps/RNMGoogleMap.m} +77 -77
- package/ios/{AirGoogleMaps/AIRGoogleMapCallout.h → GoogleMaps/RNMGoogleMapCallout.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCallout.m → GoogleMaps/RNMGoogleMapCallout.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutManager.h → GoogleMaps/RNMGoogleMapCalloutManager.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutManager.m → GoogleMaps/RNMGoogleMapCalloutManager.m} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutSubview.h → GoogleMaps/RNMGoogleMapCalloutSubview.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutSubview.m → GoogleMaps/RNMGoogleMapCalloutSubview.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapCalloutSubviewManager.h → GoogleMaps/RNMGoogleMapCalloutSubviewManager.h} +3 -3
- package/ios/GoogleMaps/RNMGoogleMapCalloutSubviewManager.m +28 -0
- package/ios/{AirGoogleMaps/AIRGoogleMapCircle.h → GoogleMaps/RNMGoogleMapCircle.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCircle.m → GoogleMaps/RNMGoogleMapCircle.m} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapCircleManager.h → GoogleMaps/RNMGoogleMapCircleManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapCircleManager.m → GoogleMaps/RNMGoogleMapCircleManager.m} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapHeatmap.h → GoogleMaps/RNMGoogleMapHeatmap.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapHeatmap.m → GoogleMaps/RNMGoogleMapHeatmap.m} +4 -4
- package/ios/GoogleMaps/RNMGoogleMapHeatmapManager.h +11 -0
- package/ios/{AirGoogleMaps/AIRGoogleMapHeatmapManager.m → GoogleMaps/RNMGoogleMapHeatmapManager.m} +9 -9
- package/ios/{AirGoogleMaps/AIRGoogleMapManager.h → GoogleMaps/RNMGoogleMapManager.h} +3 -3
- package/ios/GoogleMaps/RNMGoogleMapManager.m +274 -0
- package/ios/{AirGoogleMaps/AIRGoogleMapMarker.h → GoogleMaps/RNMGoogleMapMarker.h} +15 -15
- package/ios/{AirGoogleMaps/AIRGoogleMapMarker.m → GoogleMaps/RNMGoogleMapMarker.m} +22 -22
- package/ios/{AirGoogleMaps/AIRGoogleMapMarkerManager.h → GoogleMaps/RNMGoogleMapMarkerManager.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapMarkerManager.m → GoogleMaps/RNMGoogleMapMarkerManager.m} +20 -20
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlay.h → GoogleMaps/RNMGoogleMapOverlay.h} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlay.m → GoogleMaps/RNMGoogleMapOverlay.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlayManager.h → GoogleMaps/RNMGoogleMapOverlayManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapOverlayManager.m → GoogleMaps/RNMGoogleMapOverlayManager.m} +6 -6
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygon.h → GoogleMaps/RNMGoogleMapPolygon.h} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygon.m → GoogleMaps/RNMGoogleMapPolygon.m} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapPolylineManager.h → GoogleMaps/RNMGoogleMapPolygonManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygonManager.m → GoogleMaps/RNMGoogleMapPolygonManager.m} +10 -10
- package/ios/{AirGoogleMaps/AIRGoogleMapPolyline.h → GoogleMaps/RNMGoogleMapPolyline.h} +7 -7
- package/ios/{AirGoogleMaps/AIRGoogleMapPolyline.m → GoogleMaps/RNMGoogleMapPolyline.m} +9 -9
- package/ios/{AirGoogleMaps/AIRGoogleMapPolygonManager.h → GoogleMaps/RNMGoogleMapPolylineManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapPolylineManager.m → GoogleMaps/RNMGoogleMapPolylineManager.m} +9 -9
- package/ios/{AirGoogleMaps/AIRGoogleMapUrlTile.h → GoogleMaps/RNMGoogleMapUrlTile.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapUrlTile.m → GoogleMaps/RNMGoogleMapUrlTile.m} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapUrlTileManager.h → GoogleMaps/RNMGoogleMapUrlTileManager.h} +2 -2
- package/ios/{AirGoogleMaps/AIRGoogleMapURLTileManager.m → GoogleMaps/RNMGoogleMapUrlTileManager.m} +7 -7
- package/ios/GoogleMaps/RNMGoogleMapViewModule.h +5 -0
- package/ios/GoogleMaps/RNMGoogleMapViewModule.m +380 -0
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTile.h → GoogleMaps/RNMGoogleMapWMSTile.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTile.m → GoogleMaps/RNMGoogleMapWMSTile.m} +4 -4
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTileManager.h → GoogleMaps/RNMGoogleMapWMSTileManager.h} +3 -3
- package/ios/{AirGoogleMaps/AIRGoogleMapWMSTileManager.m → GoogleMaps/RNMGoogleMapWMSTileManager.m} +8 -8
- package/ios/{AirMaps → Maps}/Callout/SMCalloutView.h +4 -4
- package/ios/{AirMaps/RCTConvert+AirMap.h → Maps/RCTConvert+RNMMap.h} +1 -1
- package/ios/{AirMaps/RCTConvert+AirMap.m → Maps/RCTConvert+RNMMap.m} +8 -8
- package/ios/{AirMaps/AIRMap.h → Maps/RNMMap.h} +8 -8
- package/ios/{AirMaps/AIRMap.m → Maps/RNMMap.m} +56 -56
- package/ios/{AirMaps/AIRMapCallout.h → Maps/RNMMapCallout.h} +1 -1
- package/ios/{AirMaps/AIRMapCallout.m → Maps/RNMMapCallout.m} +2 -2
- package/ios/{AirMaps/AIRMapCircleManager.h → Maps/RNMMapCalloutManager.h} +2 -2
- package/ios/{AirMaps/AIRMapCalloutManager.m → Maps/RNMMapCalloutManager.m} +7 -7
- package/ios/{AirMaps/AIRMapCalloutSubview.h → Maps/RNMMapCalloutSubview.h} +3 -3
- package/ios/{AirMaps/AIRMapCalloutSubview.m → Maps/RNMMapCalloutSubview.m} +4 -4
- package/ios/Maps/RNMMapCalloutSubviewManager.h +14 -0
- package/ios/Maps/RNMMapCalloutSubviewManager.m +24 -0
- package/ios/{AirMaps/AIRMapCircle.h → Maps/RNMMapCircle.h} +5 -5
- package/ios/{AirMaps/AIRMapCircle.m → Maps/RNMMapCircle.m} +3 -3
- package/ios/{AirMaps/AIRMapCalloutManager.h → Maps/RNMMapCircleManager.h} +2 -2
- package/ios/{AirMaps/AIRMapCircleManager.m → Maps/RNMMapCircleManager.m} +7 -7
- package/ios/{AirMaps/AIRMapCoordinate.h → Maps/RNMMapCoordinate.h} +2 -2
- package/ios/{AirMaps/AIRMapCoordinate.m → Maps/RNMMapCoordinate.m} +3 -3
- package/ios/{AirMaps/AIRMapLocalTile.h → Maps/RNMMapLocalTile.h} +7 -7
- package/ios/{AirMaps/AIRMapLocalTile.m → Maps/RNMMapLocalTile.m} +6 -6
- package/ios/{AirMaps/AIRMapLocalTileManager.h → Maps/RNMMapLocalTileManager.h} +3 -3
- package/ios/{AirMaps/AIRMapLocalTileManager.m → Maps/RNMMapLocalTileManager.m} +9 -9
- package/ios/{AirMaps/AIRMapLocalTileOverlay.h → Maps/RNMMapLocalTileOverlay.h} +2 -2
- package/ios/{AirMaps/AIRMapLocalTileOverlay.m → Maps/RNMMapLocalTileOverlay.m} +5 -5
- package/ios/{AirMaps/AIRMapManager.h → Maps/RNMMapManager.h} +6 -6
- package/ios/Maps/RNMMapManager.m +857 -0
- package/ios/{AirMaps/AIRMapMarker.h → Maps/RNMMapMarker.h} +8 -8
- package/ios/{AirMaps/AIRMapMarker.m → Maps/RNMMapMarker.m} +13 -13
- package/ios/{AirMaps/AIRMapMarkerManager.h → Maps/RNMMapMarkerManager.h} +1 -1
- package/ios/{AirMaps/AIRMapMarkerManager.m → Maps/RNMMapMarkerManager.m} +14 -14
- package/ios/{AirMaps/AIRMapOverlay.h → Maps/RNMMapOverlay.h} +7 -7
- package/ios/{AirMaps/AIRMapOverlay.m → Maps/RNMMapOverlay.m} +4 -4
- package/ios/Maps/RNMMapOverlayManager.h +5 -0
- package/ios/{AirMaps/AIRMapOverlayManager.m → Maps/RNMMapOverlayManager.m} +6 -6
- package/ios/{AirMaps/AIRMapOverlayRenderer.h → Maps/RNMMapOverlayRenderer.h} +1 -1
- package/ios/{AirMaps/AIRMapOverlayRenderer.m → Maps/RNMMapOverlayRenderer.m} +5 -5
- package/ios/{AirMaps/AIRMapPolygon.h → Maps/RNMMapPolygon.h} +7 -7
- package/ios/{AirMaps/AIRMapPolygon.m → Maps/RNMMapPolygon.m} +4 -4
- package/ios/{AirMaps/AIRMapPolygonManager.h → Maps/RNMMapPolygonManager.h} +2 -2
- package/ios/{AirMaps/AIRMapPolygonManager.m → Maps/RNMMapPolygonManager.m} +10 -10
- package/ios/{AirMaps/AIRMapPolyline.h → Maps/RNMMapPolyline.h} +6 -6
- package/ios/{AirMaps/AIRMapPolyline.m → Maps/RNMMapPolyline.m} +11 -11
- package/ios/{AirMaps/AIRMapPolylineManager.h → Maps/RNMMapPolylineManager.h} +2 -2
- package/ios/{AirMaps/AIRMapPolylineManager.m → Maps/RNMMapPolylineManager.m} +9 -9
- package/ios/{AirMaps/AIRMapPolylineRenderer.h → Maps/RNMMapPolylineRenderer.h} +2 -2
- package/ios/{AirMaps/AIRMapPolylineRenderer.m → Maps/RNMMapPolylineRenderer.m} +10 -10
- package/ios/{AirMaps/AIRMapSnapshot.h → Maps/RNMMapSnapshot.h} +6 -6
- package/ios/{AirMaps/AIRMapUrlTile.h → Maps/RNMMapUrlTile.h} +18 -18
- package/ios/{AirMaps/AIRMapUrlTile.m → Maps/RNMMapUrlTile.m} +7 -7
- package/ios/{AirMaps/AIRMapUrlTileCachedOverlay.h → Maps/RNMMapUrlTileCachedOverlay.h} +3 -3
- package/ios/{AirMaps/AIRMapUrlTileCachedOverlay.m → Maps/RNMMapUrlTileCachedOverlay.m} +10 -10
- package/ios/{AirMaps/AIRMapUrlTileManager.h → Maps/RNMMapUrlTileManager.h} +3 -3
- package/ios/{AirMaps/AIRMapUrlTileManager.m → Maps/RNMMapUrlTileManager.m} +9 -9
- package/ios/Maps/RNMMapViewModule.h +5 -0
- package/ios/Maps/RNMMapViewModule.m +459 -0
- package/ios/{AirMaps/AIRMapWMSTile.h → Maps/RNMMapWMSTile.h} +11 -11
- package/ios/{AirMaps/AIRMapWMSTile.m → Maps/RNMMapWMSTile.m} +15 -15
- package/ios/{AirMaps/AIRMapWMSTileManager.h → Maps/RNMMapWMSTileManager.h} +3 -3
- package/ios/{AirMaps/AIRMapWMSTileManager.m → Maps/RNMMapWMSTileManager.m} +9 -9
- package/ios/RNMaps.xcodeproj/project.pbxproj +647 -0
- package/lib/MapCallout.js +2 -2
- package/lib/MapCalloutSubview.js +2 -2
- package/lib/MapCircle.js +2 -2
- package/lib/MapHeatmap.js +2 -2
- package/lib/MapLocalTile.js +2 -2
- package/lib/MapMarker.js +2 -2
- package/lib/MapOverlay.js +2 -2
- package/lib/MapPolygon.js +2 -2
- package/lib/MapPolyline.js +2 -2
- package/lib/MapUrlTile.js +2 -2
- package/lib/MapView.d.ts +7 -8
- package/lib/MapView.js +89 -97
- package/lib/MapView.types.d.ts +8 -2
- package/lib/MapViewNativeComponent.d.ts +2 -7
- package/lib/MapViewNativeComponent.js +0 -5
- package/lib/MapWMSTile.js +2 -2
- package/lib/NativeGoogleMapViewModule.d.ts +25 -0
- package/lib/NativeGoogleMapViewModule.js +4 -0
- package/lib/NativeMapViewModule.d.ts +29 -0
- package/lib/NativeMapViewModule.js +4 -0
- package/lib/decorateMapComponent.d.ts +1 -1
- package/lib/decorateMapComponent.js +3 -3
- package/package.json +1 -1
- package/react-native-google-maps.podspec +1 -1
- package/react-native-maps.podspec +1 -1
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +0 -380
- package/ios/AirGoogleMaps/AIRGoogleMapCalloutSubviewManager.m +0 -28
- package/ios/AirGoogleMaps/AIRGoogleMapHeatmapManager.h +0 -11
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -597
- package/ios/AirMaps/AIRMapCalloutSubviewManager.h +0 -14
- package/ios/AirMaps/AIRMapCalloutSubviewManager.m +0 -24
- package/ios/AirMaps/AIRMapManager.m +0 -1253
- package/ios/AirMaps/AIRMapOverlayManager.h +0 -5
- package/ios/AirMaps/AIRWeakMapReference.h +0 -24
- package/ios/AirMaps/AIRWeakMapReference.m +0 -23
- package/ios/AirMaps/AIRWeakTimerReference.h +0 -21
- package/ios/AirMaps/AIRWeakTimerReference.m +0 -42
- package/ios/AirMaps.xcodeproj/project.pbxproj +0 -587
- /package/ios/{AirGoogleMaps → GoogleMaps}/RCTConvert+GMSMapViewType.h +0 -0
- /package/ios/{AirGoogleMaps → GoogleMaps}/RCTConvert+GMSMapViewType.m +0 -0
- /package/ios/{AirMaps → Maps}/Callout/SMCalloutView.m +0 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
package com.rnmaps.maps;
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap;
|
|
4
|
+
import android.graphics.Point;
|
|
5
|
+
import android.location.Address;
|
|
6
|
+
import android.location.Geocoder;
|
|
7
|
+
import android.net.Uri;
|
|
8
|
+
import android.util.Base64;
|
|
9
|
+
import android.util.DisplayMetrics;
|
|
10
|
+
import android.util.Log;
|
|
11
|
+
|
|
12
|
+
import androidx.annotation.NonNull;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
|
|
15
|
+
import com.facebook.react.bridge.Promise;
|
|
16
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
20
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.bridge.WritableMap;
|
|
22
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
23
|
+
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
24
|
+
import com.facebook.react.uimanager.UIBlock;
|
|
25
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
26
|
+
import com.google.android.gms.maps.CameraUpdate;
|
|
27
|
+
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
28
|
+
import com.google.android.gms.maps.GoogleMap;
|
|
29
|
+
import com.google.android.gms.maps.MapsInitializer;
|
|
30
|
+
import com.google.android.gms.maps.OnMapsSdkInitializedCallback;
|
|
31
|
+
import com.google.android.gms.maps.model.CameraPosition;
|
|
32
|
+
import com.google.android.gms.maps.model.LatLng;
|
|
33
|
+
import com.google.android.gms.maps.model.LatLngBounds;
|
|
34
|
+
import com.google.android.gms.maps.model.Marker;
|
|
35
|
+
|
|
36
|
+
import java.io.ByteArrayOutputStream;
|
|
37
|
+
import java.io.Closeable;
|
|
38
|
+
import java.io.File;
|
|
39
|
+
import java.io.FileOutputStream;
|
|
40
|
+
import java.io.IOException;
|
|
41
|
+
import java.util.Arrays;
|
|
42
|
+
import java.util.HashMap;
|
|
43
|
+
import java.util.List;
|
|
44
|
+
import java.util.Map;
|
|
45
|
+
|
|
46
|
+
public class MapViewModule extends ReactContextBaseJavaModule {
|
|
47
|
+
|
|
48
|
+
private final ReactApplicationContext context;
|
|
49
|
+
|
|
50
|
+
public MapViewModule(ReactApplicationContext reactContext) {
|
|
51
|
+
super(reactContext);
|
|
52
|
+
context = reactContext;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public String getName() {
|
|
57
|
+
return "RNMMapViewModule";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
public Map<String, Object> getConstants() {
|
|
62
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
63
|
+
constants.put("legalNotice", "This license information is displayed in Settings > Google > Open Source on any device running Google Play services.");
|
|
64
|
+
return constants;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public static void closeQuietly(Closeable closeable) {
|
|
68
|
+
if (closeable == null) return;
|
|
69
|
+
try {
|
|
70
|
+
closeable.close();
|
|
71
|
+
} catch (IOException ignored) {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
public void takeSnapshot(final int tag, final ReadableMap options, final Promise promise) {
|
|
77
|
+
// Parse and verity options
|
|
78
|
+
final String format = options.hasKey("format") ? options.getString("format") : "png";
|
|
79
|
+
final Bitmap.CompressFormat compressFormat =
|
|
80
|
+
format.equals("png") ? Bitmap.CompressFormat.PNG :
|
|
81
|
+
format.equals("jpg") ? Bitmap.CompressFormat.JPEG : null;
|
|
82
|
+
final double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
|
|
83
|
+
final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
|
84
|
+
final Integer width =
|
|
85
|
+
options.hasKey("width") ? (int) (displayMetrics.density * options.getDouble("width")) : 0;
|
|
86
|
+
final Integer height =
|
|
87
|
+
options.hasKey("height") ? (int) (displayMetrics.density * options.getDouble("height")) : 0;
|
|
88
|
+
final String result = options.hasKey("result") ? options.getString("result") : "file";
|
|
89
|
+
|
|
90
|
+
// Add UI-block so we can get a valid reference to the map-view
|
|
91
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
92
|
+
public void execute(NativeViewHierarchyManager nvhm) {
|
|
93
|
+
MapView view = (MapView) nvhm.resolveView(tag);
|
|
94
|
+
if (view == null) {
|
|
95
|
+
promise.reject("RNMMapView not found");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (view.map == null) {
|
|
99
|
+
promise.reject("RNMMapView.map is not valid");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
view.map.snapshot(new GoogleMap.SnapshotReadyCallback() {
|
|
103
|
+
public void onSnapshotReady(@Nullable Bitmap snapshot) {
|
|
104
|
+
|
|
105
|
+
// Convert image to requested width/height if necessary
|
|
106
|
+
if (snapshot == null) {
|
|
107
|
+
promise.reject("Failed to generate bitmap, snapshot = null");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if ((width != 0) && (height != 0) &&
|
|
111
|
+
(width != snapshot.getWidth() || height != snapshot.getHeight())) {
|
|
112
|
+
snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Save the snapshot to disk
|
|
116
|
+
if (result.equals("file")) {
|
|
117
|
+
File tempFile;
|
|
118
|
+
FileOutputStream outputStream;
|
|
119
|
+
try {
|
|
120
|
+
tempFile =
|
|
121
|
+
File.createTempFile("RNMMapSnapshot", "." + format, context.getCacheDir());
|
|
122
|
+
outputStream = new FileOutputStream(tempFile);
|
|
123
|
+
} catch (Exception e) {
|
|
124
|
+
promise.reject(e);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
128
|
+
closeQuietly(outputStream);
|
|
129
|
+
String uri = Uri.fromFile(tempFile).toString();
|
|
130
|
+
promise.resolve(uri);
|
|
131
|
+
} else if (result.equals("base64")) {
|
|
132
|
+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
133
|
+
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
134
|
+
closeQuietly(outputStream);
|
|
135
|
+
byte[] bytes = outputStream.toByteArray();
|
|
136
|
+
String data = Base64.encodeToString(bytes, Base64.NO_WRAP);
|
|
137
|
+
promise.resolve(data);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
public void getCamera(final int tag, final Promise promise) {
|
|
147
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
148
|
+
@Override
|
|
149
|
+
public void execute(NativeViewHierarchyManager nvhm) {
|
|
150
|
+
MapView view = (MapView) nvhm.resolveView(tag);
|
|
151
|
+
if (view == null) {
|
|
152
|
+
promise.reject("RNMMapView not found");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (view.map == null) {
|
|
156
|
+
promise.reject("RNMMapView.map is not valid");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
CameraPosition position = view.map.getCameraPosition();
|
|
161
|
+
|
|
162
|
+
WritableMap centerJson = new WritableNativeMap();
|
|
163
|
+
centerJson.putDouble("latitude", position.target.latitude);
|
|
164
|
+
centerJson.putDouble("longitude", position.target.longitude);
|
|
165
|
+
|
|
166
|
+
WritableMap cameraJson = new WritableNativeMap();
|
|
167
|
+
cameraJson.putMap("center", centerJson);
|
|
168
|
+
cameraJson.putDouble("heading", (double) position.bearing);
|
|
169
|
+
cameraJson.putDouble("zoom", (double) position.zoom);
|
|
170
|
+
cameraJson.putDouble("pitch", (double) position.tilt);
|
|
171
|
+
|
|
172
|
+
promise.resolve(cameraJson);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@ReactMethod
|
|
178
|
+
public void getAddressFromCoordinates(final int tag, final ReadableMap coordinate, final Promise promise) {
|
|
179
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
180
|
+
@Override
|
|
181
|
+
public void execute(NativeViewHierarchyManager nvhm) {
|
|
182
|
+
MapView view = (MapView) nvhm.resolveView(tag);
|
|
183
|
+
if (view == null) {
|
|
184
|
+
promise.reject("RNMMapView not found");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (view.map == null) {
|
|
188
|
+
promise.reject("RNMMapView.map is not valid");
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (coordinate == null ||
|
|
192
|
+
!coordinate.hasKey("latitude") ||
|
|
193
|
+
!coordinate.hasKey("longitude")) {
|
|
194
|
+
promise.reject("Invalid coordinate format");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
Geocoder geocoder = new Geocoder(context);
|
|
198
|
+
try {
|
|
199
|
+
List<Address> list =
|
|
200
|
+
geocoder.getFromLocation(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"), 1);
|
|
201
|
+
if (list.isEmpty()) {
|
|
202
|
+
promise.reject("Can not get address location");
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
Address address = list.get(0);
|
|
206
|
+
|
|
207
|
+
WritableMap addressJson = new WritableNativeMap();
|
|
208
|
+
addressJson.putString("name", address.getFeatureName());
|
|
209
|
+
addressJson.putString("locality", address.getLocality());
|
|
210
|
+
addressJson.putString("thoroughfare", address.getThoroughfare());
|
|
211
|
+
addressJson.putString("subThoroughfare", address.getSubThoroughfare());
|
|
212
|
+
addressJson.putString("subLocality", address.getSubLocality());
|
|
213
|
+
addressJson.putString("administrativeArea", address.getAdminArea());
|
|
214
|
+
addressJson.putString("subAdministrativeArea", address.getSubAdminArea());
|
|
215
|
+
addressJson.putString("postalCode", address.getPostalCode());
|
|
216
|
+
addressJson.putString("countryCode", address.getCountryCode());
|
|
217
|
+
addressJson.putString("country", address.getCountryName());
|
|
218
|
+
|
|
219
|
+
promise.resolve(addressJson);
|
|
220
|
+
} catch (IOException e) {
|
|
221
|
+
promise.reject("Can not get address location");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@ReactMethod
|
|
228
|
+
public void pointForCoordinate(final int tag, ReadableMap coordinate, final Promise promise) {
|
|
229
|
+
final double density = context.getResources().getDisplayMetrics().density;
|
|
230
|
+
|
|
231
|
+
final LatLng coord = new LatLng(
|
|
232
|
+
coordinate.hasKey("latitude") ? coordinate.getDouble("latitude") : 0.0,
|
|
233
|
+
coordinate.hasKey("longitude") ? coordinate.getDouble("longitude") : 0.0
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
237
|
+
@Override
|
|
238
|
+
public void execute(NativeViewHierarchyManager nvhm) {
|
|
239
|
+
MapView view = (MapView) nvhm.resolveView(tag);
|
|
240
|
+
if (view == null) {
|
|
241
|
+
promise.reject("RNMMapView not found");
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (view.map == null) {
|
|
245
|
+
promise.reject("RNMMapView.map is not valid");
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
Point pt = view.map.getProjection().toScreenLocation(coord);
|
|
250
|
+
|
|
251
|
+
WritableMap ptJson = new WritableNativeMap();
|
|
252
|
+
ptJson.putDouble("x", (double) pt.x / density);
|
|
253
|
+
ptJson.putDouble("y", (double) pt.y / density);
|
|
254
|
+
|
|
255
|
+
promise.resolve(ptJson);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@ReactMethod
|
|
261
|
+
public void coordinateForPoint(final int tag, ReadableMap point, final Promise promise) {
|
|
262
|
+
final double density = context.getResources().getDisplayMetrics().density;
|
|
263
|
+
|
|
264
|
+
final Point pt = new Point(
|
|
265
|
+
point.hasKey("x") ? (int) (point.getDouble("x") * density) : 0,
|
|
266
|
+
point.hasKey("y") ? (int) (point.getDouble("y") * density) : 0
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
270
|
+
@Override
|
|
271
|
+
public void execute(NativeViewHierarchyManager nvhm) {
|
|
272
|
+
MapView view = (MapView) nvhm.resolveView(tag);
|
|
273
|
+
if (view == null) {
|
|
274
|
+
promise.reject("RNMMapView not found");
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (view.map == null) {
|
|
278
|
+
promise.reject("RNMMapView.map is not valid");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
LatLng coord = view.map.getProjection().fromScreenLocation(pt);
|
|
283
|
+
|
|
284
|
+
WritableMap coordJson = new WritableNativeMap();
|
|
285
|
+
coordJson.putDouble("latitude", coord.latitude);
|
|
286
|
+
coordJson.putDouble("longitude", coord.longitude);
|
|
287
|
+
|
|
288
|
+
promise.resolve(coordJson);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@ReactMethod
|
|
294
|
+
public void getMapBoundaries(final int tag, final Promise promise) {
|
|
295
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
296
|
+
@Override
|
|
297
|
+
public void execute(NativeViewHierarchyManager nvhm) {
|
|
298
|
+
MapView view = (MapView) nvhm.resolveView(tag);
|
|
299
|
+
if (view == null) {
|
|
300
|
+
promise.reject("RNMMapView not found");
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (view.map == null) {
|
|
304
|
+
promise.reject("RNMMapView.map is not valid");
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
double[][] boundaries = view.getMapBoundaries();
|
|
309
|
+
|
|
310
|
+
WritableMap coordinates = new WritableNativeMap();
|
|
311
|
+
WritableMap northEastHash = new WritableNativeMap();
|
|
312
|
+
WritableMap southWestHash = new WritableNativeMap();
|
|
313
|
+
|
|
314
|
+
northEastHash.putDouble("longitude", boundaries[0][0]);
|
|
315
|
+
northEastHash.putDouble("latitude", boundaries[0][1]);
|
|
316
|
+
southWestHash.putDouble("longitude", boundaries[1][0]);
|
|
317
|
+
southWestHash.putDouble("latitude", boundaries[1][1]);
|
|
318
|
+
|
|
319
|
+
coordinates.putMap("northEast", northEastHash);
|
|
320
|
+
coordinates.putMap("southWest", southWestHash);
|
|
321
|
+
|
|
322
|
+
promise.resolve(coordinates);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@ReactMethod
|
|
328
|
+
public void enableLatestRenderer(final Promise promise) {
|
|
329
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
330
|
+
@Override
|
|
331
|
+
public void execute(NativeViewHierarchyManager nvhm) {
|
|
332
|
+
MapsInitializer.initialize(context, MapsInitializer.Renderer.LATEST, new OnMapsSdkInitializedCallback() {
|
|
333
|
+
@Override
|
|
334
|
+
public void onMapsSdkInitialized(@NonNull MapsInitializer.Renderer renderer) {
|
|
335
|
+
Log.d("RNMMapRenderer", renderer.toString());
|
|
336
|
+
promise.resolve(renderer.toString());
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
@ReactMethod
|
|
344
|
+
public void animateToRegion(final int tag, ReadableMap region, int duration, final Promise promise) {
|
|
345
|
+
double lng = region.getDouble("longitude");
|
|
346
|
+
double lat = region.getDouble("latitude");
|
|
347
|
+
double lngDelta = region.getDouble("longitudeDelta");
|
|
348
|
+
double latDelta = region.getDouble("latitudeDelta");
|
|
349
|
+
LatLngBounds bounds = new LatLngBounds(
|
|
350
|
+
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
|
|
351
|
+
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
355
|
+
@Override
|
|
356
|
+
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
357
|
+
MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
|
|
358
|
+
if (view == null) {
|
|
359
|
+
promise.reject("RNMMapView not found");
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (view.map == null) {
|
|
363
|
+
promise.reject("RNMMapView.map is not valid");
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (duration <= 0) {
|
|
367
|
+
view.map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
|
368
|
+
promise.resolve(null);
|
|
369
|
+
} else {
|
|
370
|
+
view.map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0), duration, new GoogleMap.CancelableCallback() {
|
|
371
|
+
@Override
|
|
372
|
+
public void onCancel() {
|
|
373
|
+
promise.resolve(null);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
@Override
|
|
377
|
+
public void onFinish() {
|
|
378
|
+
promise.resolve(null);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
@ReactMethod
|
|
387
|
+
public void animateCamera(final int tag, ReadableMap camera, int duration, final Promise promise) {
|
|
388
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
389
|
+
@Override
|
|
390
|
+
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
391
|
+
MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
|
|
392
|
+
if (view == null) {
|
|
393
|
+
promise.reject("RNMMapView not found");
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (view.map == null) {
|
|
397
|
+
promise.reject("RNMMapView.map is not valid");
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
CameraUpdate update = view.buildCameraUpdate(camera);
|
|
402
|
+
|
|
403
|
+
if (duration <= 0) {
|
|
404
|
+
view.map.moveCamera(update);
|
|
405
|
+
promise.resolve(null);
|
|
406
|
+
} else {
|
|
407
|
+
view.map.animateCamera(update, duration, new GoogleMap.CancelableCallback() {
|
|
408
|
+
@Override
|
|
409
|
+
public void onCancel() {
|
|
410
|
+
promise.resolve(null);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
@Override
|
|
414
|
+
public void onFinish() {
|
|
415
|
+
promise.resolve(null);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
@ReactMethod
|
|
424
|
+
public void fitToElements(final int tag, ReadableMap edgePadding, int duration, final Promise promise) {
|
|
425
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
426
|
+
@Override
|
|
427
|
+
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
428
|
+
MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
|
|
429
|
+
if (view == null) {
|
|
430
|
+
promise.reject("RNMMapView not found");
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (view.map == null) {
|
|
434
|
+
promise.reject("RNMMapView.map is not valid");
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
438
|
+
|
|
439
|
+
boolean addedPosition = false;
|
|
440
|
+
|
|
441
|
+
for (MapFeature feature : view.features) {
|
|
442
|
+
if (feature instanceof MapMarker) {
|
|
443
|
+
Marker marker = (Marker) feature.getFeature();
|
|
444
|
+
builder.include(marker.getPosition());
|
|
445
|
+
addedPosition = true;
|
|
446
|
+
}
|
|
447
|
+
// TODO(lmr): may want to include shapes / etc.
|
|
448
|
+
}
|
|
449
|
+
if (addedPosition) {
|
|
450
|
+
LatLngBounds bounds = builder.build();
|
|
451
|
+
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, view.baseMapPadding);
|
|
452
|
+
|
|
453
|
+
if (edgePadding != null) {
|
|
454
|
+
view.map.setPadding(edgePadding.getInt("left"), edgePadding.getInt("top"),
|
|
455
|
+
edgePadding.getInt("right"), edgePadding.getInt("bottom"));
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (duration > 0) {
|
|
459
|
+
view.map.animateCamera(cu, duration, new GoogleMap.CancelableCallback() {
|
|
460
|
+
@Override
|
|
461
|
+
public void onCancel() {
|
|
462
|
+
promise.resolve(null);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
@Override
|
|
466
|
+
public void onFinish() {
|
|
467
|
+
promise.resolve(null);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
} else {
|
|
471
|
+
view.map.moveCamera(cu);
|
|
472
|
+
promise.resolve(null);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
@ReactMethod
|
|
481
|
+
public void fitToSuppliedMarkers(final int tag, ReadableArray markersIds, ReadableMap edgePadding, int duration, final Promise promise) {
|
|
482
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
483
|
+
@Override
|
|
484
|
+
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
485
|
+
MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
|
|
486
|
+
if (view == null) {
|
|
487
|
+
promise.reject("RNMMapView not found");
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (view.map == null) {
|
|
491
|
+
promise.reject("RNMMapView.map is not valid");
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
495
|
+
|
|
496
|
+
String[] markerIDs = new String[markersIds.size()];
|
|
497
|
+
for (int i = 0; i < markersIds.size(); i++) {
|
|
498
|
+
markerIDs[i] = markersIds.getString(i);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
boolean addedPosition = false;
|
|
502
|
+
|
|
503
|
+
List<String> markerIDList = Arrays.asList(markerIDs);
|
|
504
|
+
|
|
505
|
+
for (MapFeature feature : view.features) {
|
|
506
|
+
if (feature instanceof MapMarker) {
|
|
507
|
+
String identifier = ((MapMarker) feature).getIdentifier();
|
|
508
|
+
Marker marker = (Marker) feature.getFeature();
|
|
509
|
+
if (markerIDList.contains(identifier)) {
|
|
510
|
+
builder.include(marker.getPosition());
|
|
511
|
+
addedPosition = true;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
if (addedPosition) {
|
|
517
|
+
LatLngBounds bounds = builder.build();
|
|
518
|
+
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, view.baseMapPadding);
|
|
519
|
+
|
|
520
|
+
if (edgePadding != null) {
|
|
521
|
+
view.map.setPadding(edgePadding.getInt("left"), edgePadding.getInt("top"),
|
|
522
|
+
edgePadding.getInt("right"), edgePadding.getInt("bottom"));
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (duration > 0) {
|
|
526
|
+
view.map.animateCamera(cu, duration, new GoogleMap.CancelableCallback() {
|
|
527
|
+
@Override
|
|
528
|
+
public void onCancel() {
|
|
529
|
+
promise.resolve(null);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
@Override
|
|
533
|
+
public void onFinish() {
|
|
534
|
+
promise.resolve(null);
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
} else {
|
|
538
|
+
view.map.moveCamera(cu);
|
|
539
|
+
promise.resolve(null);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
@ReactMethod
|
|
547
|
+
public void fitToCoordinates(final int tag, ReadableArray coordinates, ReadableMap edgePadding, int duration, Promise promise) {
|
|
548
|
+
context.getNativeModule(UIManagerModule.class).addUIBlock(new UIBlock() {
|
|
549
|
+
@Override
|
|
550
|
+
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
551
|
+
MapView view = (MapView) nativeViewHierarchyManager.resolveView(tag);
|
|
552
|
+
if (view == null) {
|
|
553
|
+
promise.reject("RNMMapView not found");
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (view.map == null) {
|
|
557
|
+
promise.reject("RNMMapView.map is not valid");
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
562
|
+
|
|
563
|
+
for (int i = 0; i < coordinates.size(); i++) {
|
|
564
|
+
ReadableMap latLng = coordinates.getMap(i);
|
|
565
|
+
double lat = latLng.getDouble("latitude");
|
|
566
|
+
double lng = latLng.getDouble("longitude");
|
|
567
|
+
builder.include(new LatLng(lat, lng));
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
LatLngBounds bounds = builder.build();
|
|
571
|
+
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, view.baseMapPadding);
|
|
572
|
+
|
|
573
|
+
if (edgePadding != null) {
|
|
574
|
+
view.appendMapPadding(edgePadding.getInt("left"), edgePadding.getInt("top"), edgePadding.getInt("right"), edgePadding.getInt("bottom"));
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (duration > 0) {
|
|
578
|
+
view.map.animateCamera(cu, duration, new GoogleMap.CancelableCallback() {
|
|
579
|
+
@Override
|
|
580
|
+
public void onCancel() {
|
|
581
|
+
promise.resolve(null);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
@Override
|
|
585
|
+
public void onFinish() {
|
|
586
|
+
promise.resolve(null);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
} else {
|
|
590
|
+
view.map.moveCamera(cu);
|
|
591
|
+
promise.resolve(null);
|
|
592
|
+
}
|
|
593
|
+
// Move the google logo to the default base padding value.
|
|
594
|
+
view.map.setPadding(view.baseLeftMapPadding, view.baseTopMapPadding, view.baseRightMapPadding, view.baseBottomMapPadding);
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
@@ -12,13 +12,13 @@ public class MapWMSTile extends MapUrlTile {
|
|
|
12
12
|
private static final double[] mapBound = {-20037508.34789244, 20037508.34789244};
|
|
13
13
|
private static final double FULL = 20037508.34789244 * 2;
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class MapGSUrlTileProvider extends MapTileProvider {
|
|
16
16
|
|
|
17
|
-
class
|
|
17
|
+
class MapWMSTileProvider extends UrlTileProvider {
|
|
18
18
|
private String urlTemplate;
|
|
19
19
|
private final int tileSize;
|
|
20
20
|
|
|
21
|
-
public
|
|
21
|
+
public MapWMSTileProvider(int width, int height, String urlTemplate) {
|
|
22
22
|
super(width, height);
|
|
23
23
|
this.urlTemplate = urlTemplate;
|
|
24
24
|
this.tileSize = width;
|
|
@@ -67,12 +67,12 @@ public class MapWMSTile extends MapUrlTile {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
public
|
|
70
|
+
public MapGSUrlTileProvider(int tileSizet, String urlTemplate,
|
|
71
71
|
int maximumZ, int maximumNativeZ, int minimumZ, String tileCachePath,
|
|
72
72
|
int tileCacheMaxAge, boolean offlineMode, Context context, boolean customMode) {
|
|
73
73
|
super(tileSizet, false, urlTemplate, maximumZ, maximumNativeZ, minimumZ, false,
|
|
74
74
|
tileCachePath, tileCacheMaxAge, offlineMode, context, customMode);
|
|
75
|
-
this.tileProvider = new
|
|
75
|
+
this.tileProvider = new MapWMSTileProvider(tileSizet, tileSizet, urlTemplate);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -85,7 +85,7 @@ public class MapWMSTile extends MapUrlTile {
|
|
|
85
85
|
TileOverlayOptions options = new TileOverlayOptions();
|
|
86
86
|
options.zIndex(zIndex);
|
|
87
87
|
options.transparency(1 - this.opacity);
|
|
88
|
-
|
|
88
|
+
MapGSUrlTileProvider tileProvider = new MapGSUrlTileProvider((int) this.tileSize, this.urlTemplate,
|
|
89
89
|
(int) this.maximumZ, (int) this.maximumNativeZ, (int) this.minimumZ, this.tileCachePath,
|
|
90
90
|
(int) this.tileCacheMaxAge, this.offlineMode, this.context, this.customTileProviderNeeded);
|
|
91
91
|
options.tileProvider(tileProvider);
|
|
@@ -14,7 +14,7 @@ public class MapsPackage implements ReactPackage {
|
|
|
14
14
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
15
15
|
List<NativeModule> modules = new ArrayList<>();
|
|
16
16
|
|
|
17
|
-
modules.add(new
|
|
17
|
+
modules.add(new MapViewModule(reactContext));
|
|
18
18
|
|
|
19
19
|
return modules;
|
|
20
20
|
}
|
|
@@ -14,7 +14,7 @@ import com.facebook.react.uimanager.UIViewOperationQueue;
|
|
|
14
14
|
import java.util.HashMap;
|
|
15
15
|
import java.util.Map;
|
|
16
16
|
|
|
17
|
-
// Custom LayoutShadowNode implementation used in conjunction with the
|
|
17
|
+
// Custom LayoutShadowNode implementation used in conjunction with the RNMMapManager
|
|
18
18
|
// which sends the width/height of the view after layout occurs.
|
|
19
19
|
public class SizeReportingShadowNode extends LayoutShadowNode {
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNMDummyView.h
|
|
3
|
+
// RNMaps
|
|
4
4
|
//
|
|
5
5
|
// Created by Gil Birman on 10/4/16.
|
|
6
6
|
//
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#import <UIKit/UIKit.h>
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
@interface
|
|
13
|
+
@interface RNMDummyView : UIView
|
|
14
14
|
@property (nonatomic, weak) UIView *view;
|
|
15
15
|
- (instancetype)initWithView:(UIView*)view;
|
|
16
16
|
@end
|