react-native-maps 1.21.0-alpha.140 → 1.21.0-alpha.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java +1 -2
- package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java +1 -2
- package/android/src/main/java/com/rnmaps/fabric/OverlayManager.java +9 -3
- package/android/src/main/java/com/rnmaps/maps/MapOverlay.java +2 -22
- package/android/src/main/java/com/rnmaps/maps/MapOverlayManager.java +23 -1
- package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +45 -11
- package/ios/AirMaps/AIRMapOverlay.m +2 -2
- package/package.json +1 -1
- package/src/MapOverlay.tsx +26 -4
- package/src/specs/NativeComponentOverlay.ts +10 -1
package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java
CHANGED
|
@@ -11,7 +11,6 @@ package com.facebook.react.viewmanagers;
|
|
|
11
11
|
|
|
12
12
|
import android.view.View;
|
|
13
13
|
import androidx.annotation.Nullable;
|
|
14
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
15
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
16
15
|
import com.facebook.react.uimanager.BaseViewManager;
|
|
17
16
|
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
@@ -28,7 +27,7 @@ public class RNMapsOverlayManagerDelegate<T extends View, U extends BaseViewMana
|
|
|
28
27
|
mViewManager.setBearing(view, value == null ? 0f : ((Double) value).floatValue());
|
|
29
28
|
break;
|
|
30
29
|
case "bounds":
|
|
31
|
-
mViewManager.setBounds(view, (
|
|
30
|
+
mViewManager.setBounds(view, (ReadableMap) value);
|
|
32
31
|
break;
|
|
33
32
|
case "image":
|
|
34
33
|
mViewManager.setImage(view, (ReadableMap) value);
|
package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java
CHANGED
|
@@ -11,12 +11,11 @@ package com.facebook.react.viewmanagers;
|
|
|
11
11
|
|
|
12
12
|
import android.view.View;
|
|
13
13
|
import androidx.annotation.Nullable;
|
|
14
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
15
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
16
15
|
|
|
17
16
|
public interface RNMapsOverlayManagerInterface<T extends View> {
|
|
18
17
|
void setBearing(T view, float value);
|
|
19
|
-
void setBounds(T view, @Nullable
|
|
18
|
+
void setBounds(T view, @Nullable ReadableMap value);
|
|
20
19
|
void setImage(T view, @Nullable ReadableMap value);
|
|
21
20
|
void setOpacity(T view, float value);
|
|
22
21
|
void setTappable(T view, boolean value);
|
|
@@ -4,7 +4,6 @@ package com.rnmaps.fabric;
|
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
5
|
|
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
8
7
|
import com.facebook.react.bridge.ReadableMap;
|
|
9
8
|
import com.facebook.react.module.annotations.ReactModule;
|
|
10
9
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
@@ -12,6 +11,8 @@ import com.facebook.react.uimanager.ViewGroupManager;
|
|
|
12
11
|
import com.facebook.react.uimanager.ViewManagerDelegate;
|
|
13
12
|
import com.facebook.react.viewmanagers.RNMapsOverlayManagerDelegate;
|
|
14
13
|
import com.facebook.react.viewmanagers.RNMapsOverlayManagerInterface;
|
|
14
|
+
import com.google.android.gms.maps.model.LatLng;
|
|
15
|
+
import com.google.android.gms.maps.model.LatLngBounds;
|
|
15
16
|
import com.rnmaps.maps.MapOverlay;
|
|
16
17
|
|
|
17
18
|
import java.util.HashMap;
|
|
@@ -70,8 +71,13 @@ public class OverlayManager extends ViewGroupManager<MapOverlay> implements RNMa
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
@Override
|
|
73
|
-
public void setBounds(MapOverlay view, @Nullable
|
|
74
|
-
|
|
74
|
+
public void setBounds(MapOverlay view, @Nullable ReadableMap value) {
|
|
75
|
+
LatLng sw = new LatLng(value.getMap("southWest").getDouble("latitude"),
|
|
76
|
+
value.getMap("southWest").getDouble("longitude"));
|
|
77
|
+
LatLng ne = new LatLng(value.getMap("northEast").getDouble("latitude"),
|
|
78
|
+
value.getMap("northEast").getDouble("longitude"));
|
|
79
|
+
LatLngBounds bounds = new LatLngBounds(sw, ne);
|
|
80
|
+
view.setBounds(bounds);
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
@Override
|
|
@@ -68,29 +68,9 @@ public class MapOverlay extends MapFeature {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
// seems like apple users north west, south east
|
|
72
|
-
// google uses north east, south west
|
|
73
|
-
private static LatLngBounds fixBoundsIfNecessary(ReadableArray bounds) {
|
|
74
|
-
double lat1 = bounds.getArray(0).getDouble(0);
|
|
75
|
-
double lon1 = bounds.getArray(0).getDouble(1);
|
|
76
|
-
double lat2 = bounds.getArray(1).getDouble(0);
|
|
77
|
-
double lon2 = bounds.getArray(1).getDouble(1);
|
|
78
|
-
|
|
79
|
-
// Ensure lat1/lon1 is the SW corner and lat2/lon2 is the NE corner
|
|
80
|
-
double southLat = Math.min(lat1, lat2);
|
|
81
|
-
double northLat = Math.max(lat1, lat2);
|
|
82
|
-
double westLon = Math.min(lon1, lon2);
|
|
83
|
-
double eastLon = Math.max(lon1, lon2);
|
|
84
|
-
|
|
85
|
-
// Create corrected LatLngs
|
|
86
|
-
LatLng sw = new LatLng(southLat, westLon);
|
|
87
|
-
LatLng ne = new LatLng(northLat, eastLon);
|
|
88
|
-
return new LatLngBounds(sw, ne);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public void setBounds(ReadableArray bounds) {
|
|
92
71
|
|
|
93
|
-
|
|
72
|
+
public void setBounds(LatLngBounds bounds) {
|
|
73
|
+
this.bounds = bounds;
|
|
94
74
|
if (this.groundOverlay != null) {
|
|
95
75
|
this.groundOverlay.setPositionFromBounds(this.bounds);
|
|
96
76
|
}
|
|
@@ -12,6 +12,8 @@ import com.facebook.react.common.MapBuilder;
|
|
|
12
12
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
13
13
|
import com.facebook.react.uimanager.ViewGroupManager;
|
|
14
14
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
15
|
+
import com.google.android.gms.maps.model.LatLng;
|
|
16
|
+
import com.google.android.gms.maps.model.LatLngBounds;
|
|
15
17
|
|
|
16
18
|
import java.util.Map;
|
|
17
19
|
|
|
@@ -37,7 +39,27 @@ public class MapOverlayManager extends ViewGroupManager<MapOverlay> {
|
|
|
37
39
|
|
|
38
40
|
@ReactProp(name = "bounds")
|
|
39
41
|
public void setBounds(MapOverlay view, ReadableArray bounds) {
|
|
40
|
-
view.setBounds(bounds);
|
|
42
|
+
view.setBounds(fixBoundsIfNecessary(bounds));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// seems like apple users north west, south east
|
|
46
|
+
// google uses north east, south west
|
|
47
|
+
private static LatLngBounds fixBoundsIfNecessary(ReadableArray bounds) {
|
|
48
|
+
double lat1 = bounds.getArray(0).getDouble(0);
|
|
49
|
+
double lon1 = bounds.getArray(0).getDouble(1);
|
|
50
|
+
double lat2 = bounds.getArray(1).getDouble(0);
|
|
51
|
+
double lon2 = bounds.getArray(1).getDouble(1);
|
|
52
|
+
|
|
53
|
+
// Ensure lat1/lon1 is the SW corner and lat2/lon2 is the NE corner
|
|
54
|
+
double southLat = Math.min(lat1, lat2);
|
|
55
|
+
double northLat = Math.max(lat1, lat2);
|
|
56
|
+
double westLon = Math.min(lon1, lon2);
|
|
57
|
+
double eastLon = Math.max(lon1, lon2);
|
|
58
|
+
|
|
59
|
+
// Create corrected LatLngs
|
|
60
|
+
LatLng sw = new LatLng(southLat, westLon);
|
|
61
|
+
LatLng ne = new LatLng(northLat, eastLon);
|
|
62
|
+
return new LatLngBounds(sw, ne);
|
|
41
63
|
}
|
|
42
64
|
|
|
43
65
|
@ReactProp(name = "bearing")
|
|
@@ -1094,12 +1094,12 @@ class RNMapsMarkerProps final : public ViewProps {
|
|
|
1094
1094
|
bool useLegacyPinView{false};
|
|
1095
1095
|
};
|
|
1096
1096
|
|
|
1097
|
-
struct
|
|
1097
|
+
struct RNMapsOverlayBoundsNorthEastStruct {
|
|
1098
1098
|
double latitude{0.0};
|
|
1099
1099
|
double longitude{0.0};
|
|
1100
1100
|
};
|
|
1101
1101
|
|
|
1102
|
-
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value,
|
|
1102
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsNorthEastStruct &result) {
|
|
1103
1103
|
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
1104
1104
|
|
|
1105
1105
|
auto tmp_latitude = map.find("latitude");
|
|
@@ -1112,19 +1112,53 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
|
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
1114
|
|
|
1115
|
-
static inline std::string toString(const
|
|
1116
|
-
return "[Object
|
|
1115
|
+
static inline std::string toString(const RNMapsOverlayBoundsNorthEastStruct &value) {
|
|
1116
|
+
return "[Object RNMapsOverlayBoundsNorthEastStruct]";
|
|
1117
1117
|
}
|
|
1118
1118
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1119
|
+
struct RNMapsOverlayBoundsSouthWestStruct {
|
|
1120
|
+
double latitude{0.0};
|
|
1121
|
+
double longitude{0.0};
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsSouthWestStruct &result) {
|
|
1125
|
+
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
1126
|
+
|
|
1127
|
+
auto tmp_latitude = map.find("latitude");
|
|
1128
|
+
if (tmp_latitude != map.end()) {
|
|
1129
|
+
fromRawValue(context, tmp_latitude->second, result.latitude);
|
|
1130
|
+
}
|
|
1131
|
+
auto tmp_longitude = map.find("longitude");
|
|
1132
|
+
if (tmp_longitude != map.end()) {
|
|
1133
|
+
fromRawValue(context, tmp_longitude->second, result.longitude);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
static inline std::string toString(const RNMapsOverlayBoundsSouthWestStruct &value) {
|
|
1138
|
+
return "[Object RNMapsOverlayBoundsSouthWestStruct]";
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
struct RNMapsOverlayBoundsStruct {
|
|
1142
|
+
RNMapsOverlayBoundsNorthEastStruct northEast{};
|
|
1143
|
+
RNMapsOverlayBoundsSouthWestStruct southWest{};
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNMapsOverlayBoundsStruct &result) {
|
|
1147
|
+
auto map = (std::unordered_map<std::string, RawValue>)value;
|
|
1148
|
+
|
|
1149
|
+
auto tmp_northEast = map.find("northEast");
|
|
1150
|
+
if (tmp_northEast != map.end()) {
|
|
1151
|
+
fromRawValue(context, tmp_northEast->second, result.northEast);
|
|
1152
|
+
}
|
|
1153
|
+
auto tmp_southWest = map.find("southWest");
|
|
1154
|
+
if (tmp_southWest != map.end()) {
|
|
1155
|
+
fromRawValue(context, tmp_southWest->second, result.southWest);
|
|
1125
1156
|
}
|
|
1126
1157
|
}
|
|
1127
1158
|
|
|
1159
|
+
static inline std::string toString(const RNMapsOverlayBoundsStruct &value) {
|
|
1160
|
+
return "[Object RNMapsOverlayBoundsStruct]";
|
|
1161
|
+
}
|
|
1128
1162
|
class RNMapsOverlayProps final : public ViewProps {
|
|
1129
1163
|
public:
|
|
1130
1164
|
RNMapsOverlayProps() = default;
|
|
@@ -1133,7 +1167,7 @@ class RNMapsOverlayProps final : public ViewProps {
|
|
|
1133
1167
|
#pragma mark - Props
|
|
1134
1168
|
|
|
1135
1169
|
Float bearing{0.0};
|
|
1136
|
-
|
|
1170
|
+
RNMapsOverlayBoundsStruct bounds{};
|
|
1137
1171
|
ImageSource image{};
|
|
1138
1172
|
Float opacity{1.0};
|
|
1139
1173
|
bool tappable{false};
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
- (void)setBoundsRect:(NSArray *)boundsRect {
|
|
51
51
|
_boundsRect = boundsRect;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
_northEast = CLLocationCoordinate2DMake([boundsRect[0][0] doubleValue], [boundsRect[0][1] doubleValue]);
|
|
54
|
+
_southWest = CLLocationCoordinate2DMake([boundsRect[1][0] doubleValue], [boundsRect[1][1] doubleValue]);
|
|
55
55
|
|
|
56
56
|
MKMapPoint southWest = MKMapPointForCoordinate(_southWest);
|
|
57
57
|
MKMapPoint northEast = MKMapPointForCoordinate(_northEast);
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"main": "src/index.ts",
|
|
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.141",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|
package/src/MapOverlay.tsx
CHANGED
|
@@ -77,6 +77,13 @@ export type MapOverlayProps = ViewProps & {
|
|
|
77
77
|
|
|
78
78
|
type NativeProps = Modify<MapOverlayProps, {image?: string}>;
|
|
79
79
|
|
|
80
|
+
function normalizeBounds(bounds: [number, number][]): any {
|
|
81
|
+
return {
|
|
82
|
+
northEast: {latitude: bounds[0][0], longitude: bounds[0][1]},
|
|
83
|
+
southWest: {latitude: bounds[1][0], longitude: bounds[1][1]},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
80
87
|
export class MapOverlay extends React.Component<MapOverlayProps> {
|
|
81
88
|
// declaration only, as they are set through decorateMap
|
|
82
89
|
/// @ts-ignore
|
|
@@ -90,7 +97,7 @@ export class MapOverlay extends React.Component<MapOverlayProps> {
|
|
|
90
97
|
private fabricOverlay?: Boolean = undefined;
|
|
91
98
|
|
|
92
99
|
render() {
|
|
93
|
-
const {opacity = 1.0} = this.props;
|
|
100
|
+
const {opacity = 1.0, bounds} = this.props;
|
|
94
101
|
|
|
95
102
|
if (this.fabricOverlay === undefined) {
|
|
96
103
|
this.fabricOverlay = Platform.OS === 'android';
|
|
@@ -98,12 +105,27 @@ export class MapOverlay extends React.Component<MapOverlayProps> {
|
|
|
98
105
|
|
|
99
106
|
const AIRMapOverlay = this.getNativeComponent();
|
|
100
107
|
let image: any = this.props.image;
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
|
|
109
|
+
let boundsParam: any = bounds;
|
|
110
|
+
if (this.fabricOverlay) {
|
|
111
|
+
if (this.props.image) {
|
|
112
|
+
image = fixImageProp(this.props.image);
|
|
113
|
+
}
|
|
114
|
+
if (bounds) {
|
|
115
|
+
boundsParam = normalizeBounds(bounds);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
if (this.props.image) {
|
|
119
|
+
image = fixImageProp(this.props.image);
|
|
120
|
+
if (image.uri) {
|
|
121
|
+
image = image.uri;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
103
124
|
}
|
|
104
125
|
return (
|
|
105
126
|
<AIRMapOverlay
|
|
106
|
-
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
bounds={boundsParam}
|
|
107
129
|
opacity={opacity}
|
|
108
130
|
// @ts-ignore
|
|
109
131
|
image={image}
|
|
@@ -46,7 +46,16 @@ export interface OverlayFabricNativeProps extends ViewProps {
|
|
|
46
46
|
* @platform iOS: Supported
|
|
47
47
|
* @platform Android: Supported
|
|
48
48
|
*/
|
|
49
|
-
bounds:
|
|
49
|
+
bounds: Readonly<{
|
|
50
|
+
northEast: {
|
|
51
|
+
latitude: Double; // Non-nullable Double for latitude
|
|
52
|
+
longitude: Double; // Non-nullable Double for longitude
|
|
53
|
+
};
|
|
54
|
+
southWest: {
|
|
55
|
+
latitude: Double; // Non-nullable Double for latitude
|
|
56
|
+
longitude: Double; // Non-nullable Double for longitude
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
50
59
|
|
|
51
60
|
/**
|
|
52
61
|
* A custom image to be used as the overlay.
|