react-native-maps 1.21.0-alpha.65 → 1.21.0-alpha.67
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/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +1 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +22 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.cpp +8 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +11 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +6 -2
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +1 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +11 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/States.h +12 -0
- package/android/src/main/java/com/rnmaps/fabric/CalloutManager.java +89 -0
- package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +0 -3
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +16 -1
- package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +107 -18
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +5 -1
- package/android/src/main/java/com/rnmaps/maps/MapCallout.java +19 -0
- package/android/src/main/java/com/rnmaps/maps/MapModule.java +206 -206
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +1 -0
- package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +1 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.cpp +22 -0
- package/ios/generated/RNMapsSpecs/EventEmitters.h +22 -0
- package/ios/generated/RNMapsSpecs/Props.cpp +8 -0
- package/ios/generated/RNMapsSpecs/Props.h +11 -0
- package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +3 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +1 -0
- package/ios/generated/RNMapsSpecs/ShadowNodes.h +11 -0
- package/ios/generated/RNMapsSpecs/States.h +12 -0
- package/ios/generated/RNMapsSpecsJSI.h +6 -2
- package/lib/MapCallout.js +1 -0
- package/lib/MapView.js +3 -9
- package/lib/decorateMapComponent.js +5 -0
- package/lib/specs/NativeComponentCallout.d.ts +46 -0
- package/lib/specs/NativeComponentCallout.js +9 -0
- package/package.json +1 -1
package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp
CHANGED
|
@@ -16,6 +16,7 @@ namespace facebook::react {
|
|
|
16
16
|
|
|
17
17
|
void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
|
|
18
18
|
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
|
+
registry->add(concreteComponentDescriptorProvider<RNMapsCalloutComponentDescriptor>());
|
|
19
20
|
registry->add(concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDescriptor>());
|
|
20
21
|
registry->add(concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>());
|
|
21
22
|
registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>());
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
namespace facebook::react {
|
|
18
18
|
|
|
19
|
+
using RNMapsCalloutComponentDescriptor = ConcreteComponentDescriptor<RNMapsCalloutShadowNode>;
|
|
19
20
|
using RNMapsGoogleMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsGoogleMapViewShadowNode>;
|
|
20
21
|
using RNMapsGooglePolygonComponentDescriptor = ConcreteComponentDescriptor<RNMapsGooglePolygonShadowNode>;
|
|
21
22
|
using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapViewShadowNode>;
|
|
@@ -13,6 +13,28 @@
|
|
|
13
13
|
|
|
14
14
|
namespace facebook::react {
|
|
15
15
|
|
|
16
|
+
void RNMapsCalloutEventEmitter::onPress(OnPress $event) const {
|
|
17
|
+
dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
18
|
+
auto $payload = jsi::Object(runtime);
|
|
19
|
+
$payload.setProperty(runtime, "action", $event.action);
|
|
20
|
+
$payload.setProperty(runtime, "id", $event.id);
|
|
21
|
+
{
|
|
22
|
+
auto coordinate = jsi::Object(runtime);
|
|
23
|
+
coordinate.setProperty(runtime, "latitude", $event.coordinate.latitude);
|
|
24
|
+
coordinate.setProperty(runtime, "longitude", $event.coordinate.longitude);
|
|
25
|
+
$payload.setProperty(runtime, "coordinate", coordinate);
|
|
26
|
+
}
|
|
27
|
+
{
|
|
28
|
+
auto position = jsi::Object(runtime);
|
|
29
|
+
position.setProperty(runtime, "x", $event.position.x);
|
|
30
|
+
position.setProperty(runtime, "y", $event.position.y);
|
|
31
|
+
$payload.setProperty(runtime, "position", position);
|
|
32
|
+
}
|
|
33
|
+
return $payload;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
16
38
|
void RNMapsGoogleMapViewEventEmitter::onIndoorBuildingFocused(OnIndoorBuildingFocused $event) const {
|
|
17
39
|
dispatchEvent("indoorBuildingFocused", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
18
40
|
auto $payload = jsi::Object(runtime);
|
|
@@ -13,6 +13,28 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
namespace facebook::react {
|
|
16
|
+
class RNMapsCalloutEventEmitter : public ViewEventEmitter {
|
|
17
|
+
public:
|
|
18
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
19
|
+
|
|
20
|
+
struct OnPressCoordinate {
|
|
21
|
+
double latitude;
|
|
22
|
+
double longitude;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
struct OnPressPosition {
|
|
26
|
+
double x;
|
|
27
|
+
double y;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
struct OnPress {
|
|
31
|
+
std::string action;
|
|
32
|
+
std::string id;
|
|
33
|
+
OnPressCoordinate coordinate;
|
|
34
|
+
OnPressPosition position;
|
|
35
|
+
};
|
|
36
|
+
void onPress(OnPress value) const;
|
|
37
|
+
};
|
|
16
38
|
class RNMapsGoogleMapViewEventEmitter : public ViewEventEmitter {
|
|
17
39
|
public:
|
|
18
40
|
using ViewEventEmitter::ViewEventEmitter;
|
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
namespace facebook::react {
|
|
17
17
|
|
|
18
|
+
RNMapsCalloutProps::RNMapsCalloutProps(
|
|
19
|
+
const PropsParserContext &context,
|
|
20
|
+
const RNMapsCalloutProps &sourceProps,
|
|
21
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
22
|
+
|
|
23
|
+
alphaHitTest(convertRawProp(context, rawProps, "alphaHitTest", sourceProps.alphaHitTest, {false})),
|
|
24
|
+
tooltip(convertRawProp(context, rawProps, "tooltip", sourceProps.tooltip, {false}))
|
|
25
|
+
{}
|
|
18
26
|
RNMapsGoogleMapViewProps::RNMapsGoogleMapViewProps(
|
|
19
27
|
const PropsParserContext &context,
|
|
20
28
|
const RNMapsGoogleMapViewProps &sourceProps,
|
|
@@ -18,6 +18,17 @@
|
|
|
18
18
|
|
|
19
19
|
namespace facebook::react {
|
|
20
20
|
|
|
21
|
+
class RNMapsCalloutProps final : public ViewProps {
|
|
22
|
+
public:
|
|
23
|
+
RNMapsCalloutProps() = default;
|
|
24
|
+
RNMapsCalloutProps(const PropsParserContext& context, const RNMapsCalloutProps &sourceProps, const RawProps &rawProps);
|
|
25
|
+
|
|
26
|
+
#pragma mark - Props
|
|
27
|
+
|
|
28
|
+
bool alphaHitTest{false};
|
|
29
|
+
bool tooltip{false};
|
|
30
|
+
};
|
|
31
|
+
|
|
21
32
|
enum class RNMapsGoogleMapViewMapType { Hybrid, MutedStandard, None, Satellite, Standard, Terrain, SatelliteFlyover, HybridFlyover };
|
|
22
33
|
|
|
23
34
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsGoogleMapViewMapType &result) {
|
|
@@ -176,8 +176,12 @@ public:
|
|
|
176
176
|
template <typename T>
|
|
177
177
|
class JSI_EXPORT NativeAirMapsModuleCxxSpec : public TurboModule {
|
|
178
178
|
public:
|
|
179
|
-
jsi::Value
|
|
180
|
-
return delegate_.
|
|
179
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
180
|
+
return delegate_.create(rt, propName);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
184
|
+
return delegate_.getPropertyNames(runtime);
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
static constexpr std::string_view kModuleName = "RNMapsAirModule";
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
namespace facebook::react {
|
|
14
14
|
|
|
15
|
+
extern const char RNMapsCalloutComponentName[] = "RNMapsCallout";
|
|
15
16
|
extern const char RNMapsGoogleMapViewComponentName[] = "RNMapsGoogleMapView";
|
|
16
17
|
extern const char RNMapsGooglePolygonComponentName[] = "RNMapsGooglePolygon";
|
|
17
18
|
extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
|
|
@@ -18,6 +18,17 @@
|
|
|
18
18
|
|
|
19
19
|
namespace facebook::react {
|
|
20
20
|
|
|
21
|
+
JSI_EXPORT extern const char RNMapsCalloutComponentName[];
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* `ShadowNode` for <RNMapsCallout> component.
|
|
25
|
+
*/
|
|
26
|
+
using RNMapsCalloutShadowNode = ConcreteViewShadowNode<
|
|
27
|
+
RNMapsCalloutComponentName,
|
|
28
|
+
RNMapsCalloutProps,
|
|
29
|
+
RNMapsCalloutEventEmitter,
|
|
30
|
+
RNMapsCalloutState>;
|
|
31
|
+
|
|
21
32
|
JSI_EXPORT extern const char RNMapsGoogleMapViewComponentName[];
|
|
22
33
|
|
|
23
34
|
/*
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
|
|
15
15
|
namespace facebook::react {
|
|
16
16
|
|
|
17
|
+
class RNMapsCalloutState {
|
|
18
|
+
public:
|
|
19
|
+
RNMapsCalloutState() = default;
|
|
20
|
+
|
|
21
|
+
#ifdef ANDROID
|
|
22
|
+
RNMapsCalloutState(RNMapsCalloutState const &previousState, folly::dynamic data){};
|
|
23
|
+
folly::dynamic getDynamic() const {
|
|
24
|
+
return {};
|
|
25
|
+
};
|
|
26
|
+
#endif
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
class RNMapsGoogleMapViewState {
|
|
18
30
|
public:
|
|
19
31
|
RNMapsGoogleMapViewState() = default;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package com.rnmaps.fabric;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
8
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
9
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
10
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
11
|
+
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
12
|
+
import com.facebook.react.viewmanagers.RNMapsCalloutManagerDelegate;
|
|
13
|
+
import com.facebook.react.viewmanagers.RNMapsCalloutManagerInterface;
|
|
14
|
+
import com.rnmaps.maps.MapCallout;
|
|
15
|
+
import com.rnmaps.maps.SizeReportingShadowNode;
|
|
16
|
+
|
|
17
|
+
import java.util.HashMap;
|
|
18
|
+
import java.util.Map;
|
|
19
|
+
|
|
20
|
+
@ReactModule(name = CalloutManager.REACT_CLASS)
|
|
21
|
+
public class CalloutManager extends ViewGroupManager<MapCallout> implements RNMapsCalloutManagerInterface<MapCallout> {
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
public CalloutManager(ReactApplicationContext context){
|
|
25
|
+
super(context);
|
|
26
|
+
}
|
|
27
|
+
private final RNMapsCalloutManagerDelegate<MapCallout, CalloutManager> delegate =
|
|
28
|
+
new RNMapsCalloutManagerDelegate<>(this);
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public ViewManagerDelegate<MapCallout> getDelegate() {
|
|
32
|
+
return delegate;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public String getName() {
|
|
37
|
+
return REACT_CLASS;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
public MapCallout createViewInstance(ThemedReactContext context) {
|
|
42
|
+
return new MapCallout(context);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
public static final String REACT_CLASS = "RNMapsCallout";
|
|
47
|
+
|
|
48
|
+
@Nullable
|
|
49
|
+
@Override
|
|
50
|
+
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
51
|
+
return MapCallout.getExportedCustomBubblingEventTypeConstants();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Nullable
|
|
55
|
+
@Override
|
|
56
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
57
|
+
return new HashMap<>();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@Override
|
|
62
|
+
public void setAlphaHitTest(MapCallout view, boolean value) {
|
|
63
|
+
/// do nothing
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public void setTooltip(MapCallout view, boolean value) {
|
|
68
|
+
view.setTooltip(value);
|
|
69
|
+
}
|
|
70
|
+
@Override
|
|
71
|
+
public LayoutShadowNode createShadowNodeInstance() {
|
|
72
|
+
// we use a custom shadow node that emits the width/height of the view
|
|
73
|
+
// after layout with the updateExtraData method. Without this, we can't generate
|
|
74
|
+
// a bitmap of the appropriate width/height of the rendered view.
|
|
75
|
+
return new SizeReportingShadowNode();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Override
|
|
79
|
+
public void updateExtraData(MapCallout view, Object extraData) {
|
|
80
|
+
// This method is called from the shadow node with the width/height of the rendered
|
|
81
|
+
// marker view.
|
|
82
|
+
//noinspection unchecked
|
|
83
|
+
Map<String, Float> data = (Map<String, Float>) extraData;
|
|
84
|
+
float width = data.get("width");
|
|
85
|
+
float height = data.get("height");
|
|
86
|
+
view.width = (int) width;
|
|
87
|
+
view.height = (int) height;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -3,8 +3,6 @@ package com.rnmaps.fabric;
|
|
|
3
3
|
|
|
4
4
|
import static com.rnmaps.maps.MapManager.MY_LOCATION_PRIORITY;
|
|
5
5
|
|
|
6
|
-
import android.graphics.drawable.Drawable;
|
|
7
|
-
import android.net.Uri;
|
|
8
6
|
import android.util.Log;
|
|
9
7
|
import android.view.View;
|
|
10
8
|
|
|
@@ -28,7 +26,6 @@ import com.facebook.react.uimanager.ViewGroupManager;
|
|
|
28
26
|
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
29
27
|
import com.facebook.react.viewmanagers.RNMapsMapViewManagerInterface;
|
|
30
28
|
import com.facebook.react.viewmanagers.RNMapsMapViewManagerDelegate;
|
|
31
|
-
import com.google.android.gms.common.images.ImageManager;
|
|
32
29
|
import com.google.android.gms.maps.GoogleMap;
|
|
33
30
|
import com.google.android.gms.maps.GoogleMapOptions;
|
|
34
31
|
import com.google.android.gms.maps.MapsInitializer;
|
|
@@ -2,6 +2,7 @@ package com.rnmaps.fabric;
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import android.util.Log;
|
|
5
|
+
import android.view.View;
|
|
5
6
|
|
|
6
7
|
import androidx.annotation.NonNull;
|
|
7
8
|
import androidx.annotation.Nullable;
|
|
@@ -17,7 +18,9 @@ import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
|
17
18
|
import com.facebook.react.viewmanagers.RNMapsMarkerManagerDelegate;
|
|
18
19
|
import com.facebook.react.viewmanagers.RNMapsMarkerManagerInterface;
|
|
19
20
|
import com.google.android.gms.maps.model.LatLng;
|
|
21
|
+
import com.google.android.gms.maps.model.Marker;
|
|
20
22
|
import com.google.android.gms.maps.model.MarkerOptions;
|
|
23
|
+
import com.rnmaps.maps.MapCallout;
|
|
21
24
|
import com.rnmaps.maps.MapMarker;
|
|
22
25
|
|
|
23
26
|
import java.util.Map;
|
|
@@ -220,12 +223,13 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
|
|
|
220
223
|
|
|
221
224
|
@Override
|
|
222
225
|
public void showCallout(MapMarker view) {
|
|
226
|
+
((Marker) view.getFeature()).showInfoWindow();
|
|
223
227
|
|
|
224
228
|
}
|
|
225
229
|
|
|
226
230
|
@Override
|
|
227
231
|
public void hideCallout(MapMarker view) {
|
|
228
|
-
|
|
232
|
+
((Marker) view.getFeature()).hideInfoWindow();
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
@Override
|
|
@@ -237,4 +241,15 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
|
|
|
237
241
|
public void redraw(MapMarker view) {
|
|
238
242
|
|
|
239
243
|
}
|
|
244
|
+
@Override
|
|
245
|
+
public void addView(MapMarker parent, View child, int index) {
|
|
246
|
+
// if an <Callout /> component is a child, then it is a callout view, NOT part of the
|
|
247
|
+
// marker.
|
|
248
|
+
if (child instanceof MapCallout) {
|
|
249
|
+
parent.setCalloutView((MapCallout) child);
|
|
250
|
+
} else {
|
|
251
|
+
super.addView(parent, child, index);
|
|
252
|
+
parent.update(true);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
240
255
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
3
16
|
import com.facebook.fbreact.specs.NativeAirMapsModuleSpec;
|
|
4
17
|
import com.facebook.react.bridge.Arguments;
|
|
5
18
|
import com.facebook.react.bridge.Promise;
|
|
@@ -8,9 +21,18 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
8
21
|
import com.facebook.react.bridge.UIManager;
|
|
9
22
|
import com.facebook.react.bridge.WritableMap;
|
|
10
23
|
import com.facebook.react.uimanager.UIManagerHelper;
|
|
24
|
+
import com.google.android.gms.maps.GoogleMap;
|
|
11
25
|
import com.google.android.gms.maps.model.CameraPosition;
|
|
26
|
+
import com.rnmaps.maps.MapUIBlock;
|
|
12
27
|
import com.rnmaps.maps.MapView;
|
|
13
28
|
|
|
29
|
+
import org.json.JSONException;
|
|
30
|
+
import org.json.JSONObject;
|
|
31
|
+
|
|
32
|
+
import java.io.ByteArrayOutputStream;
|
|
33
|
+
import java.io.File;
|
|
34
|
+
import java.io.FileOutputStream;
|
|
35
|
+
|
|
14
36
|
public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
15
37
|
public NativeAirMapsModule(ReactApplicationContext reactContext) {
|
|
16
38
|
super(reactContext);
|
|
@@ -23,23 +45,23 @@ public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
|
23
45
|
|
|
24
46
|
@Override
|
|
25
47
|
public void getCamera(double tag, Promise promise) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(), (int) tag);
|
|
49
|
+
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
|
|
50
|
+
@Override
|
|
51
|
+
public void run() {
|
|
52
|
+
MapView view = (MapView) uiManager.resolveView((int) tag);
|
|
53
|
+
CameraPosition position = view.map.getCameraPosition();
|
|
54
|
+
WritableMap map = Arguments.createMap();
|
|
55
|
+
WritableMap center = Arguments.createMap();
|
|
56
|
+
center.putDouble("latitude", position.target.latitude);
|
|
57
|
+
center.putDouble("longitude", position.target.longitude);
|
|
58
|
+
map.putMap("center", center);
|
|
59
|
+
map.putDouble("heading", position.bearing);
|
|
60
|
+
map.putDouble("pitch", position.tilt);
|
|
61
|
+
map.putDouble("zoom", position.zoom);
|
|
62
|
+
promise.resolve(map);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
43
65
|
}
|
|
44
66
|
|
|
45
67
|
@Override
|
|
@@ -54,7 +76,74 @@ public class NativeAirMapsModule extends NativeAirMapsModuleSpec {
|
|
|
54
76
|
|
|
55
77
|
@Override
|
|
56
78
|
public void takeSnapshot(double tag, String config, Promise promise) {
|
|
57
|
-
|
|
79
|
+
WritableMap options = null;
|
|
80
|
+
try {
|
|
81
|
+
if (config != null) {
|
|
82
|
+
JSONObject jsonObject = new JSONObject(config);
|
|
83
|
+
options = JSONUtil.convertJsonToWritable(jsonObject);
|
|
84
|
+
WritableMap finalOptions = options;
|
|
85
|
+
|
|
86
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
87
|
+
final String format = finalOptions.hasKey("format") ? finalOptions.getString("format") : "png";
|
|
88
|
+
final Bitmap.CompressFormat compressFormat =
|
|
89
|
+
format.equals(SNAPSHOT_FORMAT_PNG) ? Bitmap.CompressFormat.PNG :
|
|
90
|
+
format.equals(SNAPSHOT_FORMAT_JPG) ? Bitmap.CompressFormat.JPEG : null;
|
|
91
|
+
final double quality = finalOptions.hasKey("quality") ? finalOptions.getDouble("quality") : 1.0;
|
|
92
|
+
final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
|
93
|
+
final Integer width =
|
|
94
|
+
finalOptions.hasKey("width") ? (int) (displayMetrics.density * finalOptions.getDouble("width")) : 0;
|
|
95
|
+
final Integer height =
|
|
96
|
+
finalOptions.hasKey("height") ? (int) (displayMetrics.density * finalOptions.getDouble("height")) : 0;
|
|
97
|
+
final String result = finalOptions.hasKey("result") ? finalOptions.getString("result") : "file";
|
|
98
|
+
|
|
99
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(), (int) tag);
|
|
100
|
+
getReactApplicationContext().runOnUiQueueThread(new Runnable() {
|
|
101
|
+
@Override
|
|
102
|
+
public void run() {
|
|
103
|
+
MapView view = (MapView) uiManager.resolveView((int) tag);
|
|
104
|
+
view.map.snapshot(snapshot -> {
|
|
105
|
+
|
|
106
|
+
// Convert image to requested width/height if necessary
|
|
107
|
+
if (snapshot == null) {
|
|
108
|
+
promise.reject("Failed to generate bitmap, snapshot = null");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if ((width != 0) && (height != 0) &&
|
|
112
|
+
(width != snapshot.getWidth() || height != snapshot.getHeight())) {
|
|
113
|
+
snapshot = Bitmap.createScaledBitmap(snapshot, width, height, true);
|
|
114
|
+
}
|
|
115
|
+
// Save the snapshot to disk
|
|
116
|
+
if (result.equals(SNAPSHOT_RESULT_FILE)) {
|
|
117
|
+
File tempFile;
|
|
118
|
+
FileOutputStream outputStream;
|
|
119
|
+
try {
|
|
120
|
+
tempFile =
|
|
121
|
+
File.createTempFile("AirMapSnapshot", "." + 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(SNAPSHOT_RESULT_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
|
+
} catch (JSONException e) {
|
|
144
|
+
promise.reject("Failed to parse config ", config);
|
|
145
|
+
|
|
146
|
+
}
|
|
58
147
|
}
|
|
59
148
|
|
|
60
149
|
@Override
|
|
@@ -8,6 +8,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
8
8
|
import com.facebook.react.module.model.ReactModuleInfo;
|
|
9
9
|
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
10
10
|
import com.facebook.react.uimanager.ViewManager;
|
|
11
|
+
import com.rnmaps.fabric.CalloutManager;
|
|
11
12
|
import com.rnmaps.fabric.MapViewManager;
|
|
12
13
|
import com.rnmaps.fabric.MarkerManager;
|
|
13
14
|
import com.rnmaps.fabric.NativeAirMapsModule;
|
|
@@ -21,12 +22,15 @@ public class MapAirModulePackage extends TurboReactPackage {
|
|
|
21
22
|
|
|
22
23
|
@Override
|
|
23
24
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
24
|
-
return List.of(new MapViewManager(reactContext), new MarkerManager(reactContext));
|
|
25
|
+
return List.of(new MapViewManager(reactContext), new MarkerManager(reactContext), new CalloutManager(reactContext));
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
@Override
|
|
29
30
|
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
31
|
+
if (CalloutManager.REACT_CLASS.equals(name)) {
|
|
32
|
+
return new CalloutManager(reactContext);
|
|
33
|
+
}
|
|
30
34
|
if (MarkerManager.REACT_CLASS.equals(name)) {
|
|
31
35
|
return new MarkerManager(reactContext);
|
|
32
36
|
}
|
|
@@ -2,7 +2,19 @@ package com.rnmaps.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
|
|
5
|
+
import com.facebook.react.common.MapBuilder;
|
|
5
6
|
import com.facebook.react.views.view.ReactViewGroup;
|
|
7
|
+
import com.rnmaps.fabric.event.OnLongPressEvent;
|
|
8
|
+
import com.rnmaps.fabric.event.OnMarkerDeselectEvent;
|
|
9
|
+
import com.rnmaps.fabric.event.OnMarkerDragEndEvent;
|
|
10
|
+
import com.rnmaps.fabric.event.OnMarkerDragEvent;
|
|
11
|
+
import com.rnmaps.fabric.event.OnMarkerDragStartEvent;
|
|
12
|
+
import com.rnmaps.fabric.event.OnMarkerPressEvent;
|
|
13
|
+
import com.rnmaps.fabric.event.OnMarkerSelectEvent;
|
|
14
|
+
import com.rnmaps.fabric.event.OnPoiClickEvent;
|
|
15
|
+
import com.rnmaps.fabric.event.OnPressEvent;
|
|
16
|
+
|
|
17
|
+
import java.util.Map;
|
|
6
18
|
|
|
7
19
|
public class MapCallout extends ReactViewGroup {
|
|
8
20
|
private boolean tooltip = false;
|
|
@@ -20,4 +32,11 @@ public class MapCallout extends ReactViewGroup {
|
|
|
20
32
|
public boolean getTooltip() {
|
|
21
33
|
return this.tooltip;
|
|
22
34
|
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
38
|
+
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
39
|
+
builder.put(OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME));
|
|
40
|
+
return builder.build();
|
|
41
|
+
}
|
|
23
42
|
}
|