react-native-maps 1.21.0-alpha.82 → 1.21.0-alpha.83
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/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java +49 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCircleManagerInterface.java +24 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java +46 -0
- package/android/generated/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java +24 -0
- 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 +11 -0
- package/android/generated/jni/react/renderer/components/RNMapsSpecs/Props.h +45 -0
- 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/MapViewManager.java +5 -0
- package/android/src/main/java/com/rnmaps/fabric/MarkerManager.java +0 -1
- package/android/src/main/java/com/rnmaps/fabric/OverlayManager.java +94 -0
- package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +5 -1
- package/android/src/main/java/com/rnmaps/maps/MapOverlay.java +175 -3
- 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 +11 -0
- package/ios/generated/RNMapsSpecs/Props.h +45 -0
- package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +4 -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/lib/MapMarker.js +6 -1
- package/lib/MapOverlay.d.ts +1 -0
- package/lib/MapOverlay.js +23 -4
- package/lib/decorateMapComponent.js +5 -0
- package/lib/specs/NativeComponentOverlay.d.ts +67 -0
- package/lib/specs/NativeComponentOverlay.js +7 -0
- package/package.json +1 -1
package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.bridge.ColorPropConverter;
|
|
15
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
16
|
+
import com.facebook.react.uimanager.BaseViewManager;
|
|
17
|
+
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
18
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
19
|
+
|
|
20
|
+
public class RNMapsCircleManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMapsCircleManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
21
|
+
public RNMapsCircleManagerDelegate(U viewManager) {
|
|
22
|
+
super(viewManager);
|
|
23
|
+
}
|
|
24
|
+
@Override
|
|
25
|
+
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
26
|
+
switch (propName) {
|
|
27
|
+
case "center":
|
|
28
|
+
mViewManager.setCenter(view, (ReadableMap) value);
|
|
29
|
+
break;
|
|
30
|
+
case "fillColor":
|
|
31
|
+
mViewManager.setFillColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
|
32
|
+
break;
|
|
33
|
+
case "radius":
|
|
34
|
+
mViewManager.setRadius(view, value == null ? Double.NaN : ((Double) value).doubleValue());
|
|
35
|
+
break;
|
|
36
|
+
case "strokeColor":
|
|
37
|
+
mViewManager.setStrokeColor(view, ColorPropConverter.getColor(value, view.getContext()));
|
|
38
|
+
break;
|
|
39
|
+
case "strokeWidth":
|
|
40
|
+
mViewManager.setStrokeWidth(view, value == null ? 0f : ((Double) value).floatValue());
|
|
41
|
+
break;
|
|
42
|
+
case "tappable":
|
|
43
|
+
mViewManager.setTappable(view, value == null ? false : (boolean) value);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
super.setProperty(view, propName, value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
package/android/generated/java/com/facebook/react/viewmanagers/RNMapsCircleManagerInterface.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
15
|
+
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
16
|
+
|
|
17
|
+
public interface RNMapsCircleManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
18
|
+
void setCenter(T view, @Nullable ReadableMap value);
|
|
19
|
+
void setFillColor(T view, @Nullable Integer value);
|
|
20
|
+
void setRadius(T view, double value);
|
|
21
|
+
void setStrokeColor(T view, @Nullable Integer value);
|
|
22
|
+
void setStrokeWidth(T view, float value);
|
|
23
|
+
void setTappable(T view, boolean value);
|
|
24
|
+
}
|
package/android/generated/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
15
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
16
|
+
import com.facebook.react.uimanager.BaseViewManager;
|
|
17
|
+
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
18
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
19
|
+
|
|
20
|
+
public class RNMapsOverlayManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMapsOverlayManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
21
|
+
public RNMapsOverlayManagerDelegate(U viewManager) {
|
|
22
|
+
super(viewManager);
|
|
23
|
+
}
|
|
24
|
+
@Override
|
|
25
|
+
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
26
|
+
switch (propName) {
|
|
27
|
+
case "bearing":
|
|
28
|
+
mViewManager.setBearing(view, value == null ? 0f : ((Double) value).floatValue());
|
|
29
|
+
break;
|
|
30
|
+
case "bounds":
|
|
31
|
+
mViewManager.setBounds(view, (ReadableArray) value);
|
|
32
|
+
break;
|
|
33
|
+
case "image":
|
|
34
|
+
mViewManager.setImage(view, (ReadableMap) value);
|
|
35
|
+
break;
|
|
36
|
+
case "opacity":
|
|
37
|
+
mViewManager.setOpacity(view, value == null ? 1f : ((Double) value).floatValue());
|
|
38
|
+
break;
|
|
39
|
+
case "tappable":
|
|
40
|
+
mViewManager.setTappable(view, value == null ? false : (boolean) value);
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
super.setProperty(view, propName, value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
package/android/generated/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
15
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
16
|
+
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
17
|
+
|
|
18
|
+
public interface RNMapsOverlayManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
19
|
+
void setBearing(T view, float value);
|
|
20
|
+
void setBounds(T view, @Nullable ReadableArray value);
|
|
21
|
+
void setImage(T view, @Nullable ReadableMap value);
|
|
22
|
+
void setOpacity(T view, float value);
|
|
23
|
+
void setTappable(T view, boolean value);
|
|
24
|
+
}
|
package/android/generated/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp
CHANGED
|
@@ -22,6 +22,7 @@ registry->add(concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDe
|
|
|
22
22
|
registry->add(concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>());
|
|
23
23
|
registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>());
|
|
24
24
|
registry->add(concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>());
|
|
25
|
+
registry->add(concreteComponentDescriptorProvider<RNMapsOverlayComponentDescriptor>());
|
|
25
26
|
registry->add(concreteComponentDescriptorProvider<RNMapsPolylineComponentDescriptor>());
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -22,6 +22,7 @@ using RNMapsGoogleMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMap
|
|
|
22
22
|
using RNMapsGooglePolygonComponentDescriptor = ConcreteComponentDescriptor<RNMapsGooglePolygonShadowNode>;
|
|
23
23
|
using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapViewShadowNode>;
|
|
24
24
|
using RNMapsMarkerComponentDescriptor = ConcreteComponentDescriptor<RNMapsMarkerShadowNode>;
|
|
25
|
+
using RNMapsOverlayComponentDescriptor = ConcreteComponentDescriptor<RNMapsOverlayShadowNode>;
|
|
25
26
|
using RNMapsPolylineComponentDescriptor = ConcreteComponentDescriptor<RNMapsPolylineShadowNode>;
|
|
26
27
|
|
|
27
28
|
void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
|
|
@@ -938,6 +938,28 @@ $payload.setProperty(runtime, "id", $event.id);
|
|
|
938
938
|
}
|
|
939
939
|
|
|
940
940
|
|
|
941
|
+
void RNMapsOverlayEventEmitter::onPress(OnPress $event) const {
|
|
942
|
+
dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
943
|
+
auto $payload = jsi::Object(runtime);
|
|
944
|
+
$payload.setProperty(runtime, "action", $event.action);
|
|
945
|
+
$payload.setProperty(runtime, "id", $event.id);
|
|
946
|
+
{
|
|
947
|
+
auto coordinate = jsi::Object(runtime);
|
|
948
|
+
coordinate.setProperty(runtime, "latitude", $event.coordinate.latitude);
|
|
949
|
+
coordinate.setProperty(runtime, "longitude", $event.coordinate.longitude);
|
|
950
|
+
$payload.setProperty(runtime, "coordinate", coordinate);
|
|
951
|
+
}
|
|
952
|
+
{
|
|
953
|
+
auto position = jsi::Object(runtime);
|
|
954
|
+
position.setProperty(runtime, "x", $event.position.x);
|
|
955
|
+
position.setProperty(runtime, "y", $event.position.y);
|
|
956
|
+
$payload.setProperty(runtime, "position", position);
|
|
957
|
+
}
|
|
958
|
+
return $payload;
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
|
|
941
963
|
void RNMapsPolylineEventEmitter::onPress(OnPress $event) const {
|
|
942
964
|
dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
943
965
|
auto $payload = jsi::Object(runtime);
|
|
@@ -806,6 +806,28 @@ class RNMapsMarkerEventEmitter : public ViewEventEmitter {
|
|
|
806
806
|
|
|
807
807
|
void onSelect(OnSelect value) const;
|
|
808
808
|
};
|
|
809
|
+
class RNMapsOverlayEventEmitter : public ViewEventEmitter {
|
|
810
|
+
public:
|
|
811
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
812
|
+
|
|
813
|
+
struct OnPressCoordinate {
|
|
814
|
+
double latitude;
|
|
815
|
+
double longitude;
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
struct OnPressPosition {
|
|
819
|
+
double x;
|
|
820
|
+
double y;
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
struct OnPress {
|
|
824
|
+
std::string action;
|
|
825
|
+
std::string id;
|
|
826
|
+
OnPressCoordinate coordinate;
|
|
827
|
+
OnPressPosition position;
|
|
828
|
+
};
|
|
829
|
+
void onPress(OnPress value) const;
|
|
830
|
+
};
|
|
809
831
|
class RNMapsPolylineEventEmitter : public ViewEventEmitter {
|
|
810
832
|
public:
|
|
811
833
|
using ViewEventEmitter::ViewEventEmitter;
|
|
@@ -163,6 +163,17 @@ RNMapsMarkerProps::RNMapsMarkerProps(
|
|
|
163
163
|
subtitleVisibility(convertRawProp(context, rawProps, "subtitleVisibility", sourceProps.subtitleVisibility, {RNMapsMarkerSubtitleVisibility::Adaptive})),
|
|
164
164
|
useLegacyPinView(convertRawProp(context, rawProps, "useLegacyPinView", sourceProps.useLegacyPinView, {false}))
|
|
165
165
|
{}
|
|
166
|
+
RNMapsOverlayProps::RNMapsOverlayProps(
|
|
167
|
+
const PropsParserContext &context,
|
|
168
|
+
const RNMapsOverlayProps &sourceProps,
|
|
169
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
170
|
+
|
|
171
|
+
bearing(convertRawProp(context, rawProps, "bearing", sourceProps.bearing, {0.0})),
|
|
172
|
+
bounds(convertRawProp(context, rawProps, "bounds", sourceProps.bounds, {})),
|
|
173
|
+
image(convertRawProp(context, rawProps, "image", sourceProps.image, {})),
|
|
174
|
+
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {1.0})),
|
|
175
|
+
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
|
|
176
|
+
{}
|
|
166
177
|
RNMapsPolylineProps::RNMapsPolylineProps(
|
|
167
178
|
const PropsParserContext &context,
|
|
168
179
|
const RNMapsPolylineProps &sourceProps,
|
|
@@ -1092,6 +1092,51 @@ class RNMapsMarkerProps final : public ViewProps {
|
|
|
1092
1092
|
bool useLegacyPinView{false};
|
|
1093
1093
|
};
|
|
1094
1094
|
|
|
1095
|
+
struct RNMapsOverlayBoundsStruct {
|
|
1096
|
+
double latitude{0.0};
|
|
1097
|
+
double longitude{0.0};
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsStruct &result) {
|
|
1101
|
+
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
1102
|
+
|
|
1103
|
+
auto tmp_latitude = map.find("latitude");
|
|
1104
|
+
if (tmp_latitude != map.end()) {
|
|
1105
|
+
fromRawValue(context, tmp_latitude->second, result.latitude);
|
|
1106
|
+
}
|
|
1107
|
+
auto tmp_longitude = map.find("longitude");
|
|
1108
|
+
if (tmp_longitude != map.end()) {
|
|
1109
|
+
fromRawValue(context, tmp_longitude->second, result.longitude);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
static inline std::string toString(const RNMapsOverlayBoundsStruct &value) {
|
|
1114
|
+
return "[Object RNMapsOverlayBoundsStruct]";
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector<RNMapsOverlayBoundsStruct> &result) {
|
|
1118
|
+
auto items = (std::vector<RawValue>)value;
|
|
1119
|
+
for (const auto &item : items) {
|
|
1120
|
+
RNMapsOverlayBoundsStruct newItem;
|
|
1121
|
+
fromRawValue(context, item, newItem);
|
|
1122
|
+
result.emplace_back(newItem);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
class RNMapsOverlayProps final : public ViewProps {
|
|
1127
|
+
public:
|
|
1128
|
+
RNMapsOverlayProps() = default;
|
|
1129
|
+
RNMapsOverlayProps(const PropsParserContext& context, const RNMapsOverlayProps &sourceProps, const RawProps &rawProps);
|
|
1130
|
+
|
|
1131
|
+
#pragma mark - Props
|
|
1132
|
+
|
|
1133
|
+
Float bearing{0.0};
|
|
1134
|
+
std::vector<RNMapsOverlayBoundsStruct> bounds{};
|
|
1135
|
+
ImageSource image{};
|
|
1136
|
+
Float opacity{1.0};
|
|
1137
|
+
bool tappable{false};
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1095
1140
|
enum class RNMapsPolylineLineCap { Butt, Round, Square };
|
|
1096
1141
|
|
|
1097
1142
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsPolylineLineCap &result) {
|
|
@@ -18,6 +18,7 @@ extern const char RNMapsGoogleMapViewComponentName[] = "RNMapsGoogleMapView";
|
|
|
18
18
|
extern const char RNMapsGooglePolygonComponentName[] = "RNMapsGooglePolygon";
|
|
19
19
|
extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
|
|
20
20
|
extern const char RNMapsMarkerComponentName[] = "RNMapsMarker";
|
|
21
|
+
extern const char RNMapsOverlayComponentName[] = "RNMapsOverlay";
|
|
21
22
|
extern const char RNMapsPolylineComponentName[] = "RNMapsPolyline";
|
|
22
23
|
|
|
23
24
|
} // namespace facebook::react
|
|
@@ -84,6 +84,17 @@ using RNMapsMarkerShadowNode = ConcreteViewShadowNode<
|
|
|
84
84
|
RNMapsMarkerEventEmitter,
|
|
85
85
|
RNMapsMarkerState>;
|
|
86
86
|
|
|
87
|
+
JSI_EXPORT extern const char RNMapsOverlayComponentName[];
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* `ShadowNode` for <RNMapsOverlay> component.
|
|
91
|
+
*/
|
|
92
|
+
using RNMapsOverlayShadowNode = ConcreteViewShadowNode<
|
|
93
|
+
RNMapsOverlayComponentName,
|
|
94
|
+
RNMapsOverlayProps,
|
|
95
|
+
RNMapsOverlayEventEmitter,
|
|
96
|
+
RNMapsOverlayState>;
|
|
97
|
+
|
|
87
98
|
JSI_EXPORT extern const char RNMapsPolylineComponentName[];
|
|
88
99
|
|
|
89
100
|
/*
|
|
@@ -86,6 +86,18 @@ public:
|
|
|
86
86
|
#endif
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
class RNMapsOverlayState {
|
|
90
|
+
public:
|
|
91
|
+
RNMapsOverlayState() = default;
|
|
92
|
+
|
|
93
|
+
#ifdef ANDROID
|
|
94
|
+
RNMapsOverlayState(RNMapsOverlayState const &previousState, folly::dynamic data){};
|
|
95
|
+
folly::dynamic getDynamic() const {
|
|
96
|
+
return {};
|
|
97
|
+
};
|
|
98
|
+
#endif
|
|
99
|
+
};
|
|
100
|
+
|
|
89
101
|
class RNMapsPolylineState {
|
|
90
102
|
public:
|
|
91
103
|
RNMapsPolylineState() = default;
|
|
@@ -34,6 +34,7 @@ import com.google.android.gms.maps.model.LatLng;
|
|
|
34
34
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
35
35
|
import com.google.android.gms.maps.model.MapColorScheme;
|
|
36
36
|
import com.rnmaps.maps.MapMarker;
|
|
37
|
+
import com.rnmaps.maps.MapOverlay;
|
|
37
38
|
import com.rnmaps.maps.MapView;
|
|
38
39
|
import com.rnmaps.maps.SizeReportingShadowNode;
|
|
39
40
|
|
|
@@ -321,6 +322,10 @@ public class MapViewManager extends ViewGroupManager<MapView> implements RNMapsM
|
|
|
321
322
|
((MapMarker) child).setImageLoadedListener((uri, drawable, b) -> {
|
|
322
323
|
parent.addFeature(child, parent.getFeatureCount());
|
|
323
324
|
});
|
|
325
|
+
// } else if (child instanceof MapOverlay && ((MapOverlay) child).isLoadingImage()){
|
|
326
|
+
// ((MapOverlay) child).setImageLoadedListener((uri, drawable, b) -> {
|
|
327
|
+
// parent.addFeature(child, parent.getFeatureCount());
|
|
328
|
+
// });
|
|
324
329
|
} else {
|
|
325
330
|
parent.addFeature(child, index);
|
|
326
331
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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.bridge.ReadableArray;
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
9
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
10
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
11
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
12
|
+
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
13
|
+
import com.facebook.react.viewmanagers.RNMapsOverlayManagerDelegate;
|
|
14
|
+
import com.facebook.react.viewmanagers.RNMapsOverlayManagerInterface;
|
|
15
|
+
import com.rnmaps.maps.MapOverlay;
|
|
16
|
+
|
|
17
|
+
import java.util.HashMap;
|
|
18
|
+
import java.util.Map;
|
|
19
|
+
|
|
20
|
+
@ReactModule(name = OverlayManager.REACT_CLASS)
|
|
21
|
+
public class OverlayManager extends ViewGroupManager<MapOverlay> implements RNMapsOverlayManagerInterface<MapOverlay> {
|
|
22
|
+
public OverlayManager(ReactApplicationContext context) {
|
|
23
|
+
super(context);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private final RNMapsOverlayManagerDelegate<MapOverlay, OverlayManager> delegate =
|
|
27
|
+
new RNMapsOverlayManagerDelegate<>(this);
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public ViewManagerDelegate<MapOverlay> getDelegate() {
|
|
31
|
+
return delegate;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public String getName() {
|
|
36
|
+
return REACT_CLASS;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public MapOverlay createViewInstance(ThemedReactContext context) {
|
|
41
|
+
return new MapOverlay(context);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
public static final String REACT_CLASS = "RNMapsOverlay";
|
|
46
|
+
|
|
47
|
+
@Nullable
|
|
48
|
+
@Override
|
|
49
|
+
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
50
|
+
return MapOverlay.getExportedCustomBubblingEventTypeConstants();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Nullable
|
|
54
|
+
@Override
|
|
55
|
+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
56
|
+
return new HashMap<>();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@Override
|
|
62
|
+
public void setZIndex(MapOverlay view, float value) {
|
|
63
|
+
view.setZIndex(value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@Override
|
|
68
|
+
public void setBearing(MapOverlay view, float value) {
|
|
69
|
+
view.setBearing(value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Override
|
|
73
|
+
public void setBounds(MapOverlay view, @Nullable ReadableArray value) {
|
|
74
|
+
view.setBounds(value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Override
|
|
78
|
+
public void setImage(MapOverlay view, @Nullable ReadableMap value) {
|
|
79
|
+
if (value != null) {
|
|
80
|
+
view.setImage(value.getString("uri"));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
|
+
public void setOpacity(MapOverlay view, float value) {
|
|
87
|
+
view.setTransparency(value);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Override
|
|
91
|
+
public void setTappable(MapOverlay view, boolean value) {
|
|
92
|
+
view.setTappable(value);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -14,6 +14,7 @@ import com.rnmaps.fabric.MapViewManager;
|
|
|
14
14
|
import com.rnmaps.fabric.MarkerManager;
|
|
15
15
|
import com.rnmaps.fabric.NativeAirMapsModule;
|
|
16
16
|
import com.facebook.fbreact.specs.NativeAirMapsModuleSpec;
|
|
17
|
+
import com.rnmaps.fabric.OverlayManager;
|
|
17
18
|
import com.rnmaps.fabric.PolygonManager;
|
|
18
19
|
import com.rnmaps.fabric.PolylineManager;
|
|
19
20
|
|
|
@@ -25,12 +26,15 @@ public class MapAirModulePackage extends TurboReactPackage {
|
|
|
25
26
|
|
|
26
27
|
@Override
|
|
27
28
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
28
|
-
return List.of(new MapViewManager(reactContext), new MarkerManager(reactContext), new CalloutManager(reactContext), new PolygonManager(reactContext), new PolylineManager(reactContext), new CircleManager(reactContext));
|
|
29
|
+
return List.of(new MapViewManager(reactContext), new MarkerManager(reactContext), new CalloutManager(reactContext), new PolygonManager(reactContext), new PolylineManager(reactContext), new CircleManager(reactContext), new OverlayManager(reactContext));
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
@Override
|
|
33
34
|
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
35
|
+
if (OverlayManager.REACT_CLASS.equals(name)) {
|
|
36
|
+
return new OverlayManager(reactContext);
|
|
37
|
+
}
|
|
34
38
|
if (CircleManager.REACT_CLASS.equals(name)) {
|
|
35
39
|
return new CircleManager(reactContext);
|
|
36
40
|
}
|
|
@@ -2,8 +2,33 @@ package com.rnmaps.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.graphics.Bitmap;
|
|
5
|
+
import android.graphics.BitmapFactory;
|
|
6
|
+
import android.graphics.Canvas;
|
|
7
|
+
import android.graphics.drawable.Animatable;
|
|
8
|
+
import android.graphics.drawable.Drawable;
|
|
9
|
+
import android.net.Uri;
|
|
5
10
|
|
|
11
|
+
import androidx.annotation.Nullable;
|
|
12
|
+
|
|
13
|
+
import com.facebook.common.references.CloseableReference;
|
|
14
|
+
import com.facebook.datasource.DataSource;
|
|
15
|
+
import com.facebook.drawee.backends.pipeline.Fresco;
|
|
16
|
+
import com.facebook.drawee.controller.BaseControllerListener;
|
|
17
|
+
import com.facebook.drawee.controller.ControllerListener;
|
|
18
|
+
import com.facebook.drawee.drawable.ScalingUtils;
|
|
19
|
+
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
|
20
|
+
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
|
21
|
+
import com.facebook.drawee.interfaces.DraweeController;
|
|
22
|
+
import com.facebook.drawee.view.DraweeHolder;
|
|
23
|
+
import com.facebook.imagepipeline.core.ImagePipeline;
|
|
24
|
+
import com.facebook.imagepipeline.image.CloseableImage;
|
|
25
|
+
import com.facebook.imagepipeline.image.CloseableStaticBitmap;
|
|
26
|
+
import com.facebook.imagepipeline.image.ImageInfo;
|
|
27
|
+
import com.facebook.imagepipeline.request.ImageRequest;
|
|
28
|
+
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
6
29
|
import com.facebook.react.bridge.ReadableArray;
|
|
30
|
+
import com.facebook.react.common.MapBuilder;
|
|
31
|
+
import com.google.android.gms.common.images.ImageManager;
|
|
7
32
|
import com.google.android.gms.maps.model.BitmapDescriptor;
|
|
8
33
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
9
34
|
import com.google.android.gms.maps.model.GroundOverlay;
|
|
@@ -11,30 +36,127 @@ import com.google.android.gms.maps.model.GroundOverlayOptions;
|
|
|
11
36
|
import com.google.android.gms.maps.model.LatLng;
|
|
12
37
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
13
38
|
import com.google.maps.android.collections.GroundOverlayManager;
|
|
39
|
+
import com.rnmaps.fabric.event.OnPressEvent;
|
|
40
|
+
|
|
41
|
+
import java.util.Map;
|
|
14
42
|
|
|
15
43
|
public class MapOverlay extends MapFeature implements ImageReadable {
|
|
16
44
|
|
|
45
|
+
|
|
46
|
+
private String imageUri;
|
|
47
|
+
private boolean loadingImage;
|
|
48
|
+
|
|
17
49
|
private GroundOverlayOptions groundOverlayOptions;
|
|
18
50
|
private GroundOverlay groundOverlay;
|
|
19
51
|
private LatLngBounds bounds;
|
|
20
52
|
private float bearing;
|
|
21
53
|
private BitmapDescriptor iconBitmapDescriptor;
|
|
54
|
+
private Bitmap iconBitmap;
|
|
22
55
|
private boolean tappable;
|
|
23
56
|
private float zIndex;
|
|
24
57
|
private float transparency;
|
|
25
58
|
|
|
59
|
+
private DataSource<CloseableReference<CloseableImage>> dataSource;
|
|
60
|
+
|
|
26
61
|
private final ImageReader mImageReader;
|
|
27
62
|
private GroundOverlayManager.Collection groundOverlayCollection;
|
|
28
63
|
|
|
64
|
+
private final DraweeHolder<?> logoHolder;
|
|
65
|
+
private ImageManager.OnImageLoadedListener imageLoadedListener;
|
|
66
|
+
|
|
67
|
+
public boolean isLoadingImage() {
|
|
68
|
+
return loadingImage;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public ImageManager.OnImageLoadedListener getImageLoadedListener() {
|
|
72
|
+
return imageLoadedListener;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public void setImageLoadedListener(ImageManager.OnImageLoadedListener imageLoadedListener) {
|
|
76
|
+
this.imageLoadedListener = imageLoadedListener;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
29
80
|
public MapOverlay(Context context) {
|
|
30
81
|
super(context);
|
|
31
82
|
this.mImageReader = new ImageReader(context, getResources(), this);
|
|
83
|
+
logoHolder = DraweeHolder.create(createDraweeHierarchy(), context);
|
|
84
|
+
logoHolder.onAttach();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private GenericDraweeHierarchy createDraweeHierarchy() {
|
|
88
|
+
return new GenericDraweeHierarchyBuilder(getResources())
|
|
89
|
+
.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
|
|
90
|
+
.setFadeDuration(0)
|
|
91
|
+
.build();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private final ControllerListener<ImageInfo> mLogoControllerListener =
|
|
95
|
+
new BaseControllerListener<ImageInfo>() {
|
|
96
|
+
@Override
|
|
97
|
+
public void onSubmit(String id, Object callerContext){
|
|
98
|
+
loadingImage = true;
|
|
99
|
+
}
|
|
100
|
+
@Override
|
|
101
|
+
public void onFinalImageSet(
|
|
102
|
+
String id,
|
|
103
|
+
@Nullable final ImageInfo imageInfo,
|
|
104
|
+
@Nullable Animatable animatable) {
|
|
105
|
+
CloseableReference<CloseableImage> imageReference = null;
|
|
106
|
+
try {
|
|
107
|
+
imageReference = dataSource.getResult();
|
|
108
|
+
if (imageReference != null) {
|
|
109
|
+
CloseableImage image = imageReference.get();
|
|
110
|
+
if (image instanceof CloseableStaticBitmap) {
|
|
111
|
+
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
|
|
112
|
+
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
|
|
113
|
+
if (bitmap != null) {
|
|
114
|
+
bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
|
115
|
+
iconBitmap = bitmap;
|
|
116
|
+
iconBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} finally {
|
|
121
|
+
dataSource.close();
|
|
122
|
+
if (imageReference != null) {
|
|
123
|
+
CloseableReference.closeSafely(imageReference);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
loadingImage = false;
|
|
128
|
+
if (imageLoadedListener != null){
|
|
129
|
+
imageLoadedListener.onImageLoaded(null, null, false);
|
|
130
|
+
// fire and forget
|
|
131
|
+
imageLoadedListener = null;
|
|
132
|
+
}
|
|
133
|
+
update();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// seems like apple users north west, south east
|
|
138
|
+
// google uses north east, south west
|
|
139
|
+
private static LatLngBounds fixBoundsIfNecessary(ReadableArray bounds){
|
|
140
|
+
double lat1 = bounds.getArray(0).getDouble(0);
|
|
141
|
+
double lon1 = bounds.getArray(0).getDouble(1);
|
|
142
|
+
double lat2 = bounds.getArray(1).getDouble(0);
|
|
143
|
+
double lon2 = bounds.getArray(1).getDouble(1);
|
|
144
|
+
|
|
145
|
+
// Ensure lat1/lon1 is the SW corner and lat2/lon2 is the NE corner
|
|
146
|
+
double southLat = Math.min(lat1, lat2);
|
|
147
|
+
double northLat = Math.max(lat1, lat2);
|
|
148
|
+
double westLon = Math.min(lon1, lon2);
|
|
149
|
+
double eastLon = Math.max(lon1, lon2);
|
|
150
|
+
|
|
151
|
+
// Create corrected LatLngs
|
|
152
|
+
LatLng sw = new LatLng(southLat, westLon);
|
|
153
|
+
LatLng ne = new LatLng(northLat, eastLon);
|
|
154
|
+
return new LatLngBounds(sw, ne);
|
|
32
155
|
}
|
|
33
156
|
|
|
34
157
|
public void setBounds(ReadableArray bounds) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.bounds = new LatLngBounds(sw, ne);
|
|
158
|
+
|
|
159
|
+
this.bounds = fixBoundsIfNecessary(bounds);
|
|
38
160
|
if (this.groundOverlay != null) {
|
|
39
161
|
this.groundOverlay.setPositionFromBounds(this.bounds);
|
|
40
162
|
}
|
|
@@ -63,6 +185,51 @@ public class MapOverlay extends MapFeature implements ImageReadable {
|
|
|
63
185
|
|
|
64
186
|
public void setImage(String uri) {
|
|
65
187
|
this.mImageReader.setImage(uri);
|
|
188
|
+
boolean shouldLoadImage = true;
|
|
189
|
+
|
|
190
|
+
this.imageUri = uri;
|
|
191
|
+
if (!shouldLoadImage) {return;}
|
|
192
|
+
|
|
193
|
+
if (uri == null) {
|
|
194
|
+
iconBitmapDescriptor = null;
|
|
195
|
+
} else if (uri.startsWith("http://") || uri.startsWith("https://") ||
|
|
196
|
+
uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
|
|
197
|
+
ImageRequest imageRequest = ImageRequestBuilder
|
|
198
|
+
.newBuilderWithSource(Uri.parse(uri))
|
|
199
|
+
.build();
|
|
200
|
+
|
|
201
|
+
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
|
202
|
+
dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
|
|
203
|
+
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
|
204
|
+
.setImageRequest(imageRequest)
|
|
205
|
+
.setControllerListener(mLogoControllerListener)
|
|
206
|
+
.setOldController(logoHolder.getController())
|
|
207
|
+
.build();
|
|
208
|
+
logoHolder.setController(controller);
|
|
209
|
+
} else {
|
|
210
|
+
iconBitmapDescriptor = getBitmapDescriptorByName(uri);
|
|
211
|
+
int drawableId = getDrawableResourceByName(uri);
|
|
212
|
+
iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
213
|
+
if (iconBitmap == null) { // VectorDrawable or similar
|
|
214
|
+
Drawable drawable = getResources().getDrawable(drawableId);
|
|
215
|
+
iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
216
|
+
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
217
|
+
Canvas canvas = new Canvas(iconBitmap);
|
|
218
|
+
drawable.draw(canvas);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private BitmapDescriptor getBitmapDescriptorByName(String name) {
|
|
225
|
+
return BitmapDescriptorFactory.fromResource(getDrawableResourceByName(name));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private int getDrawableResourceByName(String name) {
|
|
229
|
+
return getResources().getIdentifier(
|
|
230
|
+
name,
|
|
231
|
+
"drawable",
|
|
232
|
+
getContext().getPackageName());
|
|
66
233
|
}
|
|
67
234
|
|
|
68
235
|
public void setTappable(boolean tapabble) {
|
|
@@ -72,6 +239,11 @@ public class MapOverlay extends MapFeature implements ImageReadable {
|
|
|
72
239
|
}
|
|
73
240
|
}
|
|
74
241
|
|
|
242
|
+
public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
|
243
|
+
MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
|
|
244
|
+
builder.put(OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME));
|
|
245
|
+
return builder.build();
|
|
246
|
+
}
|
|
75
247
|
|
|
76
248
|
public GroundOverlayOptions getGroundOverlayOptions() {
|
|
77
249
|
if (this.groundOverlayOptions == null) {
|
|
@@ -22,6 +22,7 @@ registry->add(concreteComponentDescriptorProvider<RNMapsGoogleMapViewComponentDe
|
|
|
22
22
|
registry->add(concreteComponentDescriptorProvider<RNMapsGooglePolygonComponentDescriptor>());
|
|
23
23
|
registry->add(concreteComponentDescriptorProvider<RNMapsMapViewComponentDescriptor>());
|
|
24
24
|
registry->add(concreteComponentDescriptorProvider<RNMapsMarkerComponentDescriptor>());
|
|
25
|
+
registry->add(concreteComponentDescriptorProvider<RNMapsOverlayComponentDescriptor>());
|
|
25
26
|
registry->add(concreteComponentDescriptorProvider<RNMapsPolylineComponentDescriptor>());
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -22,6 +22,7 @@ using RNMapsGoogleMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMap
|
|
|
22
22
|
using RNMapsGooglePolygonComponentDescriptor = ConcreteComponentDescriptor<RNMapsGooglePolygonShadowNode>;
|
|
23
23
|
using RNMapsMapViewComponentDescriptor = ConcreteComponentDescriptor<RNMapsMapViewShadowNode>;
|
|
24
24
|
using RNMapsMarkerComponentDescriptor = ConcreteComponentDescriptor<RNMapsMarkerShadowNode>;
|
|
25
|
+
using RNMapsOverlayComponentDescriptor = ConcreteComponentDescriptor<RNMapsOverlayShadowNode>;
|
|
25
26
|
using RNMapsPolylineComponentDescriptor = ConcreteComponentDescriptor<RNMapsPolylineShadowNode>;
|
|
26
27
|
|
|
27
28
|
void RNMapsSpecs_registerComponentDescriptorsFromCodegen(
|
|
@@ -938,6 +938,28 @@ $payload.setProperty(runtime, "id", $event.id);
|
|
|
938
938
|
}
|
|
939
939
|
|
|
940
940
|
|
|
941
|
+
void RNMapsOverlayEventEmitter::onPress(OnPress $event) const {
|
|
942
|
+
dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
943
|
+
auto $payload = jsi::Object(runtime);
|
|
944
|
+
$payload.setProperty(runtime, "action", $event.action);
|
|
945
|
+
$payload.setProperty(runtime, "id", $event.id);
|
|
946
|
+
{
|
|
947
|
+
auto coordinate = jsi::Object(runtime);
|
|
948
|
+
coordinate.setProperty(runtime, "latitude", $event.coordinate.latitude);
|
|
949
|
+
coordinate.setProperty(runtime, "longitude", $event.coordinate.longitude);
|
|
950
|
+
$payload.setProperty(runtime, "coordinate", coordinate);
|
|
951
|
+
}
|
|
952
|
+
{
|
|
953
|
+
auto position = jsi::Object(runtime);
|
|
954
|
+
position.setProperty(runtime, "x", $event.position.x);
|
|
955
|
+
position.setProperty(runtime, "y", $event.position.y);
|
|
956
|
+
$payload.setProperty(runtime, "position", position);
|
|
957
|
+
}
|
|
958
|
+
return $payload;
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
|
|
941
963
|
void RNMapsPolylineEventEmitter::onPress(OnPress $event) const {
|
|
942
964
|
dispatchEvent("press", [$event=std::move($event)](jsi::Runtime &runtime) {
|
|
943
965
|
auto $payload = jsi::Object(runtime);
|
|
@@ -806,6 +806,28 @@ class RNMapsMarkerEventEmitter : public ViewEventEmitter {
|
|
|
806
806
|
|
|
807
807
|
void onSelect(OnSelect value) const;
|
|
808
808
|
};
|
|
809
|
+
class RNMapsOverlayEventEmitter : public ViewEventEmitter {
|
|
810
|
+
public:
|
|
811
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
812
|
+
|
|
813
|
+
struct OnPressCoordinate {
|
|
814
|
+
double latitude;
|
|
815
|
+
double longitude;
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
struct OnPressPosition {
|
|
819
|
+
double x;
|
|
820
|
+
double y;
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
struct OnPress {
|
|
824
|
+
std::string action;
|
|
825
|
+
std::string id;
|
|
826
|
+
OnPressCoordinate coordinate;
|
|
827
|
+
OnPressPosition position;
|
|
828
|
+
};
|
|
829
|
+
void onPress(OnPress value) const;
|
|
830
|
+
};
|
|
809
831
|
class RNMapsPolylineEventEmitter : public ViewEventEmitter {
|
|
810
832
|
public:
|
|
811
833
|
using ViewEventEmitter::ViewEventEmitter;
|
|
@@ -163,6 +163,17 @@ RNMapsMarkerProps::RNMapsMarkerProps(
|
|
|
163
163
|
subtitleVisibility(convertRawProp(context, rawProps, "subtitleVisibility", sourceProps.subtitleVisibility, {RNMapsMarkerSubtitleVisibility::Adaptive})),
|
|
164
164
|
useLegacyPinView(convertRawProp(context, rawProps, "useLegacyPinView", sourceProps.useLegacyPinView, {false}))
|
|
165
165
|
{}
|
|
166
|
+
RNMapsOverlayProps::RNMapsOverlayProps(
|
|
167
|
+
const PropsParserContext &context,
|
|
168
|
+
const RNMapsOverlayProps &sourceProps,
|
|
169
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
170
|
+
|
|
171
|
+
bearing(convertRawProp(context, rawProps, "bearing", sourceProps.bearing, {0.0})),
|
|
172
|
+
bounds(convertRawProp(context, rawProps, "bounds", sourceProps.bounds, {})),
|
|
173
|
+
image(convertRawProp(context, rawProps, "image", sourceProps.image, {})),
|
|
174
|
+
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {1.0})),
|
|
175
|
+
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false}))
|
|
176
|
+
{}
|
|
166
177
|
RNMapsPolylineProps::RNMapsPolylineProps(
|
|
167
178
|
const PropsParserContext &context,
|
|
168
179
|
const RNMapsPolylineProps &sourceProps,
|
|
@@ -1092,6 +1092,51 @@ class RNMapsMarkerProps final : public ViewProps {
|
|
|
1092
1092
|
bool useLegacyPinView{false};
|
|
1093
1093
|
};
|
|
1094
1094
|
|
|
1095
|
+
struct RNMapsOverlayBoundsStruct {
|
|
1096
|
+
double latitude{0.0};
|
|
1097
|
+
double longitude{0.0};
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsStruct &result) {
|
|
1101
|
+
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
1102
|
+
|
|
1103
|
+
auto tmp_latitude = map.find("latitude");
|
|
1104
|
+
if (tmp_latitude != map.end()) {
|
|
1105
|
+
fromRawValue(context, tmp_latitude->second, result.latitude);
|
|
1106
|
+
}
|
|
1107
|
+
auto tmp_longitude = map.find("longitude");
|
|
1108
|
+
if (tmp_longitude != map.end()) {
|
|
1109
|
+
fromRawValue(context, tmp_longitude->second, result.longitude);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
static inline std::string toString(const RNMapsOverlayBoundsStruct &value) {
|
|
1114
|
+
return "[Object RNMapsOverlayBoundsStruct]";
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, std::vector<RNMapsOverlayBoundsStruct> &result) {
|
|
1118
|
+
auto items = (std::vector<RawValue>)value;
|
|
1119
|
+
for (const auto &item : items) {
|
|
1120
|
+
RNMapsOverlayBoundsStruct newItem;
|
|
1121
|
+
fromRawValue(context, item, newItem);
|
|
1122
|
+
result.emplace_back(newItem);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
class RNMapsOverlayProps final : public ViewProps {
|
|
1127
|
+
public:
|
|
1128
|
+
RNMapsOverlayProps() = default;
|
|
1129
|
+
RNMapsOverlayProps(const PropsParserContext& context, const RNMapsOverlayProps &sourceProps, const RawProps &rawProps);
|
|
1130
|
+
|
|
1131
|
+
#pragma mark - Props
|
|
1132
|
+
|
|
1133
|
+
Float bearing{0.0};
|
|
1134
|
+
std::vector<RNMapsOverlayBoundsStruct> bounds{};
|
|
1135
|
+
ImageSource image{};
|
|
1136
|
+
Float opacity{1.0};
|
|
1137
|
+
bool tappable{false};
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1095
1140
|
enum class RNMapsPolylineLineCap { Butt, Round, Square };
|
|
1096
1141
|
|
|
1097
1142
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsPolylineLineCap &result) {
|
|
@@ -18,6 +18,7 @@ extern const char RNMapsGoogleMapViewComponentName[] = "RNMapsGoogleMapView";
|
|
|
18
18
|
extern const char RNMapsGooglePolygonComponentName[] = "RNMapsGooglePolygon";
|
|
19
19
|
extern const char RNMapsMapViewComponentName[] = "RNMapsMapView";
|
|
20
20
|
extern const char RNMapsMarkerComponentName[] = "RNMapsMarker";
|
|
21
|
+
extern const char RNMapsOverlayComponentName[] = "RNMapsOverlay";
|
|
21
22
|
extern const char RNMapsPolylineComponentName[] = "RNMapsPolyline";
|
|
22
23
|
|
|
23
24
|
} // namespace facebook::react
|
|
@@ -84,6 +84,17 @@ using RNMapsMarkerShadowNode = ConcreteViewShadowNode<
|
|
|
84
84
|
RNMapsMarkerEventEmitter,
|
|
85
85
|
RNMapsMarkerState>;
|
|
86
86
|
|
|
87
|
+
JSI_EXPORT extern const char RNMapsOverlayComponentName[];
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* `ShadowNode` for <RNMapsOverlay> component.
|
|
91
|
+
*/
|
|
92
|
+
using RNMapsOverlayShadowNode = ConcreteViewShadowNode<
|
|
93
|
+
RNMapsOverlayComponentName,
|
|
94
|
+
RNMapsOverlayProps,
|
|
95
|
+
RNMapsOverlayEventEmitter,
|
|
96
|
+
RNMapsOverlayState>;
|
|
97
|
+
|
|
87
98
|
JSI_EXPORT extern const char RNMapsPolylineComponentName[];
|
|
88
99
|
|
|
89
100
|
/*
|
|
@@ -86,6 +86,18 @@ public:
|
|
|
86
86
|
#endif
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
class RNMapsOverlayState {
|
|
90
|
+
public:
|
|
91
|
+
RNMapsOverlayState() = default;
|
|
92
|
+
|
|
93
|
+
#ifdef ANDROID
|
|
94
|
+
RNMapsOverlayState(RNMapsOverlayState const &previousState, folly::dynamic data){};
|
|
95
|
+
folly::dynamic getDynamic() const {
|
|
96
|
+
return {};
|
|
97
|
+
};
|
|
98
|
+
#endif
|
|
99
|
+
};
|
|
100
|
+
|
|
89
101
|
class RNMapsPolylineState {
|
|
90
102
|
public:
|
|
91
103
|
RNMapsPolylineState() = default;
|
package/lib/MapMarker.js
CHANGED
|
@@ -127,7 +127,12 @@ class MapMarker extends React.Component {
|
|
|
127
127
|
let image;
|
|
128
128
|
if (this.props.image) {
|
|
129
129
|
if (this.fabricMarker) {
|
|
130
|
-
|
|
130
|
+
if (typeof this.props.image === 'string') {
|
|
131
|
+
image = { uri: this.props.image };
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
image = this.props.image;
|
|
135
|
+
}
|
|
131
136
|
}
|
|
132
137
|
else {
|
|
133
138
|
const resolvedImage = react_native_1.Image.resolveAssetSource(this.props.image) || {};
|
package/lib/MapOverlay.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare class MapOverlay extends React.Component<MapOverlayProps> {
|
|
|
60
60
|
getMapManagerCommand: (name: string) => MapManagerCommand;
|
|
61
61
|
getUIManagerCommand: (name: string) => UIManagerCommand;
|
|
62
62
|
static Animated: Animated.AnimatedComponent<typeof MapOverlay>;
|
|
63
|
+
private fabricOverlay?;
|
|
63
64
|
render(): React.JSX.Element;
|
|
64
65
|
}
|
|
65
66
|
type Coordinate = [number, number];
|
package/lib/MapOverlay.js
CHANGED
|
@@ -32,13 +32,32 @@ class MapOverlay extends React.Component {
|
|
|
32
32
|
getMapManagerCommand;
|
|
33
33
|
getUIManagerCommand;
|
|
34
34
|
static Animated;
|
|
35
|
+
fabricOverlay = undefined;
|
|
35
36
|
render() {
|
|
36
37
|
const { opacity = 1.0 } = this.props;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (this.fabricOverlay === undefined) {
|
|
39
|
+
this.fabricOverlay = react_native_1.Platform.OS === 'android';
|
|
40
|
+
}
|
|
40
41
|
const AIRMapOverlay = this.getNativeComponent();
|
|
41
|
-
|
|
42
|
+
let image;
|
|
43
|
+
if (this.props.image) {
|
|
44
|
+
if (this.fabricOverlay) {
|
|
45
|
+
if (typeof this.props.image === 'string') {
|
|
46
|
+
image = { uri: this.props.image };
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
image = this.props.image;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const resolvedImage = react_native_1.Image.resolveAssetSource(this.props.image) || {};
|
|
54
|
+
image = resolvedImage.uri || this.props.image;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
console.log('MapOverlay image: ' + image);
|
|
58
|
+
return (<AIRMapOverlay {...this.props} opacity={opacity}
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
image={image} style={[styles.overlay, this.props.style]}/>);
|
|
42
61
|
}
|
|
43
62
|
}
|
|
44
63
|
exports.MapOverlay = MapOverlay;
|
|
@@ -12,6 +12,7 @@ const NativeComponentMarker_1 = __importDefault(require("./specs/NativeComponent
|
|
|
12
12
|
const NativeComponentCallout_1 = __importDefault(require("./specs/NativeComponentCallout"));
|
|
13
13
|
const NativeComponentPolyline_1 = __importDefault(require("./specs/NativeComponentPolyline"));
|
|
14
14
|
const NativeComponentCircle_1 = __importDefault(require("./specs/NativeComponentCircle"));
|
|
15
|
+
const NativeComponentOverlay_1 = __importDefault(require("./specs/NativeComponentOverlay"));
|
|
15
16
|
exports.SUPPORTED = 'SUPPORTED';
|
|
16
17
|
exports.USES_DEFAULT_IMPLEMENTATION = 'USES_DEFAULT_IMPLEMENTATION';
|
|
17
18
|
exports.NOT_SUPPORTED = 'NOT_SUPPORTED';
|
|
@@ -68,6 +69,10 @@ function decorateMapComponent(Component, componentName, providers) {
|
|
|
68
69
|
// @ts-ignore
|
|
69
70
|
return NativeComponentCircle_1.default;
|
|
70
71
|
}
|
|
72
|
+
else if (componentName === 'Overlay') {
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
return NativeComponentOverlay_1.default;
|
|
75
|
+
}
|
|
71
76
|
}
|
|
72
77
|
const key = provider || 'default';
|
|
73
78
|
if (components[key]) {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Double, Float, BubblingEventHandler, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
2
|
+
import type { ViewProps, HostComponent, ImageSourcePropType as ImageSource } from 'react-native';
|
|
3
|
+
export type LatLng = Readonly<{
|
|
4
|
+
latitude: Double;
|
|
5
|
+
longitude: Double;
|
|
6
|
+
}>;
|
|
7
|
+
export type OverlayPressEventHandler = BubblingEventHandler<Readonly<{
|
|
8
|
+
action?: string;
|
|
9
|
+
id: string;
|
|
10
|
+
coordinate: {
|
|
11
|
+
latitude: Double;
|
|
12
|
+
longitude: Double;
|
|
13
|
+
};
|
|
14
|
+
position?: {
|
|
15
|
+
x: Double;
|
|
16
|
+
y: Double;
|
|
17
|
+
};
|
|
18
|
+
}>>;
|
|
19
|
+
export interface OverlayFabricNativeProps extends ViewProps {
|
|
20
|
+
/**
|
|
21
|
+
* The bearing in degrees clockwise from north. Values outside the range [0, 360) will be normalized.
|
|
22
|
+
*
|
|
23
|
+
* @default 0
|
|
24
|
+
* @platform iOS: Google Maps only
|
|
25
|
+
* @platform Android: Supported
|
|
26
|
+
*/
|
|
27
|
+
bearing?: Float;
|
|
28
|
+
/**
|
|
29
|
+
* The coordinates for the image (left-top corner, right-bottom corner). ie.```[[lat, long], [lat, long]]```
|
|
30
|
+
*
|
|
31
|
+
* @platform iOS: Supported
|
|
32
|
+
* @platform Android: Supported
|
|
33
|
+
*/
|
|
34
|
+
bounds: ReadonlyArray<LatLng>;
|
|
35
|
+
/**
|
|
36
|
+
* A custom image to be used as the overlay.
|
|
37
|
+
* Only required local image resources and uri (as for images located in the net) are allowed to be used.
|
|
38
|
+
*
|
|
39
|
+
* @platform iOS: Supported
|
|
40
|
+
* @platform Android: Supported
|
|
41
|
+
*/
|
|
42
|
+
image?: ImageSource | null;
|
|
43
|
+
/**
|
|
44
|
+
* Callback that is called when user taps on the map.
|
|
45
|
+
*
|
|
46
|
+
* @platform iOS: Supported
|
|
47
|
+
* @platform Android: Supported
|
|
48
|
+
*/
|
|
49
|
+
onPress?: OverlayPressEventHandler;
|
|
50
|
+
/**
|
|
51
|
+
* The overlay's opacity between 0.0 and 1.0.
|
|
52
|
+
*
|
|
53
|
+
* @default 1.0
|
|
54
|
+
* @platform iOS: Supported
|
|
55
|
+
* @platform Android: Supported
|
|
56
|
+
*/
|
|
57
|
+
opacity?: WithDefault<Float, 1.0>;
|
|
58
|
+
/**
|
|
59
|
+
* Boolean to allow a polygon to be tappable and use the onPress function.
|
|
60
|
+
*
|
|
61
|
+
* @platform iOS: Google Maps only
|
|
62
|
+
* @platform Android: Supported
|
|
63
|
+
*/
|
|
64
|
+
tappable?: boolean;
|
|
65
|
+
}
|
|
66
|
+
declare const _default: HostComponent<OverlayFabricNativeProps>;
|
|
67
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const codegenNativeComponent_1 = __importDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
|
|
7
|
+
exports.default = (0, codegenNativeComponent_1.default)('RNMapsOverlay', {});
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
|
|
7
7
|
"homepage": "https://github.com/react-native-maps/react-native-maps#readme",
|
|
8
|
-
"version": "1.21.0-alpha.
|
|
8
|
+
"version": "1.21.0-alpha.83",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|