react-native-maps 0.31.0 → 1.0.0-beta.2
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/README.md +1 -5
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTile.java +11 -4
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTileManager.java +5 -1
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +2 -41
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +5 -5
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +0 -32
- package/ios/AirGoogleMaps/AIRGoogleMap.m +37 -31
- package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -95
- package/ios/AirMaps/AIRMap.h +0 -1
- package/ios/AirMaps/AIRMap.m +0 -12
- package/ios/AirMaps/AIRMapManager.m +2 -132
- package/lib/AnimatedRegion.d.ts +19 -0
- package/lib/AnimatedRegion.js +134 -0
- package/lib/Geojson.d.ts +166 -0
- package/lib/Geojson.js +165 -0
- package/lib/MapCallout.d.ts +40 -0
- package/lib/MapCallout.js +51 -0
- package/lib/MapCalloutSubview.d.ts +34 -0
- package/lib/MapCalloutSubview.js +48 -0
- package/lib/MapCircle.d.ts +117 -0
- package/lib/MapCircle.js +53 -0
- package/lib/MapHeatmap.d.ts +77 -0
- package/lib/MapHeatmap.js +59 -0
- package/lib/MapLocalTile.d.ts +35 -0
- package/lib/MapLocalTile.js +44 -0
- package/lib/MapMarker.d.ts +289 -0
- package/lib/MapMarker.js +113 -0
- package/lib/MapOverlay.d.ts +86 -0
- package/lib/MapOverlay.js +63 -0
- package/lib/MapPolygon.d.ts +156 -0
- package/lib/MapPolygon.js +74 -0
- package/lib/MapPolyline.d.ts +156 -0
- package/lib/MapPolyline.js +53 -0
- package/lib/MapUrlTile.d.ts +134 -0
- package/lib/MapUrlTile.js +44 -0
- package/lib/MapView.d.ts +825 -0
- package/lib/MapView.js +418 -0
- package/{src/MapView.web.js → lib/MapView.web.d.ts} +0 -0
- package/lib/MapView.web.js +9 -0
- package/lib/MapWMSTile.d.ts +116 -0
- package/lib/MapWMSTile.js +44 -0
- package/lib/ProviderConstants.d.ts +2 -0
- package/lib/ProviderConstants.js +5 -0
- package/lib/decorateMapComponent.d.ts +35 -0
- package/lib/decorateMapComponent.js +80 -0
- package/{src/index.js → lib/index.d.ts} +5 -16
- package/lib/index.js +66 -0
- package/lib/sharedTypes.d.ts +82 -0
- package/lib/sharedTypes.js +2 -0
- package/package.json +19 -28
- package/react-native-google-maps.podspec +1 -1
- package/react-native-maps.podspec +1 -1
- package/index.d.ts +0 -637
- package/src/AnimatedRegion.js +0 -164
- package/src/Geojson.js +0 -334
- package/src/MapCallout.js +0 -51
- package/src/MapCalloutSubview.js +0 -44
- package/src/MapCircle.js +0 -150
- package/src/MapHeatmap.js +0 -99
- package/src/MapLocalTile.js +0 -52
- package/src/MapMarker.js +0 -377
- package/src/MapOverlay.js +0 -86
- package/src/MapPolygon.js +0 -202
- package/src/MapPolyline.js +0 -168
- package/src/MapUrlTile.js +0 -131
- package/src/MapView.js +0 -1160
- package/src/MapWMSTile.js +0 -122
- package/src/ProviderConstants.js +0 -2
- package/src/decorateMapComponent.js +0 -112
package/src/AnimatedRegion.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { Animated } from 'react-native';
|
|
2
|
-
|
|
3
|
-
const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY);
|
|
4
|
-
if (__DEV__) {
|
|
5
|
-
if (AnimatedWithChildren.name !== 'AnimatedWithChildren') {
|
|
6
|
-
console.error(
|
|
7
|
-
'AnimatedRegion could not obtain AnimatedWithChildren base class'
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const configTypes = [
|
|
13
|
-
'latitude',
|
|
14
|
-
'longitude',
|
|
15
|
-
'latitudeDelta',
|
|
16
|
-
'longitudeDelta',
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const defaultValues = {
|
|
20
|
-
// probably want to come up with better defaults
|
|
21
|
-
latitude: 0,
|
|
22
|
-
longitude: 0,
|
|
23
|
-
latitudeDelta: 0,
|
|
24
|
-
longitudeDelta: 0,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
let _uniqueId = 1;
|
|
28
|
-
|
|
29
|
-
const getAnimatedValue = (valueIn, fallback) => {
|
|
30
|
-
if (valueIn instanceof Animated.Value) {
|
|
31
|
-
return valueIn;
|
|
32
|
-
} else if (typeof valueIn === 'number') {
|
|
33
|
-
return new Animated.Value(valueIn);
|
|
34
|
-
}
|
|
35
|
-
return new Animated.Value(fallback);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default class AnimatedMapRegion extends AnimatedWithChildren {
|
|
39
|
-
constructor(valueIn = {}) {
|
|
40
|
-
super();
|
|
41
|
-
this.latitude = getAnimatedValue(valueIn.latitude, defaultValues.latitude);
|
|
42
|
-
this.longitude = getAnimatedValue(
|
|
43
|
-
valueIn.longitude,
|
|
44
|
-
defaultValues.longitude
|
|
45
|
-
);
|
|
46
|
-
this.latitudeDelta = getAnimatedValue(
|
|
47
|
-
valueIn.latitudeDelta,
|
|
48
|
-
defaultValues.latitudeDelta
|
|
49
|
-
);
|
|
50
|
-
this.longitudeDelta = getAnimatedValue(
|
|
51
|
-
valueIn.longitudeDelta,
|
|
52
|
-
defaultValues.longitudeDelta
|
|
53
|
-
);
|
|
54
|
-
this._regionListeners = {};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
setValue(value) {
|
|
58
|
-
this.latitude._value = value.latitude;
|
|
59
|
-
this.longitude._value = value.longitude;
|
|
60
|
-
this.latitudeDelta._value = value.latitudeDelta;
|
|
61
|
-
this.longitudeDelta._value = value.longitudeDelta;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
setOffset(offset) {
|
|
65
|
-
this.latitude.setOffset(offset.latitude);
|
|
66
|
-
this.longitude.setOffset(offset.longitude);
|
|
67
|
-
this.latitudeDelta.setOffset(offset.latitudeDelta);
|
|
68
|
-
this.longitudeDelta.setOffset(offset.longitudeDelta);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
flattenOffset() {
|
|
72
|
-
this.latitude.flattenOffset();
|
|
73
|
-
this.longitude.flattenOffset();
|
|
74
|
-
this.latitudeDelta.flattenOffset();
|
|
75
|
-
this.longitudeDelta.flattenOffset();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
__getValue() {
|
|
79
|
-
return {
|
|
80
|
-
latitude: this.latitude.__getValue(),
|
|
81
|
-
longitude: this.longitude.__getValue(),
|
|
82
|
-
latitudeDelta: this.latitudeDelta.__getValue(),
|
|
83
|
-
longitudeDelta: this.longitudeDelta.__getValue(),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
__attach() {
|
|
88
|
-
this.latitude.__addChild(this);
|
|
89
|
-
this.longitude.__addChild(this);
|
|
90
|
-
this.latitudeDelta.__addChild(this);
|
|
91
|
-
this.longitudeDelta.__addChild(this);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
__detach() {
|
|
95
|
-
this.latitude.__removeChild(this);
|
|
96
|
-
this.longitude.__removeChild(this);
|
|
97
|
-
this.latitudeDelta.__removeChild(this);
|
|
98
|
-
this.longitudeDelta.__removeChild(this);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
stopAnimation(callback) {
|
|
102
|
-
this.latitude.stopAnimation();
|
|
103
|
-
this.longitude.stopAnimation();
|
|
104
|
-
this.latitudeDelta.stopAnimation();
|
|
105
|
-
this.longitudeDelta.stopAnimation();
|
|
106
|
-
callback && callback(this.__getValue());
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
addListener(callback) {
|
|
110
|
-
const id = String(_uniqueId++);
|
|
111
|
-
const jointCallback = () => /*{value}*/ callback(this.__getValue());
|
|
112
|
-
this._regionListeners[id] = {
|
|
113
|
-
latitude: this.latitude.addListener(jointCallback),
|
|
114
|
-
longitude: this.longitude.addListener(jointCallback),
|
|
115
|
-
latitudeDelta: this.latitudeDelta.addListener(jointCallback),
|
|
116
|
-
longitudeDelta: this.longitudeDelta.addListener(jointCallback),
|
|
117
|
-
};
|
|
118
|
-
return id;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
removeListener(id) {
|
|
122
|
-
this.latitude.removeListener(this._regionListeners[id].latitude);
|
|
123
|
-
this.longitude.removeListener(this._regionListeners[id].longitude);
|
|
124
|
-
this.latitudeDelta.removeListener(this._regionListeners[id].latitudeDelta);
|
|
125
|
-
this.longitudeDelta.removeListener(
|
|
126
|
-
this._regionListeners[id].longitudeDelta
|
|
127
|
-
);
|
|
128
|
-
delete this._regionListeners[id];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
spring(config) {
|
|
132
|
-
const animations = [];
|
|
133
|
-
for (const type of configTypes) {
|
|
134
|
-
if (config.hasOwnProperty(type)) {
|
|
135
|
-
animations.push(
|
|
136
|
-
Animated.spring(this[type], {
|
|
137
|
-
...config,
|
|
138
|
-
toValue: config[type],
|
|
139
|
-
// may help to eliminate some dev warnings and perf issues
|
|
140
|
-
useNativeDriver: !!config?.useNativeDriver,
|
|
141
|
-
})
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return Animated.parallel(animations);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
timing(config) {
|
|
149
|
-
const animations = [];
|
|
150
|
-
for (const type of configTypes) {
|
|
151
|
-
if (config.hasOwnProperty(type)) {
|
|
152
|
-
animations.push(
|
|
153
|
-
Animated.timing(this[type], {
|
|
154
|
-
...config,
|
|
155
|
-
toValue: config[type],
|
|
156
|
-
// may help to eliminate some dev warnings and perf issues
|
|
157
|
-
useNativeDriver: !!config?.useNativeDriver,
|
|
158
|
-
})
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return Animated.parallel(animations);
|
|
163
|
-
}
|
|
164
|
-
}
|
package/src/Geojson.js
DELETED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Marker from './MapMarker';
|
|
4
|
-
import Polyline from './MapPolyline';
|
|
5
|
-
import Polygon from './MapPolygon';
|
|
6
|
-
import { ColorPropType } from 'deprecated-react-native-prop-types';
|
|
7
|
-
|
|
8
|
-
const propTypes = {
|
|
9
|
-
/**
|
|
10
|
-
* [Geojson](https://geojson.org/) description of object.
|
|
11
|
-
*/
|
|
12
|
-
geojson: PropTypes.object.isRequired,
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The stroke color to use for the path.
|
|
16
|
-
*/
|
|
17
|
-
strokeColor: ColorPropType,
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The fill color to use for the path.
|
|
21
|
-
*/
|
|
22
|
-
fillColor: ColorPropType,
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The stroke width to use for the path.
|
|
26
|
-
*/
|
|
27
|
-
strokeWidth: PropTypes.number,
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The offset (in points) at which to start drawing the dash pattern.
|
|
31
|
-
*
|
|
32
|
-
* Use this property to start drawing a dashed line partway through a segment or gap. For
|
|
33
|
-
* example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the
|
|
34
|
-
* middle of the first gap.
|
|
35
|
-
*
|
|
36
|
-
* The default value of this property is 0.
|
|
37
|
-
*
|
|
38
|
-
* @platform ios
|
|
39
|
-
*/
|
|
40
|
-
lineDashPhase: PropTypes.number,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Make the `Polygon` or `Polyline` tappable
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
tappable: PropTypes.bool,
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* An array of numbers specifying the dash pattern to use for the path.
|
|
50
|
-
*
|
|
51
|
-
* The array contains one or more numbers that indicate the lengths (measured in points) of the
|
|
52
|
-
* line segments and gaps in the pattern. The values in the array alternate, starting with the
|
|
53
|
-
* first line segment length, followed by the first gap length, followed by the second line
|
|
54
|
-
* segment length, and so on.
|
|
55
|
-
*
|
|
56
|
-
* This property is set to `null` by default, which indicates no line dash pattern.
|
|
57
|
-
*
|
|
58
|
-
* @platform ios
|
|
59
|
-
*/
|
|
60
|
-
lineDashPattern: PropTypes.arrayOf(PropTypes.number),
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The line cap style to apply to the open ends of the path.
|
|
64
|
-
* The default style is `round`.
|
|
65
|
-
*
|
|
66
|
-
* @platform ios
|
|
67
|
-
*/
|
|
68
|
-
lineCap: PropTypes.oneOf(['butt', 'round', 'square']),
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The line join style to apply to corners of the path.
|
|
72
|
-
* The default style is `round`.
|
|
73
|
-
*
|
|
74
|
-
* @platform ios
|
|
75
|
-
*/
|
|
76
|
-
lineJoin: PropTypes.oneOf(['miter', 'round', 'bevel']),
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The limiting value that helps avoid spikes at junctions between connected line segments.
|
|
80
|
-
* The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If
|
|
81
|
-
* the ratio of the miter length—that is, the diagonal length of the miter join—to the line
|
|
82
|
-
* thickness exceeds the miter limit, the joint is converted to a bevel join. The default
|
|
83
|
-
* miter limit is 10, which results in the conversion of miters whose angle at the joint
|
|
84
|
-
* is less than 11 degrees.
|
|
85
|
-
*
|
|
86
|
-
* @platform ios
|
|
87
|
-
*/
|
|
88
|
-
miterLimit: PropTypes.number,
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The order in which this tile overlay is drawn with respect to other overlays. An overlay
|
|
92
|
-
* with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays
|
|
93
|
-
* with the same z-index is arbitrary. The default zIndex is 0.
|
|
94
|
-
*
|
|
95
|
-
* @platform android
|
|
96
|
-
*/
|
|
97
|
-
zIndex: PropTypes.number,
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Callback that is called when the user presses on the polygon
|
|
101
|
-
*/
|
|
102
|
-
onPress: PropTypes.func,
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Component to render in place of the default marker when the overlay type is a `point`
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
markerComponent: PropTypes.node,
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* The title of the marker. This is only used if the <Marker /> component has no children that
|
|
112
|
-
* are a `<Callout />`, in which case the default callout behavior will be used, which
|
|
113
|
-
* will show both the `title` and the `description`, if provided.
|
|
114
|
-
*/
|
|
115
|
-
title: PropTypes.string,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const Geojson = (props) => {
|
|
119
|
-
const {
|
|
120
|
-
title,
|
|
121
|
-
image,
|
|
122
|
-
zIndex,
|
|
123
|
-
onPress,
|
|
124
|
-
lineCap,
|
|
125
|
-
lineJoin,
|
|
126
|
-
tappable,
|
|
127
|
-
miterLimit,
|
|
128
|
-
lineDashPhase,
|
|
129
|
-
lineDashPattern,
|
|
130
|
-
markerComponent,
|
|
131
|
-
} = props;
|
|
132
|
-
const overlays = makeOverlays(props.geojson.features);
|
|
133
|
-
return (
|
|
134
|
-
<React.Fragment>
|
|
135
|
-
{overlays.map((overlay, index) => {
|
|
136
|
-
const fillColor = getColor(props, overlay, 'fill', 'fillColor');
|
|
137
|
-
const strokeColor = getColor(props, overlay, 'stroke', 'strokeColor');
|
|
138
|
-
const markerColor = getColor(props, overlay, 'marker-color', 'color');
|
|
139
|
-
const strokeWidth = getStrokeWidth(props, overlay);
|
|
140
|
-
if (overlay.type === 'point') {
|
|
141
|
-
return (
|
|
142
|
-
<Marker
|
|
143
|
-
key={index}
|
|
144
|
-
coordinate={overlay.coordinates}
|
|
145
|
-
image={image}
|
|
146
|
-
title={title}
|
|
147
|
-
pinColor={markerColor}
|
|
148
|
-
zIndex={zIndex}
|
|
149
|
-
onPress={() => onPress && onPress(overlay)}
|
|
150
|
-
>
|
|
151
|
-
{markerComponent}
|
|
152
|
-
</Marker>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
if (overlay.type === 'polygon') {
|
|
156
|
-
return (
|
|
157
|
-
<Polygon
|
|
158
|
-
key={index}
|
|
159
|
-
coordinates={overlay.coordinates}
|
|
160
|
-
holes={overlay.holes}
|
|
161
|
-
strokeColor={strokeColor}
|
|
162
|
-
fillColor={fillColor}
|
|
163
|
-
strokeWidth={strokeWidth}
|
|
164
|
-
tappable={tappable}
|
|
165
|
-
onPress={() => onPress && onPress(overlay)}
|
|
166
|
-
zIndex={zIndex}
|
|
167
|
-
/>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
if (overlay.type === 'polyline') {
|
|
171
|
-
return (
|
|
172
|
-
<Polyline
|
|
173
|
-
key={index}
|
|
174
|
-
coordinates={overlay.coordinates}
|
|
175
|
-
strokeColor={strokeColor}
|
|
176
|
-
strokeWidth={strokeWidth}
|
|
177
|
-
lineDashPhase={lineDashPhase}
|
|
178
|
-
lineDashPattern={lineDashPattern}
|
|
179
|
-
lineCap={lineCap}
|
|
180
|
-
lineJoin={lineJoin}
|
|
181
|
-
miterLimit={miterLimit}
|
|
182
|
-
zIndex={zIndex}
|
|
183
|
-
tappable={tappable}
|
|
184
|
-
onPress={() => onPress && onPress(overlay)}
|
|
185
|
-
/>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
})}
|
|
189
|
-
</React.Fragment>
|
|
190
|
-
);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
Geojson.propTypes = propTypes;
|
|
194
|
-
|
|
195
|
-
export default Geojson;
|
|
196
|
-
|
|
197
|
-
export const makeOverlays = (features) => {
|
|
198
|
-
const points = features
|
|
199
|
-
.filter(
|
|
200
|
-
(f) =>
|
|
201
|
-
f.geometry &&
|
|
202
|
-
(f.geometry.type === 'Point' || f.geometry.type === 'MultiPoint')
|
|
203
|
-
)
|
|
204
|
-
.map((feature) =>
|
|
205
|
-
makeCoordinates(feature).map((coordinates) =>
|
|
206
|
-
makeOverlay(coordinates, feature)
|
|
207
|
-
)
|
|
208
|
-
)
|
|
209
|
-
.reduce(flatten, [])
|
|
210
|
-
.map((overlay) => ({ ...overlay, type: 'point' }));
|
|
211
|
-
|
|
212
|
-
const lines = features
|
|
213
|
-
.filter(
|
|
214
|
-
(f) =>
|
|
215
|
-
f.geometry &&
|
|
216
|
-
(f.geometry.type === 'LineString' ||
|
|
217
|
-
f.geometry.type === 'MultiLineString')
|
|
218
|
-
)
|
|
219
|
-
.map((feature) =>
|
|
220
|
-
makeCoordinates(feature).map((coordinates) =>
|
|
221
|
-
makeOverlay(coordinates, feature)
|
|
222
|
-
)
|
|
223
|
-
)
|
|
224
|
-
.reduce(flatten, [])
|
|
225
|
-
.map((overlay) => ({ ...overlay, type: 'polyline' }));
|
|
226
|
-
|
|
227
|
-
const multipolygons = features
|
|
228
|
-
.filter((f) => f.geometry && f.geometry.type === 'MultiPolygon')
|
|
229
|
-
.map((feature) =>
|
|
230
|
-
makeCoordinates(feature).map((coordinates) =>
|
|
231
|
-
makeOverlay(coordinates, feature)
|
|
232
|
-
)
|
|
233
|
-
)
|
|
234
|
-
.reduce(flatten, []);
|
|
235
|
-
|
|
236
|
-
const polygons = features
|
|
237
|
-
.filter((f) => f.geometry && f.geometry.type === 'Polygon')
|
|
238
|
-
.map((feature) => makeOverlay(makeCoordinates(feature), feature))
|
|
239
|
-
.reduce(flatten, [])
|
|
240
|
-
.concat(multipolygons)
|
|
241
|
-
.map((overlay) => ({ ...overlay, type: 'polygon' }));
|
|
242
|
-
|
|
243
|
-
return points.concat(lines).concat(polygons);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const flatten = (prev, curr) => prev.concat(curr);
|
|
247
|
-
|
|
248
|
-
const makeOverlay = (coordinates, feature) => {
|
|
249
|
-
let overlay = {
|
|
250
|
-
feature,
|
|
251
|
-
};
|
|
252
|
-
if (
|
|
253
|
-
feature.geometry.type === 'Polygon' ||
|
|
254
|
-
feature.geometry.type === 'MultiPolygon'
|
|
255
|
-
) {
|
|
256
|
-
overlay.coordinates = coordinates[0];
|
|
257
|
-
if (coordinates.length > 1) {
|
|
258
|
-
overlay.holes = coordinates.slice(1);
|
|
259
|
-
}
|
|
260
|
-
} else {
|
|
261
|
-
overlay.coordinates = coordinates;
|
|
262
|
-
}
|
|
263
|
-
return overlay;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const makePoint = (c) => ({ latitude: c[1], longitude: c[0] });
|
|
267
|
-
|
|
268
|
-
const makeLine = (l) => l.map(makePoint);
|
|
269
|
-
|
|
270
|
-
const makeCoordinates = (feature) => {
|
|
271
|
-
const g = feature.geometry;
|
|
272
|
-
if (g.type === 'Point') {
|
|
273
|
-
return [makePoint(g.coordinates)];
|
|
274
|
-
} else if (g.type === 'MultiPoint') {
|
|
275
|
-
return g.coordinates.map(makePoint);
|
|
276
|
-
} else if (g.type === 'LineString') {
|
|
277
|
-
return [makeLine(g.coordinates)];
|
|
278
|
-
} else if (g.type === 'MultiLineString') {
|
|
279
|
-
return g.coordinates.map(makeLine);
|
|
280
|
-
} else if (g.type === 'Polygon') {
|
|
281
|
-
return g.coordinates.map(makeLine);
|
|
282
|
-
} else if (g.type === 'MultiPolygon') {
|
|
283
|
-
return g.coordinates.map((p) => p.map(makeLine));
|
|
284
|
-
} else {
|
|
285
|
-
return [];
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const doesOverlayContainProperty = (overlay, property) => {
|
|
290
|
-
// Geojson may have 0 for the opacity when intention is to not specify the
|
|
291
|
-
// opacity. Therefore, we evaluate the truthiness of the propery where 0
|
|
292
|
-
// would return false.
|
|
293
|
-
return (
|
|
294
|
-
overlay.feature &&
|
|
295
|
-
overlay.feature.properties &&
|
|
296
|
-
overlay.feature.properties[property]
|
|
297
|
-
);
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
const getRgbaFromHex = (hex, alpha = 1) => {
|
|
301
|
-
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
302
|
-
return `rgba(${r},${g},${b},${alpha})`;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
const getColor = (props, overlay, colorType, overrideColorProp) => {
|
|
306
|
-
if (props.hasOwnProperty(overrideColorProp)) {
|
|
307
|
-
return props[overrideColorProp];
|
|
308
|
-
}
|
|
309
|
-
if (doesOverlayContainProperty(overlay, colorType)) {
|
|
310
|
-
let color = overlay.feature.properties[colorType];
|
|
311
|
-
const opacityProperty = colorType + '-opacity';
|
|
312
|
-
if (
|
|
313
|
-
doesOverlayContainProperty(overlay, opacityProperty) &&
|
|
314
|
-
color[0] === '#'
|
|
315
|
-
) {
|
|
316
|
-
color = getRgbaFromHex(
|
|
317
|
-
color,
|
|
318
|
-
overlay.feature.properties[opacityProperty]
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
return color;
|
|
322
|
-
}
|
|
323
|
-
return;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const getStrokeWidth = (props, overlay) => {
|
|
327
|
-
if (props.hasOwnProperty('strokeWidth')) {
|
|
328
|
-
return props.strokeWidth;
|
|
329
|
-
}
|
|
330
|
-
if (doesOverlayContainProperty(overlay, 'stroke-width')) {
|
|
331
|
-
return overlay.feature.properties['stroke-width'];
|
|
332
|
-
}
|
|
333
|
-
return;
|
|
334
|
-
};
|
package/src/MapCallout.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { StyleSheet } from 'react-native';
|
|
4
|
-
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
|
-
import decorateMapComponent, {
|
|
6
|
-
SUPPORTED,
|
|
7
|
-
USES_DEFAULT_IMPLEMENTATION,
|
|
8
|
-
} from './decorateMapComponent';
|
|
9
|
-
|
|
10
|
-
const propTypes = {
|
|
11
|
-
...ViewPropTypes,
|
|
12
|
-
tooltip: PropTypes.bool,
|
|
13
|
-
onPress: PropTypes.func,
|
|
14
|
-
alphaHitTest: PropTypes.bool,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const defaultProps = {
|
|
18
|
-
tooltip: false,
|
|
19
|
-
alphaHitTest: false,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
class MapCallout extends React.Component {
|
|
23
|
-
render() {
|
|
24
|
-
const AIRMapCallout = this.getAirComponent();
|
|
25
|
-
return (
|
|
26
|
-
<AIRMapCallout
|
|
27
|
-
{...this.props}
|
|
28
|
-
style={[styles.callout, this.props.style]}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
MapCallout.propTypes = propTypes;
|
|
35
|
-
MapCallout.defaultProps = defaultProps;
|
|
36
|
-
|
|
37
|
-
const styles = StyleSheet.create({
|
|
38
|
-
callout: {
|
|
39
|
-
position: 'absolute',
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export default decorateMapComponent(MapCallout, {
|
|
44
|
-
componentType: 'Callout',
|
|
45
|
-
providers: {
|
|
46
|
-
google: {
|
|
47
|
-
ios: SUPPORTED,
|
|
48
|
-
android: USES_DEFAULT_IMPLEMENTATION,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
});
|
package/src/MapCalloutSubview.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { StyleSheet } from 'react-native';
|
|
4
|
-
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
|
-
import decorateMapComponent, {
|
|
6
|
-
SUPPORTED,
|
|
7
|
-
NOT_SUPPORTED,
|
|
8
|
-
} from './decorateMapComponent';
|
|
9
|
-
|
|
10
|
-
const propTypes = {
|
|
11
|
-
...ViewPropTypes,
|
|
12
|
-
onPress: PropTypes.func,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const defaultProps = {};
|
|
16
|
-
|
|
17
|
-
class MapCalloutSubview extends React.Component {
|
|
18
|
-
render() {
|
|
19
|
-
const AIRMapCalloutSubview = this.getAirComponent();
|
|
20
|
-
return (
|
|
21
|
-
<AIRMapCalloutSubview
|
|
22
|
-
{...this.props}
|
|
23
|
-
style={[styles.calloutSubview, this.props.style]}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
MapCalloutSubview.propTypes = propTypes;
|
|
30
|
-
MapCalloutSubview.defaultProps = defaultProps;
|
|
31
|
-
|
|
32
|
-
const styles = StyleSheet.create({
|
|
33
|
-
calloutSubview: {},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export default decorateMapComponent(MapCalloutSubview, {
|
|
37
|
-
componentType: 'CalloutSubview',
|
|
38
|
-
providers: {
|
|
39
|
-
google: {
|
|
40
|
-
ios: SUPPORTED,
|
|
41
|
-
android: NOT_SUPPORTED,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
});
|