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
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
package com.rnmaps.fabric;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import android.graphics.Color;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
import android.view.View;
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.NonNull;
|
|
9
|
+
import androidx.annotation.Nullable;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
13
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
14
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
|
15
|
+
import com.facebook.react.uimanager.StateWrapper;
|
|
16
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
17
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
18
|
+
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
19
|
+
import com.facebook.react.viewmanagers.RNMapsMarkerManagerDelegate;
|
|
20
|
+
import com.facebook.react.viewmanagers.RNMapsMarkerManagerInterface;
|
|
21
|
+
import com.google.android.gms.maps.model.LatLng;
|
|
22
|
+
import com.google.android.gms.maps.model.Marker;
|
|
23
|
+
import com.google.android.gms.maps.model.MarkerOptions;
|
|
24
|
+
import com.rnmaps.maps.MapCallout;
|
|
25
|
+
import com.rnmaps.maps.MapMarker;
|
|
26
|
+
|
|
27
|
+
import java.util.Map;
|
|
28
|
+
|
|
29
|
+
@ReactModule(name = MarkerManager.REACT_CLASS)
|
|
30
|
+
public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMapsMarkerManagerInterface<MapMarker> {
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
public MarkerManager(ReactApplicationContext context){
|
|
34
|
+
super(context);
|
|
35
|
+
}
|
|
36
|
+
private final RNMapsMarkerManagerDelegate<MapMarker, MarkerManager> delegate =
|
|
37
|
+
new RNMapsMarkerManagerDelegate<>(this);
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public ViewManagerDelegate<MapMarker> getDelegate() {
|
|
41
|
+
return delegate;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public String getName() {
|
|
46
|
+
return REACT_CLASS;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public MapMarker createViewInstance(ThemedReactContext context) {
|
|
51
|
+
return new MapMarker(context, null);
|
|
52
|
+
}
|
|
53
|
+
private MarkerOptions optionsForInitialProps(ReactStylesDiffMap initialProps){
|
|
54
|
+
MarkerOptions options = new MarkerOptions();
|
|
55
|
+
if (initialProps != null) {
|
|
56
|
+
if (initialProps.hasKey("opacity")) {
|
|
57
|
+
options.alpha(initialProps.getFloat("opacity", 1));
|
|
58
|
+
}
|
|
59
|
+
if (initialProps.hasKey("anchor")) {
|
|
60
|
+
ReadableMap map = initialProps.getMap("anchor");
|
|
61
|
+
float x = (float) (map != null && map.hasKey("x") ? map.getDouble("x") : 0.5);
|
|
62
|
+
float y = (float) (map != null && map.hasKey("y") ? map.getDouble("y") : 1.0);
|
|
63
|
+
options.anchor(x, y);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (initialProps.hasKey("coordinate")) {
|
|
67
|
+
ReadableMap coordinate = initialProps.getMap("coordinate");
|
|
68
|
+
LatLng position = new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"));
|
|
69
|
+
options.position(position);
|
|
70
|
+
}
|
|
71
|
+
if (initialProps.hasKey("title")) {
|
|
72
|
+
options.title(initialProps.getString("title"));
|
|
73
|
+
}
|
|
74
|
+
if (initialProps.hasKey("description")) {
|
|
75
|
+
options.snippet(initialProps.getString("description"));
|
|
76
|
+
}
|
|
77
|
+
if (initialProps.hasKey("draggable")){
|
|
78
|
+
options.draggable(initialProps.getBoolean("draggable", false));
|
|
79
|
+
}
|
|
80
|
+
if (initialProps.hasKey("rotation")){
|
|
81
|
+
options.rotation(initialProps.getFloat("rotation", 0));
|
|
82
|
+
}
|
|
83
|
+
if (initialProps.hasKey("flat")) {
|
|
84
|
+
options.flat(initialProps.getBoolean("flat", false));
|
|
85
|
+
}
|
|
86
|
+
if (initialProps.hasKey("calloutAnchor")){
|
|
87
|
+
ReadableMap map = initialProps.getMap("calloutAnchor");
|
|
88
|
+
float x = (float) (map != null && map.hasKey("x") ? map.getDouble("x") : 0.5);
|
|
89
|
+
float y = (float) (map != null && map.hasKey("y") ? map.getDouble("y") : 1.0);
|
|
90
|
+
options.infoWindowAnchor(x, y);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (initialProps.hasKey("zIndex")){
|
|
94
|
+
options.zIndex(initialProps.getFloat("zIndex", 0));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return options;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@Override
|
|
101
|
+
protected MapMarker createViewInstance(int reactTag, @NonNull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) {
|
|
102
|
+
MapMarker view = null;
|
|
103
|
+
view = new MapMarker(reactContext, optionsForInitialProps(initialProps), null);
|
|
104
|
+
view.setId(reactTag);
|
|
105
|
+
this.addEventEmitters(reactContext, view);
|
|
106
|
+
if (initialProps != null) {
|
|
107
|
+
this.updateProperties(view, initialProps);
|
|
108
|
+
}
|
|
109
|
+
if (stateWrapper != null) {
|
|
110
|
+
Object extraData = this.updateState(view, initialProps, stateWrapper);
|
|
111
|
+
if (extraData != null) {
|
|
112
|
+
this.updateExtraData(view, extraData);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return view;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
public static final String REACT_CLASS = "RNMapsMarker";
|
|
120
|
+
|
|
121
|
+
@Nullable
|
|
122
|
+
@Override
|
|
123
|
+
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
124
|
+
return MapMarker.getExportedCustomBubblingEventTypeConstants();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@Nullable
|
|
128
|
+
@Override
|
|
129
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
130
|
+
return MapMarker.getExportedCustomDirectEventTypeConstants();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@Override
|
|
134
|
+
public void setAnchor(MapMarker view, @Nullable ReadableMap map) {
|
|
135
|
+
double x = map != null && map.hasKey("x") ? map.getDouble("x") : 0.5;
|
|
136
|
+
double y = map != null && map.hasKey("y") ? map.getDouble("y") : 1.0;
|
|
137
|
+
view.setAnchor(x, y);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Override
|
|
141
|
+
public void setCalloutAnchor(MapMarker view, @Nullable ReadableMap value) {
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Override
|
|
146
|
+
public void setImage(MapMarker view, @Nullable ReadableMap value) {
|
|
147
|
+
view.setImage(value.getString("uri"));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@Override
|
|
151
|
+
public void setCalloutOffset(MapMarker view, @Nullable ReadableMap value) {
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@Override
|
|
156
|
+
public void setDisplayPriority(MapMarker view, @Nullable String value) {
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@Override
|
|
161
|
+
public void setCoordinate(MapMarker view, @Nullable ReadableMap value) {
|
|
162
|
+
view.setCoordinate(value);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@Override
|
|
166
|
+
public void setDescription(MapMarker view, @Nullable String value) {
|
|
167
|
+
view.setSnippet(value);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@Override
|
|
171
|
+
public void setDraggable(MapMarker view, boolean value) {
|
|
172
|
+
view.setDraggable(value);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@Override
|
|
176
|
+
public void setTitle(MapMarker view, @Nullable String value) {
|
|
177
|
+
view.setTitle(value);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@Override
|
|
181
|
+
public void setIdentifier(MapMarker view, @Nullable String value) {
|
|
182
|
+
view.setIdentifier(value);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@Override
|
|
186
|
+
public void setIsPreselected(MapMarker view, boolean value) {
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@Override
|
|
191
|
+
public void setOpacity(MapMarker view, double value) {
|
|
192
|
+
view.setOpacity((float) value);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@Override
|
|
196
|
+
public void setPinColor(MapMarker view, @Nullable Integer value) {
|
|
197
|
+
float[] hsv = new float[3];
|
|
198
|
+
Color.colorToHSV(value, hsv);
|
|
199
|
+
// NOTE: android only supports a hue
|
|
200
|
+
view.setMarkerHue(hsv[0]);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@Override
|
|
204
|
+
public void setTitleVisibility(MapMarker view, @Nullable String value) {
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@Override
|
|
209
|
+
public void setSubtitleVisibility(MapMarker view, @Nullable String value) {
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@Override
|
|
214
|
+
public void setUseLegacyPinView(MapMarker view, boolean value) {
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@Override
|
|
219
|
+
public void animateToCoordinates(MapMarker view, double latitude, double longitude, int duration) {
|
|
220
|
+
view.animateToCoodinate(new LatLng(latitude, longitude), duration);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@Override
|
|
224
|
+
public void setCoordinates(MapMarker view, double latitude, double longitude) {
|
|
225
|
+
view.setCoordinate(new LatLng(latitude, longitude));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@Override
|
|
229
|
+
public void showCallout(MapMarker view) {
|
|
230
|
+
((Marker) view.getFeature()).showInfoWindow();
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@Override
|
|
235
|
+
public void hideCallout(MapMarker view) {
|
|
236
|
+
((Marker) view.getFeature()).hideInfoWindow();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@Override
|
|
240
|
+
public void redrawCallout(MapMarker view) {
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
@Override
|
|
245
|
+
public void redraw(MapMarker view) {
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
@Override
|
|
249
|
+
public void addView(MapMarker parent, View child, int index) {
|
|
250
|
+
// if an <Callout /> component is a child, then it is a callout view, NOT part of the
|
|
251
|
+
// marker.
|
|
252
|
+
if (child instanceof MapCallout) {
|
|
253
|
+
parent.setCalloutView((MapCallout) child);
|
|
254
|
+
} else {
|
|
255
|
+
super.addView(parent, child, index);
|
|
256
|
+
parent.update(true);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
package com.rnmaps.fabric;
|
|
2
2
|
|
|
3
|
+
import static com.rnmaps.maps.MapModule.SNAPSHOT_FORMAT_JPG;
|
|
4
|
+
import static com.rnmaps.maps.MapModule.SNAPSHOT_FORMAT_PNG;
|
|
5
|
+
import static com.rnmaps.maps.MapModule.SNAPSHOT_RESULT_BASE64;
|
|
6
|
+
import static com.rnmaps.maps.MapModule.SNAPSHOT_RESULT_FILE;
|
|
7
|
+
import static com.rnmaps.maps.MapModule.closeQuietly;
|
|
8
|
+
|
|
9
|
+
import android.graphics.Bitmap;
|
|
10
|
+
import android.net.Uri;
|
|
11
|
+
import android.util.Base64;
|
|
12
|
+
import android.util.DisplayMetrics;
|
|
13
|
+
|
|
14
|
+
import androidx.annotation.Nullable;
|
|
15
|
+
|
|
16
|
+
import com.facebook.fbreact.specs.NativeAirMapsModuleSpec;
|
|
17
|
+
import com.facebook.react.bridge.Arguments;
|
|
3
18
|
import com.facebook.react.bridge.Promise;
|
|
4
19
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
20
|
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.bridge.UIManager;
|
|
22
|
+
import com.facebook.react.bridge.WritableMap;
|
|
23
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
24
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
25
|
+
import com.google.android.gms.maps.GoogleMap;
|
|
26
|
+
import com.google.android.gms.maps.model.CameraPosition;
|
|
27
|
+
import com.rnmaps.maps.MapUIBlock;
|
|
28
|
+
import com.rnmaps.maps.MapView;
|
|
29
|
+
|
|
30
|
+
import org.json.JSONException;
|
|
31
|
+
import org.json.JSONObject;
|
|
32
|
+
|
|
33
|
+
import java.io.ByteArrayOutputStream;
|
|
34
|
+
import java.io.File;
|
|
35
|
+
import java.io.FileOutputStream;
|
|
6
36
|
|
|
7
37
|
public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
8
38
|
public NativeAirMapsModule(ReactApplicationContext reactContext) {
|
|
@@ -16,22 +46,144 @@ public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
|
16
46
|
|
|
17
47
|
@Override
|
|
18
48
|
public void getCamera(double tag, Promise promise) {
|
|
19
|
-
|
|
49
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(), (int) tag);
|
|
50
|
+
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
|
|
51
|
+
@Override
|
|
52
|
+
public void run() {
|
|
53
|
+
MapView view = (MapView) uiManager.resolveView((int) tag);
|
|
54
|
+
CameraPosition position = view.map.getCameraPosition();
|
|
55
|
+
WritableMap map = Arguments.createMap();
|
|
56
|
+
WritableMap center = Arguments.createMap();
|
|
57
|
+
center.putDouble("latitude", position.target.latitude);
|
|
58
|
+
center.putDouble("longitude", position.target.longitude);
|
|
59
|
+
map.putMap("center", center);
|
|
60
|
+
map.putDouble("heading", position.bearing);
|
|
61
|
+
map.putDouble("pitch", position.tilt);
|
|
62
|
+
map.putDouble("zoom", position.zoom);
|
|
63
|
+
promise.resolve(map);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
20
66
|
}
|
|
21
67
|
|
|
22
68
|
@Override
|
|
23
69
|
public void getMarkersFrames(double tag, boolean onlyVisible, Promise promise) {
|
|
24
70
|
|
|
71
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(), (int) tag);
|
|
72
|
+
getReactApplicationContext().runOnUiQueueThread(() -> {
|
|
73
|
+
MapView view = (MapView) uiManager.resolveView((int) tag);
|
|
74
|
+
double[][] boundaries = view.getMarkersFrames(onlyVisible);
|
|
75
|
+
if (boundaries != null) {
|
|
76
|
+
WritableMap coordinates = new WritableNativeMap();
|
|
77
|
+
WritableMap northEastHash = new WritableNativeMap();
|
|
78
|
+
WritableMap southWestHash = new WritableNativeMap();
|
|
79
|
+
|
|
80
|
+
northEastHash.putDouble("longitude", boundaries[0][0]);
|
|
81
|
+
northEastHash.putDouble("latitude", boundaries[0][1]);
|
|
82
|
+
southWestHash.putDouble("longitude", boundaries[1][0]);
|
|
83
|
+
southWestHash.putDouble("latitude", boundaries[1][1]);
|
|
84
|
+
|
|
85
|
+
coordinates.putMap("northEast", northEastHash);
|
|
86
|
+
coordinates.putMap("southWest", southWestHash);
|
|
87
|
+
|
|
88
|
+
promise.resolve(coordinates);
|
|
89
|
+
} else {
|
|
90
|
+
promise.resolve(null);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
25
93
|
}
|
|
26
94
|
|
|
27
95
|
@Override
|
|
28
96
|
public void getMapBoundaries(double tag, Promise promise) {
|
|
29
|
-
|
|
97
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(), (int) tag);
|
|
98
|
+
getReactApplicationContext().runOnUiQueueThread(() -> {
|
|
99
|
+
MapView view = (MapView) uiManager.resolveView((int) tag);
|
|
100
|
+
double[][] boundaries = view.getMapBoundaries();
|
|
101
|
+
WritableMap coordinates = new WritableNativeMap();
|
|
102
|
+
WritableMap northEastHash = new WritableNativeMap();
|
|
103
|
+
WritableMap southWestHash = new WritableNativeMap();
|
|
104
|
+
|
|
105
|
+
northEastHash.putDouble("longitude", boundaries[0][0]);
|
|
106
|
+
northEastHash.putDouble("latitude", boundaries[0][1]);
|
|
107
|
+
southWestHash.putDouble("longitude", boundaries[1][0]);
|
|
108
|
+
southWestHash.putDouble("latitude", boundaries[1][1]);
|
|
109
|
+
|
|
110
|
+
coordinates.putMap("northEast", northEastHash);
|
|
111
|
+
coordinates.putMap("southWest", southWestHash);
|
|
112
|
+
|
|
113
|
+
promise.resolve(coordinates);
|
|
114
|
+
});
|
|
30
115
|
}
|
|
31
116
|
|
|
32
117
|
@Override
|
|
33
|
-
public void takeSnapshot(double tag,
|
|
34
|
-
|
|
118
|
+
public void takeSnapshot(double tag, String config, Promise promise) {
|
|
119
|
+
WritableMap options = null;
|
|
120
|
+
try {
|
|
121
|
+
if (config != null) {
|
|
122
|
+
JSONObject jsonObject = new JSONObject(config);
|
|
123
|
+
options = JSONUtil.convertJsonToWritable(jsonObject);
|
|
124
|
+
WritableMap finalOptions = options;
|
|
125
|
+
|
|
126
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
127
|
+
final String format = finalOptions.hasKey("format") ? finalOptions.getString("format") : "png";
|
|
128
|
+
final Bitmap.CompressFormat compressFormat =
|
|
129
|
+
format.equals(SNAPSHOT_FORMAT_PNG) ? Bitmap.CompressFormat.PNG :
|
|
130
|
+
format.equals(SNAPSHOT_FORMAT_JPG) ? Bitmap.CompressFormat.JPEG : null;
|
|
131
|
+
final double quality = finalOptions.hasKey("quality") ? finalOptions.getDouble("quality") : 1.0;
|
|
132
|
+
final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
|
133
|
+
final Integer width =
|
|
134
|
+
finalOptions.hasKey("width") ? (int) (displayMetrics.density * finalOptions.getDouble("width")) : 0;
|
|
135
|
+
final Integer height =
|
|
136
|
+
finalOptions.hasKey("height") ? (int) (displayMetrics.density * finalOptions.getDouble("height")) : 0;
|
|
137
|
+
final String result = finalOptions.hasKey("result") ? finalOptions.getString("result") : "file";
|
|
138
|
+
|
|
139
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(), (int) tag);
|
|
140
|
+
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
|
|
141
|
+
@Override
|
|
142
|
+
public void run() {
|
|
143
|
+
MapView view = (MapView) uiManager.resolveView((int) tag);
|
|
144
|
+
view.map.snapshot(snapshot -> {
|
|
145
|
+
|
|
146
|
+
// Convert image to requested width/height if necessary
|
|
147
|
+
if (snapshot == null) {
|
|
148
|
+
promise.reject("Failed to generate bitmap, snapshot = null");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if ((width != 0) && (height != 0) &&
|
|
152
|
+
(width != snapshot.getWidth() || height != snapshot.getHeight())) {
|
|
153
|
+
snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
|
|
154
|
+
}
|
|
155
|
+
// Save the snapshot to disk
|
|
156
|
+
if (result.equals(SNAPSHOT_RESULT_FILE)) {
|
|
157
|
+
File tempFile;
|
|
158
|
+
FileOutputStream outputStream;
|
|
159
|
+
try {
|
|
160
|
+
tempFile =
|
|
161
|
+
File.createTempFile("AirMapSnapshot", "." + format, context.getCacheDir());
|
|
162
|
+
outputStream = new FileOutputStream(tempFile);
|
|
163
|
+
} catch (Exception e) {
|
|
164
|
+
promise.reject(e);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
168
|
+
closeQuietly(outputStream);
|
|
169
|
+
String uri = Uri.fromFile(tempFile).toString();
|
|
170
|
+
promise.resolve(uri);
|
|
171
|
+
} else if (result.equals(SNAPSHOT_RESULT_BASE64)) {
|
|
172
|
+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
173
|
+
snapshot.compress(compressFormat, (int) (100.0 * quality), outputStream);
|
|
174
|
+
closeQuietly(outputStream);
|
|
175
|
+
byte[] bytes = outputStream.toByteArray();
|
|
176
|
+
String data = Base64.encodeToString(bytes, Base64.NO_WRAP);
|
|
177
|
+
promise.resolve(data);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
} catch (JSONException e) {
|
|
184
|
+
promise.reject("Failed to parse config ", config);
|
|
185
|
+
|
|
186
|
+
}
|
|
35
187
|
}
|
|
36
188
|
|
|
37
189
|
@Override
|
|
@@ -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 OnCalloutPressEvent extends Event<OnCalloutPressEvent> {
|
|
7
|
+
public static final String EVENT_NAME = "topCalloutPress";
|
|
8
|
+
|
|
9
|
+
private final WritableMap payload;
|
|
10
|
+
|
|
11
|
+
public OnCalloutPressEvent(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
|
+
}
|
|
@@ -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 OnDeselectEvent extends Event<OnDeselectEvent> {
|
|
9
|
+
public static final String EVENT_NAME = "topDeselect";
|
|
10
|
+
|
|
11
|
+
private final WritableMap payload;
|
|
12
|
+
|
|
13
|
+
public OnDeselectEvent(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
|
+
}
|
|
@@ -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 OnDragEndEvent extends Event<OnDragEndEvent> {
|
|
9
|
+
public static final String EVENT_NAME = "topDragEnd";
|
|
10
|
+
|
|
11
|
+
private final WritableMap payload;
|
|
12
|
+
|
|
13
|
+
public OnDragEndEvent(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
|
+
}
|
|
@@ -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 OnDragEvent extends Event<OnDragEvent> {
|
|
9
|
+
public static final String EVENT_NAME = "topDrag";
|
|
10
|
+
|
|
11
|
+
private final WritableMap payload;
|
|
12
|
+
|
|
13
|
+
public OnDragEvent(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
|
+
}
|
|
@@ -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 OnDragStartEvent extends Event<OnDragStartEvent> {
|
|
9
|
+
public static final String EVENT_NAME = "topDragStart";
|
|
10
|
+
|
|
11
|
+
private final WritableMap payload;
|
|
12
|
+
|
|
13
|
+
public OnDragStartEvent(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
|
+
}
|
|
@@ -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 OnLongPressEvent extends Event<OnLongPressEvent> {
|
|
9
|
+
public static final String EVENT_NAME = "topLongPress";
|
|
10
|
+
|
|
11
|
+
private final WritableMap payload;
|
|
12
|
+
|
|
13
|
+
public OnLongPressEvent(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
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
|
|
9
|
+
public class OnMapLoadedEvent extends Event<OnMapLoadedEvent> {
|
|
10
|
+
public static final String EVENT_NAME = "topMapLoaded";
|
|
11
|
+
|
|
12
|
+
private final WritableMap payload;
|
|
13
|
+
|
|
14
|
+
public OnMapLoadedEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
15
|
+
super(surfaceId, viewId);
|
|
16
|
+
this.payload = payload;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@NonNull
|
|
20
|
+
@Override
|
|
21
|
+
public String getEventName() {
|
|
22
|
+
return EVENT_NAME;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public WritableMap getEventData() {
|
|
27
|
+
return payload;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
|
|
9
|
+
public class OnMapReadyEvent extends Event<OnMapReadyEvent> {
|
|
10
|
+
public static final String EVENT_NAME = "topMapReady";
|
|
11
|
+
|
|
12
|
+
private final WritableMap payload;
|
|
13
|
+
|
|
14
|
+
public OnMapReadyEvent(int surfaceId, int viewId, WritableMap payload) {
|
|
15
|
+
super(surfaceId, viewId);
|
|
16
|
+
this.payload = payload;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@NonNull
|
|
20
|
+
@Override
|
|
21
|
+
public String getEventName() {
|
|
22
|
+
return EVENT_NAME;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public WritableMap getEventData() {
|
|
27
|
+
return payload;
|
|
28
|
+
}
|
|
29
|
+
}
|