react-native-maps 1.21.0-alpha.7 → 1.21.0-alpha.71
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 +38 -13
- package/android/generated/RCTAppDependencyProvider.h +25 -0
- package/android/generated/RCTAppDependencyProvider.mm +55 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/android/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/android/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/android/generated/RCTThirdPartyComponentsProvider.mm +26 -0
- package/android/generated/ReactAppDependencyProvider.podspec +34 -0
- package/android/generated/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerDelegate.java +35 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerInterface.java +17 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +200 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +71 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNMapsSpecs-generated.cpp +68 -0
- package/android/generated/jni/RNMapsSpecs.h +31 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +28 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +918 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +787 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +154 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +1058 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +268 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +21 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +76 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +77 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/rnmaps/fabric/CalloutManager.java +77 -0
- package/android/src/main/java/com/rnmaps/fabric/JSONUtil.java +86 -0
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +593 -0
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +259 -0
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +156 -4
- package/android/src/main/java/com/rnmaps/fabric/event/OnCalloutPressEvent.java +25 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDeselectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragEndEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnDragStartEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnLongPressEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMapLoadedEvent.java +29 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMapReadyEvent.java +29 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDeselectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEndEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerDragStartEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerPressEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnMarkerSelectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnPoiClickEvent.java +27 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnPressEvent.java +27 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeCompleteEvent.java +30 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeEvent.java +48 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnRegionChangeStartEvent.java +33 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnSelectEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/fabric/event/OnUserLocationChangeEvent.java +28 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +22 -2
- package/android/src/main/java/com/rnmaps/maps/MapCallout.java +18 -0
- package/android/src/main/java/com/rnmaps/maps/MapManager.java +14 -14
- package/android/src/main/java/com/rnmaps/maps/MapMarker.java +79 -3
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +206 -206
- package/android/src/main/java/com/rnmaps/maps/MapView.java +1618 -1346
- package/ios/AirGoogleMaps/AIRGoogleMap.h +3 -2
- package/ios/AirGoogleMaps/AIRGoogleMap.m +153 -48
- package/ios/AirGoogleMaps/AIRGoogleMapCircle.m +23 -11
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +17 -28
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.h +2 -0
- package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +347 -243
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.h +2 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolygon.m +30 -0
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.h +0 -1
- package/ios/AirGoogleMaps/AIRGoogleMapPolyline.m +0 -7
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.h +1 -1
- package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.h +3 -0
- package/ios/AirGoogleMaps/RCTConvert+GMSMapViewType.m +2 -0
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +3 -3
- package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +161 -61
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.h +26 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +217 -0
- package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +25 -0
- package/ios/AirMaps/AIRMap.h +6 -3
- package/ios/AirMaps/AIRMap.m +289 -145
- package/ios/AirMaps/AIRMapManager.m +8 -17
- package/ios/AirMaps/AIRMapMarker.h +1 -0
- package/ios/AirMaps/AIRMapMarker.m +165 -103
- package/ios/AirMaps/Callout/SMCalloutView.m +1 -1
- package/ios/AirMaps/RCTConvert+AirMap.h +4 -0
- package/ios/AirMaps/RCTConvert+AirMap.m +2 -0
- package/ios/AirMaps/RNMapsAirModule.h +1 -1
- package/ios/AirMaps/RNMapsAirModule.mm +42 -172
- package/ios/AirMaps/RNMapsAirModuleDelegate.h +24 -0
- package/ios/AirMaps/RNMapsHostVewDelegate.h +17 -0
- package/ios/AirMaps/RNMapsMapView.h +3 -3
- package/ios/AirMaps/RNMapsMapView.mm +344 -307
- package/ios/AirMaps/RNMapsMarkerView.h +24 -0
- package/ios/AirMaps/RNMapsMarkerView.mm +430 -0
- package/ios/AirMaps/RNMapsMarkerViewManager.mm +21 -0
- package/ios/AirMaps/UIView +AirMap.m +20 -0
- package/ios/AirMaps/UIView+AirMap.h +11 -0
- package/ios/AirMaps.xcodeproj/project.pbxproj +60 -0
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +26 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +26 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +28 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +918 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +787 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +154 -0
- package/ios/generated/RNMapsSpecs/Props.h +1058 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +549 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +21 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +76 -0
- package/ios/generated/RNMapsSpecs/States.cpp +16 -0
- package/ios/generated/RNMapsSpecs/States.h +77 -0
- package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
- package/ios/generated/RNMapsSpecsJSI.h +268 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/MapCallout.js +1 -0
- package/lib/MapMarker.d.ts +15 -2
- package/lib/MapMarker.js +53 -9
- package/lib/MapMarkerNativeComponent.js +0 -2
- package/lib/MapOverlay.js +2 -8
- package/lib/MapPolyline.d.ts +1 -1
- package/lib/MapView.d.ts +7 -22
- package/lib/MapView.js +83 -94
- package/lib/{FabricMapView.d.ts → createFabricMap.d.ts} +7 -11
- package/lib/createFabricMap.js +175 -0
- package/lib/decorateMapComponent.js +22 -0
- package/lib/specs/NativeAirMapsModule.d.ts +2 -2
- package/lib/specs/NativeComponentCallout.d.ts +46 -0
- package/lib/specs/NativeComponentCallout.js +9 -0
- package/lib/specs/NativeComponentGoogleMapView.d.ts +12 -12
- package/lib/specs/NativeComponentGooglePolygon.d.ts +75 -0
- package/lib/specs/NativeComponentGooglePolygon.js +9 -0
- package/lib/specs/NativeComponentMapView.d.ts +19 -36
- package/lib/specs/NativeComponentMapView.js +1 -3
- package/lib/specs/NativeComponentMarker.d.ts +258 -0
- package/lib/specs/NativeComponentMarker.js +19 -0
- package/package.json +15 -10
- package/react-native-maps.podspec +2 -1
- package/lib/FabricMapView.js +0 -181
|
@@ -32,13 +32,28 @@ import com.facebook.imagepipeline.image.CloseableStaticBitmap;
|
|
|
32
32
|
import com.facebook.imagepipeline.image.ImageInfo;
|
|
33
33
|
import com.facebook.imagepipeline.request.ImageRequest;
|
|
34
34
|
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
35
|
+
import com.facebook.react.bridge.ReactContext;
|
|
35
36
|
import com.facebook.react.bridge.ReadableMap;
|
|
37
|
+
import com.facebook.react.bridge.WritableMap;
|
|
38
|
+
import com.facebook.react.common.MapBuilder;
|
|
39
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
40
|
+
import com.facebook.react.uimanager.events.Event;
|
|
41
|
+
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
42
|
+
import com.google.android.gms.common.images.ImageManager;
|
|
36
43
|
import com.google.android.gms.maps.model.BitmapDescriptor;
|
|
37
44
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
38
45
|
import com.google.android.gms.maps.model.LatLng;
|
|
39
46
|
import com.google.android.gms.maps.model.Marker;
|
|
40
47
|
import com.google.android.gms.maps.model.MarkerOptions;
|
|
41
48
|
import com.google.maps.android.collections.MarkerManager;
|
|
49
|
+
import com.rnmaps.fabric.event.OnDeselectEvent;
|
|
50
|
+
import com.rnmaps.fabric.event.OnDragEndEvent;
|
|
51
|
+
import com.rnmaps.fabric.event.OnDragEvent;
|
|
52
|
+
import com.rnmaps.fabric.event.OnDragStartEvent;
|
|
53
|
+
import com.rnmaps.fabric.event.OnPressEvent;
|
|
54
|
+
import com.rnmaps.fabric.event.OnSelectEvent;
|
|
55
|
+
|
|
56
|
+
import java.util.Map;
|
|
42
57
|
|
|
43
58
|
public class MapMarker extends MapFeature {
|
|
44
59
|
|
|
@@ -80,11 +95,17 @@ public class MapMarker extends MapFeature {
|
|
|
80
95
|
private boolean hasCustomMarkerView = false;
|
|
81
96
|
private final MapMarkerManager markerManager;
|
|
82
97
|
private String imageUri;
|
|
98
|
+
private boolean loadingImage;
|
|
83
99
|
|
|
84
100
|
private final DraweeHolder<?> logoHolder;
|
|
101
|
+
private ImageManager.OnImageLoadedListener imageLoadedListener;
|
|
85
102
|
private DataSource<CloseableReference<CloseableImage>> dataSource;
|
|
86
103
|
private final ControllerListener<ImageInfo> mLogoControllerListener =
|
|
87
104
|
new BaseControllerListener<ImageInfo>() {
|
|
105
|
+
@Override
|
|
106
|
+
public void onSubmit(String id, Object callerContext){
|
|
107
|
+
loadingImage = true;
|
|
108
|
+
}
|
|
88
109
|
@Override
|
|
89
110
|
public void onFinalImageSet(
|
|
90
111
|
String id,
|
|
@@ -116,6 +137,12 @@ public class MapMarker extends MapFeature {
|
|
|
116
137
|
.updateIcon(iconBitmapDescriptor, iconBitmap);
|
|
117
138
|
}
|
|
118
139
|
update(true);
|
|
140
|
+
loadingImage = false;
|
|
141
|
+
if (imageLoadedListener != null){
|
|
142
|
+
imageLoadedListener.onImageLoaded(null, null, false);
|
|
143
|
+
// fire and forget
|
|
144
|
+
imageLoadedListener = null;
|
|
145
|
+
}
|
|
119
146
|
}
|
|
120
147
|
};
|
|
121
148
|
|
|
@@ -143,7 +170,7 @@ public class MapMarker extends MapFeature {
|
|
|
143
170
|
setFlat(options.isFlat());
|
|
144
171
|
setDraggable(options.isDraggable());
|
|
145
172
|
setZIndex(Math.round(options.getZIndex()));
|
|
146
|
-
|
|
173
|
+
setOpacity(options.getAlpha());
|
|
147
174
|
iconBitmapDescriptor = options.getIcon();
|
|
148
175
|
}
|
|
149
176
|
|
|
@@ -155,7 +182,10 @@ public class MapMarker extends MapFeature {
|
|
|
155
182
|
}
|
|
156
183
|
|
|
157
184
|
public void setCoordinate(ReadableMap coordinate) {
|
|
158
|
-
|
|
185
|
+
setCoordinate(new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
|
|
186
|
+
}
|
|
187
|
+
public void setCoordinate(LatLng position){
|
|
188
|
+
this.position = position;
|
|
159
189
|
if (marker != null) {
|
|
160
190
|
marker.setPosition(position);
|
|
161
191
|
}
|
|
@@ -421,7 +451,6 @@ public class MapMarker extends MapFeature {
|
|
|
421
451
|
updateTracksViewChanges();
|
|
422
452
|
update(true);
|
|
423
453
|
}
|
|
424
|
-
|
|
425
454
|
}
|
|
426
455
|
}
|
|
427
456
|
|
|
@@ -618,8 +647,55 @@ public class MapMarker extends MapFeature {
|
|
|
618
647
|
getContext().getPackageName());
|
|
619
648
|
}
|
|
620
649
|
|
|
650
|
+
public boolean isLoadingImage() {
|
|
651
|
+
return loadingImage;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
public ImageManager.OnImageLoadedListener getImageLoadedListener() {
|
|
655
|
+
return imageLoadedListener;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
public void setImageLoadedListener(ImageManager.OnImageLoadedListener imageLoadedListener) {
|
|
659
|
+
this.imageLoadedListener = imageLoadedListener;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
@FunctionalInterface
|
|
663
|
+
public interface EventCreator<T extends Event> {
|
|
664
|
+
T create(int surfaceId, int viewId, WritableMap payload);
|
|
665
|
+
}
|
|
666
|
+
public <T extends Event> void dispatchEvent(WritableMap payload, MapView.EventCreator<T> creator) {
|
|
667
|
+
// Cast context to ReactContext
|
|
668
|
+
ReactContext reactContext = (ReactContext) context;
|
|
669
|
+
|
|
670
|
+
// Get the event dispatcher
|
|
671
|
+
EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, getId());
|
|
672
|
+
|
|
673
|
+
// If there is a dispatcher, create and dispatch the event
|
|
674
|
+
if (eventDispatcher != null) {
|
|
675
|
+
int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
|
|
676
|
+
T event = creator.create(surfaceId, getId(), payload);
|
|
677
|
+
eventDispatcher.dispatchEvent(event);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
621
681
|
private BitmapDescriptor getBitmapDescriptorByName(String name) {
|
|
622
682
|
return BitmapDescriptorFactory.fromResource(getDrawableResourceByName(name));
|
|
623
683
|
}
|
|
624
684
|
|
|
685
|
+
public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
686
|
+
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
687
|
+
builder.put(OnSelectEvent.EVENT_NAME, MapBuilder.of("registrationName", OnSelectEvent.EVENT_NAME));
|
|
688
|
+
builder.put(OnDeselectEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDeselectEvent.EVENT_NAME));
|
|
689
|
+
builder.put(OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME));
|
|
690
|
+
return builder.build();
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
public static Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
694
|
+
return MapBuilder.of(
|
|
695
|
+
OnDragEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragEvent.EVENT_NAME),
|
|
696
|
+
OnDragStartEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragStartEvent.EVENT_NAME),
|
|
697
|
+
OnDragEndEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragEndEvent.EVENT_NAME)
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
|
|
625
701
|
}
|
|
@@ -35,249 +35,249 @@ import java.util.Map;
|
|
|
35
35
|
@ReactModule(name = MapModule.NAME)
|
|
36
36
|
public class MapModule extends ReactContextBaseJavaModule {
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@Override
|
|
49
|
-
public String getName() {
|
|
50
|
-
return NAME;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@Override
|
|
54
|
-
public Map<String, Object> getConstants() {
|
|
55
|
-
final Map<String, Object> constants = new HashMap<>();
|
|
56
|
-
constants.put("legalNotice", "This license information is displayed in Settings > Google > Open Source on any device running Google Play services.");
|
|
57
|
-
return constants;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public Activity getActivity() {
|
|
61
|
-
return getCurrentActivity();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public static void closeQuietly(Closeable closeable) {
|
|
65
|
-
if (closeable == null) return;
|
|
66
|
-
try {
|
|
67
|
-
closeable.close();
|
|
68
|
-
} catch (IOException ignored) {
|
|
38
|
+
public static final String NAME = "AirMapModule";
|
|
39
|
+
public static final String SNAPSHOT_RESULT_FILE = "file";
|
|
40
|
+
public static final String SNAPSHOT_RESULT_BASE64 = "base64";
|
|
41
|
+
public static final String SNAPSHOT_FORMAT_PNG = "png";
|
|
42
|
+
public static final String SNAPSHOT_FORMAT_JPG = "jpg";
|
|
43
|
+
|
|
44
|
+
public MapModule(ReactApplicationContext reactContext) {
|
|
45
|
+
super(reactContext);
|
|
69
46
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@ReactMethod
|
|
73
|
-
public void takeSnapshot(final int tag, final ReadableMap options, final Promise promise) {
|
|
74
|
-
|
|
75
|
-
// Parse and verity options
|
|
76
|
-
final ReactApplicationContext context = getReactApplicationContext();
|
|
77
|
-
final String format = options.hasKey("format") ? options.getString("format") : "png";
|
|
78
|
-
final Bitmap.CompressFormat compressFormat =
|
|
79
|
-
format.equals(SNAPSHOT_FORMAT_PNG) ? Bitmap.CompressFormat.PNG :
|
|
80
|
-
format.equals(SNAPSHOT_FORMAT_JPG) ? Bitmap.CompressFormat.JPEG : null;
|
|
81
|
-
final double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
|
|
82
|
-
final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
|
83
|
-
final Integer width =
|
|
84
|
-
options.hasKey("width") ? (int) (displayMetrics.density * options.getDouble("width")) : 0;
|
|
85
|
-
final Integer height =
|
|
86
|
-
options.hasKey("height") ? (int) (displayMetrics.density * options.getDouble("height")) : 0;
|
|
87
|
-
final String result = options.hasKey("result") ? options.getString("result") : "file";
|
|
88
|
-
|
|
89
|
-
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
|
|
90
|
-
view.map.snapshot(new GoogleMap.SnapshotReadyCallback() {
|
|
91
|
-
public void onSnapshotReady(@Nullable Bitmap snapshot) {
|
|
92
|
-
|
|
93
|
-
// Convert image to requested width/height if necessary
|
|
94
|
-
if (snapshot == null) {
|
|
95
|
-
promise.reject("Failed to generate bitmap, snapshot = null");
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if ((width != 0) && (height != 0) &&
|
|
99
|
-
(width != snapshot.getWidth() || height != snapshot.getHeight())) {
|
|
100
|
-
snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
|
|
101
|
-
}
|
|
102
47
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
try {
|
|
108
|
-
tempFile =
|
|
109
|
-
File.createTempFile("AirMapSnapshot", "." + format, context.getCacheDir());
|
|
110
|
-
outputStream = new FileOutputStream(tempFile);
|
|
111
|
-
} catch (Exception e) {
|
|
112
|
-
promise.reject(e);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
116
|
-
closeQuietly(outputStream);
|
|
117
|
-
String uri = Uri.fromFile(tempFile).toString();
|
|
118
|
-
promise.resolve(uri);
|
|
119
|
-
} else if (result.equals(SNAPSHOT_RESULT_BASE64)) {
|
|
120
|
-
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
121
|
-
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
122
|
-
closeQuietly(outputStream);
|
|
123
|
-
byte[] bytes = outputStream.toByteArray();
|
|
124
|
-
String data = Base64.encodeToString(bytes, Base64.NO_WRAP);
|
|
125
|
-
promise.resolve(data);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
48
|
+
@Override
|
|
49
|
+
public String getName() {
|
|
50
|
+
return NAME;
|
|
51
|
+
}
|
|
129
52
|
|
|
130
|
-
|
|
131
|
-
|
|
53
|
+
@Override
|
|
54
|
+
public Map<String, Object> getConstants() {
|
|
55
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
56
|
+
constants.put("legalNotice", "This license information is displayed in Settings > Google > Open Source on any device running Google Play services.");
|
|
57
|
+
return constants;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public Activity getActivity() {
|
|
61
|
+
return getCurrentActivity();
|
|
62
|
+
}
|
|
132
63
|
|
|
133
|
-
|
|
64
|
+
public static void closeQuietly(Closeable closeable) {
|
|
65
|
+
if (closeable == null) return;
|
|
66
|
+
try {
|
|
67
|
+
closeable.close();
|
|
68
|
+
} catch (IOException ignored) {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
134
71
|
|
|
135
|
-
|
|
136
|
-
|
|
72
|
+
@ReactMethod
|
|
73
|
+
public void takeSnapshot(final int tag, final ReadableMap options, final Promise promise) {
|
|
74
|
+
|
|
75
|
+
// Parse and verity options
|
|
76
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
77
|
+
final String format = options.hasKey("format") ? options.getString("format") : "png";
|
|
78
|
+
final Bitmap.CompressFormat compressFormat =
|
|
79
|
+
format.equals(SNAPSHOT_FORMAT_PNG) ? Bitmap.CompressFormat.PNG :
|
|
80
|
+
format.equals(SNAPSHOT_FORMAT_JPG) ? Bitmap.CompressFormat.JPEG : null;
|
|
81
|
+
final double quality = options.hasKey("quality") ? options.getDouble("quality") : 1.0;
|
|
82
|
+
final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
|
83
|
+
final Integer width =
|
|
84
|
+
options.hasKey("width") ? (int) (displayMetrics.density * options.getDouble("width")) : 0;
|
|
85
|
+
final Integer height =
|
|
86
|
+
options.hasKey("height") ? (int) (displayMetrics.density * options.getDouble("height")) : 0;
|
|
87
|
+
final String result = options.hasKey("result") ? options.getString("result") : "file";
|
|
88
|
+
|
|
89
|
+
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
|
|
90
|
+
view.map.snapshot(new GoogleMap.SnapshotReadyCallback() {
|
|
91
|
+
public void onSnapshotReady(@Nullable Bitmap snapshot) {
|
|
92
|
+
|
|
93
|
+
// Convert image to requested width/height if necessary
|
|
94
|
+
if (snapshot == null) {
|
|
95
|
+
promise.reject("Failed to generate bitmap, snapshot = null");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if ((width != 0) && (height != 0) &&
|
|
99
|
+
(width != snapshot.getWidth() || height != snapshot.getHeight())) {
|
|
100
|
+
snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Save the snapshot to disk
|
|
104
|
+
if (result.equals(SNAPSHOT_RESULT_FILE)) {
|
|
105
|
+
File tempFile;
|
|
106
|
+
FileOutputStream outputStream;
|
|
107
|
+
try {
|
|
108
|
+
tempFile =
|
|
109
|
+
File.createTempFile("AirMapSnapshot", "." + format, context.getCacheDir());
|
|
110
|
+
outputStream = new FileOutputStream(tempFile);
|
|
111
|
+
} catch (Exception e) {
|
|
112
|
+
promise.reject(e);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
116
|
+
closeQuietly(outputStream);
|
|
117
|
+
String uri = Uri.fromFile(tempFile).toString();
|
|
118
|
+
promise.resolve(uri);
|
|
119
|
+
} else if (result.equals(SNAPSHOT_RESULT_BASE64)) {
|
|
120
|
+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
121
|
+
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
122
|
+
closeQuietly(outputStream);
|
|
123
|
+
byte[] bytes = outputStream.toByteArray();
|
|
124
|
+
String data = Base64.encodeToString(bytes, Base64.NO_WRAP);
|
|
125
|
+
promise.resolve(data);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
137
129
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
final ReactApplicationContext context = getReactApplicationContext();
|
|
130
|
+
return null;
|
|
131
|
+
});
|
|
141
132
|
|
|
142
|
-
|
|
143
|
-
CameraPosition position = view.map.getCameraPosition();
|
|
133
|
+
// Add UI-block so we can get a valid reference to the map-view
|
|
144
134
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
centerJson.putDouble("longitude", position.target.longitude);
|
|
135
|
+
uiBlock.addToUIManager();
|
|
136
|
+
}
|
|
148
137
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
cameraJson.putDouble("zoom", (double)position.zoom);
|
|
153
|
-
cameraJson.putDouble("pitch", (double)position.tilt);
|
|
138
|
+
@ReactMethod
|
|
139
|
+
public void getCamera(final int tag, final Promise promise) {
|
|
140
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
154
141
|
|
|
155
|
-
promise
|
|
142
|
+
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
|
|
143
|
+
CameraPosition position = view.map.getCameraPosition();
|
|
156
144
|
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
WritableMap centerJson = new WritableNativeMap();
|
|
146
|
+
centerJson.putDouble("latitude", position.target.latitude);
|
|
147
|
+
centerJson.putDouble("longitude", position.target.longitude);
|
|
159
148
|
|
|
160
|
-
|
|
161
|
-
|
|
149
|
+
WritableMap cameraJson = new WritableNativeMap();
|
|
150
|
+
cameraJson.putMap("center", centerJson);
|
|
151
|
+
cameraJson.putDouble("heading", (double) position.bearing);
|
|
152
|
+
cameraJson.putDouble("zoom", (double) position.zoom);
|
|
153
|
+
cameraJson.putDouble("pitch", (double) position.tilt);
|
|
162
154
|
|
|
163
|
-
|
|
164
|
-
public void getAddressFromCoordinates(final int tag, final ReadableMap coordinate, final Promise promise) {
|
|
165
|
-
final ReactApplicationContext context = getReactApplicationContext();
|
|
155
|
+
promise.resolve(cameraJson);
|
|
166
156
|
|
|
167
|
-
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, mapView -> {
|
|
168
|
-
if (coordinate == null ||
|
|
169
|
-
!coordinate.hasKey("latitude") ||
|
|
170
|
-
!coordinate.hasKey("longitude")) {
|
|
171
|
-
promise.reject("Invalid coordinate format");
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
Geocoder geocoder = new Geocoder(context);
|
|
175
|
-
try {
|
|
176
|
-
List<Address> list =
|
|
177
|
-
geocoder.getFromLocation(coordinate.getDouble("latitude"),coordinate.getDouble("longitude"),1);
|
|
178
|
-
if (list.isEmpty()) {
|
|
179
|
-
promise.reject("Can not get address location");
|
|
180
157
|
return null;
|
|
181
|
-
|
|
182
|
-
Address address = list.get(0);
|
|
183
|
-
|
|
184
|
-
WritableMap addressJson = new WritableNativeMap();
|
|
185
|
-
addressJson.putString("name", address.getFeatureName());
|
|
186
|
-
addressJson.putString("locality", address.getLocality());
|
|
187
|
-
addressJson.putString("thoroughfare", address.getThoroughfare());
|
|
188
|
-
addressJson.putString("subThoroughfare", address.getSubThoroughfare());
|
|
189
|
-
addressJson.putString("subLocality", address.getSubLocality());
|
|
190
|
-
addressJson.putString("administrativeArea", address.getAdminArea());
|
|
191
|
-
addressJson.putString("subAdministrativeArea", address.getSubAdminArea());
|
|
192
|
-
addressJson.putString("postalCode", address.getPostalCode());
|
|
193
|
-
addressJson.putString("countryCode", address.getCountryCode());
|
|
194
|
-
addressJson.putString("country", address.getCountryName());
|
|
195
|
-
|
|
196
|
-
promise.resolve(addressJson);
|
|
197
|
-
} catch (IOException e) {
|
|
198
|
-
promise.reject("Can not get address location");
|
|
199
|
-
}
|
|
158
|
+
});
|
|
200
159
|
|
|
201
|
-
|
|
202
|
-
}
|
|
160
|
+
uiBlock.addToUIManager();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ReactMethod
|
|
164
|
+
public void getAddressFromCoordinates(final int tag, final ReadableMap coordinate, final Promise promise) {
|
|
165
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
166
|
+
|
|
167
|
+
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, mapView -> {
|
|
168
|
+
if (coordinate == null ||
|
|
169
|
+
!coordinate.hasKey("latitude") ||
|
|
170
|
+
!coordinate.hasKey("longitude")) {
|
|
171
|
+
promise.reject("Invalid coordinate format");
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
Geocoder geocoder = new Geocoder(context);
|
|
175
|
+
try {
|
|
176
|
+
List<Address> list =
|
|
177
|
+
geocoder.getFromLocation(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"), 1);
|
|
178
|
+
if (list.isEmpty()) {
|
|
179
|
+
promise.reject("Can not get address location");
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
Address address = list.get(0);
|
|
183
|
+
|
|
184
|
+
WritableMap addressJson = new WritableNativeMap();
|
|
185
|
+
addressJson.putString("name", address.getFeatureName());
|
|
186
|
+
addressJson.putString("locality", address.getLocality());
|
|
187
|
+
addressJson.putString("thoroughfare", address.getThoroughfare());
|
|
188
|
+
addressJson.putString("subThoroughfare", address.getSubThoroughfare());
|
|
189
|
+
addressJson.putString("subLocality", address.getSubLocality());
|
|
190
|
+
addressJson.putString("administrativeArea", address.getAdminArea());
|
|
191
|
+
addressJson.putString("subAdministrativeArea", address.getSubAdminArea());
|
|
192
|
+
addressJson.putString("postalCode", address.getPostalCode());
|
|
193
|
+
addressJson.putString("countryCode", address.getCountryCode());
|
|
194
|
+
addressJson.putString("country", address.getCountryName());
|
|
195
|
+
|
|
196
|
+
promise.resolve(addressJson);
|
|
197
|
+
} catch (IOException e) {
|
|
198
|
+
promise.reject("Can not get address location");
|
|
199
|
+
}
|
|
203
200
|
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
return null;
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
uiBlock.addToUIManager();
|
|
205
|
+
}
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
@ReactMethod
|
|
208
|
+
public void pointForCoordinate(final int tag, ReadableMap coordinate, final Promise promise) {
|
|
209
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
210
|
+
final double density = (double) context.getResources().getDisplayMetrics().density;
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
final LatLng coord = new LatLng(
|
|
213
|
+
coordinate.hasKey("latitude") ? coordinate.getDouble("latitude") : 0.0,
|
|
214
|
+
coordinate.hasKey("longitude") ? coordinate.getDouble("longitude") : 0.0
|
|
215
|
+
);
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
|
|
218
|
+
Point pt = view.map.getProjection().toScreenLocation(coord);
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
WritableMap ptJson = new WritableNativeMap();
|
|
221
|
+
ptJson.putDouble("x", (double) pt.x / density);
|
|
222
|
+
ptJson.putDouble("y", (double) pt.y / density);
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
promise.resolve(ptJson);
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
return null;
|
|
227
|
+
});
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
uiBlock.addToUIManager();
|
|
230
|
+
}
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
@ReactMethod
|
|
233
|
+
public void coordinateForPoint(final int tag, ReadableMap point, final Promise promise) {
|
|
234
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
235
|
+
final double density = (double) context.getResources().getDisplayMetrics().density;
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
final Point pt = new Point(
|
|
238
|
+
point.hasKey("x") ? (int) (point.getDouble("x") * density) : 0,
|
|
239
|
+
point.hasKey("y") ? (int) (point.getDouble("y") * density) : 0
|
|
240
|
+
);
|
|
241
241
|
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
|
|
243
|
+
LatLng coord = view.map.getProjection().fromScreenLocation(pt);
|
|
244
244
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
WritableMap coordJson = new WritableNativeMap();
|
|
246
|
+
coordJson.putDouble("latitude", coord.latitude);
|
|
247
|
+
coordJson.putDouble("longitude", coord.longitude);
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
promise.resolve(coordJson);
|
|
250
250
|
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
return null;
|
|
252
|
+
});
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
uiBlock.addToUIManager();
|
|
255
|
+
}
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
@ReactMethod
|
|
258
|
+
public void getMapBoundaries(final int tag, final Promise promise) {
|
|
259
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
260
260
|
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
MapUIBlock uiBlock = new MapUIBlock(tag, promise, context, view -> {
|
|
262
|
+
double[][] boundaries = view.getMapBoundaries();
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
WritableMap coordinates = new WritableNativeMap();
|
|
265
|
+
WritableMap northEastHash = new WritableNativeMap();
|
|
266
|
+
WritableMap southWestHash = new WritableNativeMap();
|
|
267
267
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
northEastHash.putDouble("longitude", boundaries[0][0]);
|
|
269
|
+
northEastHash.putDouble("latitude", boundaries[0][1]);
|
|
270
|
+
southWestHash.putDouble("longitude", boundaries[1][0]);
|
|
271
|
+
southWestHash.putDouble("latitude", boundaries[1][1]);
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
coordinates.putMap("northEast", northEastHash);
|
|
274
|
+
coordinates.putMap("southWest", southWestHash);
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
promise.resolve(coordinates);
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
return null;
|
|
279
|
+
});
|
|
280
280
|
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
uiBlock.addToUIManager();
|
|
282
|
+
}
|
|
283
283
|
}
|