react-native-maps 0.29.1 → 0.30.0
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/CHANGELOG.md +31 -0
- package/README.md +10 -3
- package/docs/geojson.md +6 -3
- package/docs/installation.md +1 -1
- package/docs/marker.md +3 -2
- package/docs/tiles.md +35 -0
- package/index.d.ts +27 -9
- package/index.js +1 -3
- package/lib/android/build.gradle +3 -1
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapPolyline.java +0 -1
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +515 -0
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileWorker.java +122 -0
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java +124 -55
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTileManager.java +34 -0
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +6 -1
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTile.java +31 -87
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTileManager.java +22 -2
- package/lib/components/AnimatedRegion.js +64 -101
- package/lib/components/Geojson.js +214 -84
- package/lib/components/MapCircle.js +1 -1
- package/lib/components/MapHeatmap.js +2 -2
- package/lib/components/MapMarker.js +4 -2
- package/lib/components/MapPolygon.js +1 -1
- package/lib/components/MapPolyline.js +1 -1
- package/lib/components/MapUrlTile.js +54 -2
- package/lib/components/MapView.js +4 -4
- package/lib/components/MapWMSTile.js +49 -2
- package/lib/components/decorateMapComponent.js +1 -1
- package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h +1 -0
- package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m +8 -0
- package/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +1 -0
- package/lib/ios/AirMaps/AIRMapManager.m +6 -1
- package/lib/ios/AirMaps/AIRMapMarkerManager.m +1 -0
- package/lib/ios/AirMaps/AIRMapUrlTile.h +22 -4
- package/lib/ios/AirMaps/AIRMapUrlTile.m +124 -34
- package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.h +17 -0
- package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.m +235 -0
- package/lib/ios/AirMaps/AIRMapUrlTileManager.m +6 -1
- package/lib/ios/AirMaps/AIRMapWMSTile.h +10 -16
- package/lib/ios/AirMaps/AIRMapWMSTile.m +68 -101
- package/lib/ios/AirMaps/AIRMapWMSTileManager.m +6 -1
- package/lib/ios/AirMaps.xcodeproj/project.pbxproj +7 -1
- package/package.json +5 -4
- package/react-native-google-maps.podspec +2 -2
|
@@ -8,37 +8,46 @@ if (__DEV__) {
|
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
// const __Animated = Object.getPrototypeOf(AnimatedWithChildren);
|
|
12
|
-
// if (__Animated.name !== 'Animated') console.error('AnimatedRegion could not obtain Animated base class');
|
|
13
11
|
|
|
14
|
-
|
|
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
|
+
return valueIn instanceof Animated.Value
|
|
31
|
+
? valueIn
|
|
32
|
+
: new Animated.Value(fallback);
|
|
33
|
+
};
|
|
15
34
|
|
|
16
35
|
export default class AnimatedMapRegion extends AnimatedWithChildren {
|
|
17
|
-
constructor(valueIn) {
|
|
36
|
+
constructor(valueIn = {}) {
|
|
18
37
|
super();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
longitude
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
? value.longitude
|
|
33
|
-
: new Animated.Value(value.longitude);
|
|
34
|
-
this.latitudeDelta =
|
|
35
|
-
value.latitudeDelta instanceof Animated.Value
|
|
36
|
-
? value.latitudeDelta
|
|
37
|
-
: new Animated.Value(value.latitudeDelta);
|
|
38
|
-
this.longitudeDelta =
|
|
39
|
-
value.longitudeDelta instanceof Animated.Value
|
|
40
|
-
? value.longitudeDelta
|
|
41
|
-
: new Animated.Value(value.longitudeDelta);
|
|
38
|
+
this.latitude = getAnimatedValue(valueIn.latitude, defaultValues.latitude);
|
|
39
|
+
this.longitude = getAnimatedValue(
|
|
40
|
+
valueIn.longitude,
|
|
41
|
+
defaultValues.longitude
|
|
42
|
+
);
|
|
43
|
+
this.latitudeDelta = getAnimatedValue(
|
|
44
|
+
valueIn.latitudeDelta,
|
|
45
|
+
defaultValues.latitudeDelta
|
|
46
|
+
);
|
|
47
|
+
this.longitudeDelta = getAnimatedValue(
|
|
48
|
+
valueIn.longitudeDelta,
|
|
49
|
+
defaultValues.longitudeDelta
|
|
50
|
+
);
|
|
42
51
|
this._regionListeners = {};
|
|
43
52
|
}
|
|
44
53
|
|
|
@@ -95,10 +104,8 @@ export default class AnimatedMapRegion extends AnimatedWithChildren {
|
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
addListener(callback) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
callback(this.__getValue());
|
|
101
|
-
};
|
|
107
|
+
const id = String(_uniqueId++);
|
|
108
|
+
const jointCallback = () => /*{value}*/ callback(this.__getValue());
|
|
102
109
|
this._regionListeners[id] = {
|
|
103
110
|
latitude: this.latitude.addListener(jointCallback),
|
|
104
111
|
longitude: this.longitude.addListener(jointCallback),
|
|
@@ -119,80 +126,36 @@ export default class AnimatedMapRegion extends AnimatedWithChildren {
|
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
spring(config) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
toValue: config.longitude,
|
|
136
|
-
})
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
config.hasOwnProperty('latitudeDelta') &&
|
|
140
|
-
animations.push(
|
|
141
|
-
Animated.spring(this.latitudeDelta, {
|
|
142
|
-
...config,
|
|
143
|
-
toValue: config.latitudeDelta,
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
config.hasOwnProperty('longitudeDelta') &&
|
|
148
|
-
animations.push(
|
|
149
|
-
Animated.spring(this.longitudeDelta, {
|
|
150
|
-
...config,
|
|
151
|
-
toValue: config.longitudeDelta,
|
|
152
|
-
})
|
|
153
|
-
);
|
|
154
|
-
|
|
129
|
+
const animations = [];
|
|
130
|
+
for (const type of configTypes) {
|
|
131
|
+
if (config.hasOwnProperty(type)) {
|
|
132
|
+
animations.push(
|
|
133
|
+
Animated.spring(this[type], {
|
|
134
|
+
...config,
|
|
135
|
+
toValue: config[type],
|
|
136
|
+
// may help to eliminate some dev warnings and perf issues
|
|
137
|
+
useNativeDriver: !!config?.useNativeDriver,
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
155
142
|
return Animated.parallel(animations);
|
|
156
143
|
}
|
|
157
144
|
|
|
158
145
|
timing(config) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
...config,
|
|
173
|
-
toValue: config.longitude,
|
|
174
|
-
useNativeDriver: false,
|
|
175
|
-
})
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
config.hasOwnProperty('latitudeDelta') &&
|
|
179
|
-
animations.push(
|
|
180
|
-
Animated.timing(this.latitudeDelta, {
|
|
181
|
-
...config,
|
|
182
|
-
toValue: config.latitudeDelta,
|
|
183
|
-
useNativeDriver: false,
|
|
184
|
-
})
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
config.hasOwnProperty('longitudeDelta') &&
|
|
188
|
-
animations.push(
|
|
189
|
-
Animated.timing(this.longitudeDelta, {
|
|
190
|
-
...config,
|
|
191
|
-
toValue: config.longitudeDelta,
|
|
192
|
-
useNativeDriver: false,
|
|
193
|
-
})
|
|
194
|
-
);
|
|
195
|
-
|
|
146
|
+
const animations = [];
|
|
147
|
+
for (const type of configTypes) {
|
|
148
|
+
if (config.hasOwnProperty(type)) {
|
|
149
|
+
animations.push(
|
|
150
|
+
Animated.timing(this[type], {
|
|
151
|
+
...config,
|
|
152
|
+
toValue: config[type],
|
|
153
|
+
// may help to eliminate some dev warnings and perf issues
|
|
154
|
+
useNativeDriver: !!config?.useNativeDriver,
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
196
159
|
return Animated.parallel(animations);
|
|
197
160
|
}
|
|
198
161
|
}
|
|
@@ -1,53 +1,244 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import Marker from './MapMarker';
|
|
3
4
|
import Polyline from './MapPolyline';
|
|
4
5
|
import Polygon from './MapPolygon';
|
|
6
|
+
import { ColorPropType } from 'react-native';
|
|
5
7
|
|
|
6
|
-
|
|
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.boolean,
|
|
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) => {
|
|
7
198
|
const points = features
|
|
8
199
|
.filter(
|
|
9
|
-
f =>
|
|
200
|
+
(f) =>
|
|
10
201
|
f.geometry &&
|
|
11
202
|
(f.geometry.type === 'Point' || f.geometry.type === 'MultiPoint')
|
|
12
203
|
)
|
|
13
|
-
.map(feature =>
|
|
14
|
-
makeCoordinates(feature).map(coordinates =>
|
|
204
|
+
.map((feature) =>
|
|
205
|
+
makeCoordinates(feature).map((coordinates) =>
|
|
15
206
|
makeOverlay(coordinates, feature)
|
|
16
207
|
)
|
|
17
208
|
)
|
|
18
209
|
.reduce(flatten, [])
|
|
19
|
-
.map(overlay => ({ ...overlay, type: 'point' }));
|
|
210
|
+
.map((overlay) => ({ ...overlay, type: 'point' }));
|
|
20
211
|
|
|
21
212
|
const lines = features
|
|
22
213
|
.filter(
|
|
23
|
-
f =>
|
|
214
|
+
(f) =>
|
|
24
215
|
f.geometry &&
|
|
25
216
|
(f.geometry.type === 'LineString' ||
|
|
26
217
|
f.geometry.type === 'MultiLineString')
|
|
27
218
|
)
|
|
28
|
-
.map(feature =>
|
|
29
|
-
makeCoordinates(feature).map(coordinates =>
|
|
219
|
+
.map((feature) =>
|
|
220
|
+
makeCoordinates(feature).map((coordinates) =>
|
|
30
221
|
makeOverlay(coordinates, feature)
|
|
31
222
|
)
|
|
32
223
|
)
|
|
33
224
|
.reduce(flatten, [])
|
|
34
|
-
.map(overlay => ({ ...overlay, type: 'polyline' }));
|
|
225
|
+
.map((overlay) => ({ ...overlay, type: 'polyline' }));
|
|
35
226
|
|
|
36
227
|
const multipolygons = features
|
|
37
|
-
.filter(f => f.geometry && f.geometry.type === 'MultiPolygon')
|
|
38
|
-
.map(feature =>
|
|
39
|
-
makeCoordinates(feature).map(coordinates =>
|
|
228
|
+
.filter((f) => f.geometry && f.geometry.type === 'MultiPolygon')
|
|
229
|
+
.map((feature) =>
|
|
230
|
+
makeCoordinates(feature).map((coordinates) =>
|
|
40
231
|
makeOverlay(coordinates, feature)
|
|
41
232
|
)
|
|
42
233
|
)
|
|
43
234
|
.reduce(flatten, []);
|
|
44
235
|
|
|
45
236
|
const polygons = features
|
|
46
|
-
.filter(f => f.geometry && f.geometry.type === 'Polygon')
|
|
47
|
-
.map(feature => makeOverlay(makeCoordinates(feature), feature))
|
|
237
|
+
.filter((f) => f.geometry && f.geometry.type === 'Polygon')
|
|
238
|
+
.map((feature) => makeOverlay(makeCoordinates(feature), feature))
|
|
48
239
|
.reduce(flatten, [])
|
|
49
240
|
.concat(multipolygons)
|
|
50
|
-
.map(overlay => ({ ...overlay, type: 'polygon' }));
|
|
241
|
+
.map((overlay) => ({ ...overlay, type: 'polygon' }));
|
|
51
242
|
|
|
52
243
|
return points.concat(lines).concat(polygons);
|
|
53
244
|
};
|
|
@@ -72,11 +263,11 @@ const makeOverlay = (coordinates, feature) => {
|
|
|
72
263
|
return overlay;
|
|
73
264
|
};
|
|
74
265
|
|
|
75
|
-
const makePoint = c => ({ latitude: c[1], longitude: c[0] });
|
|
266
|
+
const makePoint = (c) => ({ latitude: c[1], longitude: c[0] });
|
|
76
267
|
|
|
77
|
-
const makeLine = l => l.map(makePoint);
|
|
268
|
+
const makeLine = (l) => l.map(makePoint);
|
|
78
269
|
|
|
79
|
-
const makeCoordinates = feature => {
|
|
270
|
+
const makeCoordinates = (feature) => {
|
|
80
271
|
const g = feature.geometry;
|
|
81
272
|
if (g.type === 'Point') {
|
|
82
273
|
return [makePoint(g.coordinates)];
|
|
@@ -89,7 +280,7 @@ const makeCoordinates = feature => {
|
|
|
89
280
|
} else if (g.type === 'Polygon') {
|
|
90
281
|
return g.coordinates.map(makeLine);
|
|
91
282
|
} else if (g.type === 'MultiPolygon') {
|
|
92
|
-
return g.coordinates.map(p => p.map(makeLine));
|
|
283
|
+
return g.coordinates.map((p) => p.map(makeLine));
|
|
93
284
|
} else {
|
|
94
285
|
return [];
|
|
95
286
|
}
|
|
@@ -107,7 +298,7 @@ const doesOverlayContainProperty = (overlay, property) => {
|
|
|
107
298
|
};
|
|
108
299
|
|
|
109
300
|
const getRgbaFromHex = (hex, alpha = 1) => {
|
|
110
|
-
const [r, g, b] = hex.match(/\w\w/g).map(x => parseInt(x, 16));
|
|
301
|
+
const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
|
|
111
302
|
return `rgba(${r},${g},${b},${alpha})`;
|
|
112
303
|
};
|
|
113
304
|
|
|
@@ -129,76 +320,15 @@ const getColor = (props, overlay, colorType, overrideColorProp) => {
|
|
|
129
320
|
}
|
|
130
321
|
return color;
|
|
131
322
|
}
|
|
132
|
-
return
|
|
323
|
+
return;
|
|
133
324
|
};
|
|
134
325
|
|
|
135
326
|
const getStrokeWidth = (props, overlay) => {
|
|
136
327
|
if (props.hasOwnProperty('strokeWidth')) {
|
|
137
|
-
return props
|
|
328
|
+
return props.strokeWidth;
|
|
138
329
|
}
|
|
139
330
|
if (doesOverlayContainProperty(overlay, 'stroke-width')) {
|
|
140
331
|
return overlay.feature.properties['stroke-width'];
|
|
141
332
|
}
|
|
142
|
-
return
|
|
333
|
+
return;
|
|
143
334
|
};
|
|
144
|
-
|
|
145
|
-
const Geojson = props => {
|
|
146
|
-
const overlays = makeOverlays(props.geojson.features);
|
|
147
|
-
return (
|
|
148
|
-
<React.Fragment>
|
|
149
|
-
{overlays.map((overlay, index) => {
|
|
150
|
-
const fillColor = getColor(props, overlay, 'fill', 'fillColor');
|
|
151
|
-
const strokeColor = getColor(props, overlay, 'stroke', 'strokeColor');
|
|
152
|
-
const markerColor = getColor(props, overlay, 'marker-color', 'color');
|
|
153
|
-
const strokeWidth = getStrokeWidth(props, overlay);
|
|
154
|
-
if (overlay.type === 'point') {
|
|
155
|
-
return (
|
|
156
|
-
<Marker
|
|
157
|
-
key={index}
|
|
158
|
-
coordinate={overlay.coordinates}
|
|
159
|
-
image={props.image}
|
|
160
|
-
pinColor={markerColor}
|
|
161
|
-
zIndex={props.zIndex}
|
|
162
|
-
onPress={() => props.onPress(overlay)}
|
|
163
|
-
/>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
if (overlay.type === 'polygon') {
|
|
167
|
-
return (
|
|
168
|
-
<Polygon
|
|
169
|
-
key={index}
|
|
170
|
-
coordinates={overlay.coordinates}
|
|
171
|
-
holes={overlay.holes}
|
|
172
|
-
strokeColor={strokeColor}
|
|
173
|
-
fillColor={fillColor}
|
|
174
|
-
strokeWidth={strokeWidth}
|
|
175
|
-
tappable={props.tappable}
|
|
176
|
-
onPress={() => props.onPress(overlay)}
|
|
177
|
-
zIndex={props.zIndex}
|
|
178
|
-
/>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
if (overlay.type === 'polyline') {
|
|
182
|
-
return (
|
|
183
|
-
<Polyline
|
|
184
|
-
key={index}
|
|
185
|
-
coordinates={overlay.coordinates}
|
|
186
|
-
strokeColor={strokeColor}
|
|
187
|
-
strokeWidth={strokeWidth}
|
|
188
|
-
lineDashPhase={props.lineDashPhase}
|
|
189
|
-
lineDashPattern={props.lineDashPattern}
|
|
190
|
-
lineCap={props.lineCap}
|
|
191
|
-
lineJoin={props.lineJoin}
|
|
192
|
-
miterLimit={props.miterLimit}
|
|
193
|
-
zIndex={props.zIndex}
|
|
194
|
-
tappable={props.tappable}
|
|
195
|
-
onPress={() => props.onPress(overlay)}
|
|
196
|
-
/>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
})}
|
|
200
|
-
</React.Fragment>
|
|
201
|
-
);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export default Geojson;
|
|
@@ -73,13 +73,13 @@ class MapHeatmap extends React.Component {
|
|
|
73
73
|
let gradient;
|
|
74
74
|
if (this.props.gradient) {
|
|
75
75
|
gradient = Object.assign({}, this.props.gradient);
|
|
76
|
-
gradient.colors = gradient.colors.map(c => processColor(c));
|
|
76
|
+
gradient.colors = gradient.colors.map((c) => processColor(c));
|
|
77
77
|
}
|
|
78
78
|
return (
|
|
79
79
|
<AIRMapHeatmap
|
|
80
80
|
{...this.props}
|
|
81
81
|
gradient={gradient}
|
|
82
|
-
ref={ref => {
|
|
82
|
+
ref={(ref) => {
|
|
83
83
|
this.heatmap = ref;
|
|
84
84
|
}}
|
|
85
85
|
/>
|
|
@@ -189,6 +189,8 @@ const propTypes = {
|
|
|
189
189
|
|
|
190
190
|
draggable: PropTypes.bool,
|
|
191
191
|
|
|
192
|
+
tappable: PropTypes.bool,
|
|
193
|
+
|
|
192
194
|
/**
|
|
193
195
|
* Sets whether this marker should track view changes true.
|
|
194
196
|
*/
|
|
@@ -333,14 +335,14 @@ class MapMarker extends React.Component {
|
|
|
333
335
|
|
|
334
336
|
return (
|
|
335
337
|
<AIRMapMarker
|
|
336
|
-
ref={ref => {
|
|
338
|
+
ref={(ref) => {
|
|
337
339
|
this.marker = ref;
|
|
338
340
|
}}
|
|
339
341
|
{...this.props}
|
|
340
342
|
image={image}
|
|
341
343
|
icon={icon}
|
|
342
344
|
style={[styles.marker, this.props.style]}
|
|
343
|
-
onPress={event => {
|
|
345
|
+
onPress={(event) => {
|
|
344
346
|
if (this.props.stopPropagation) {
|
|
345
347
|
event.stopPropagation();
|
|
346
348
|
}
|