react-native-maps 0.31.1 → 1.0.0-beta.1
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.m +0 -7
- package/ios/AirMaps/AIRMapManager.m +0 -105
- 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 +18 -27
- package/react-native-google-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/lib/MapView.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.enableLatestRenderer = exports.AnimatedMapView = exports.MAP_TYPES = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const react_native_1 = require("react-native");
|
|
29
|
+
const decorateMapComponent_1 = require("./decorateMapComponent");
|
|
30
|
+
const ProviderConstants = __importStar(require("./ProviderConstants"));
|
|
31
|
+
exports.MAP_TYPES = {
|
|
32
|
+
STANDARD: 'standard',
|
|
33
|
+
SATELLITE: 'satellite',
|
|
34
|
+
HYBRID: 'hybrid',
|
|
35
|
+
TERRAIN: 'terrain',
|
|
36
|
+
NONE: 'none',
|
|
37
|
+
MUTEDSTANDARD: 'mutedStandard',
|
|
38
|
+
};
|
|
39
|
+
const GOOGLE_MAPS_ONLY_TYPES = [exports.MAP_TYPES.TERRAIN, exports.MAP_TYPES.NONE];
|
|
40
|
+
class MapView extends React.Component {
|
|
41
|
+
static Animated;
|
|
42
|
+
map;
|
|
43
|
+
__lastRegion;
|
|
44
|
+
__layoutCalled;
|
|
45
|
+
constructor(props) {
|
|
46
|
+
super(props);
|
|
47
|
+
this.map = React.createRef();
|
|
48
|
+
this.state = {
|
|
49
|
+
isReady: react_native_1.Platform.OS === 'ios',
|
|
50
|
+
};
|
|
51
|
+
this._onMapReady = this._onMapReady.bind(this);
|
|
52
|
+
this._onChange = this._onChange.bind(this);
|
|
53
|
+
this._onLayout = this._onLayout.bind(this);
|
|
54
|
+
}
|
|
55
|
+
setNativeProps(props) {
|
|
56
|
+
this.map.current?.setNativeProps(props);
|
|
57
|
+
}
|
|
58
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
59
|
+
if (this.state.isReady &&
|
|
60
|
+
this.props.customMapStyle !== prevProps.customMapStyle) {
|
|
61
|
+
this._updateStyle(this.props.customMapStyle);
|
|
62
|
+
}
|
|
63
|
+
return this.props.region || null;
|
|
64
|
+
}
|
|
65
|
+
componentDidUpdate(_prevProps, _prevState, region) {
|
|
66
|
+
const a = this.__lastRegion;
|
|
67
|
+
const b = region;
|
|
68
|
+
if (!a || !b) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (a.latitude !== b.latitude ||
|
|
72
|
+
a.longitude !== b.longitude ||
|
|
73
|
+
a.latitudeDelta !== b.latitudeDelta ||
|
|
74
|
+
a.longitudeDelta !== b.longitudeDelta) {
|
|
75
|
+
this.map.current?.setNativeProps({ region: b });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
componentDidMount() {
|
|
79
|
+
const { isReady } = this.state;
|
|
80
|
+
if (isReady) {
|
|
81
|
+
this._updateStyle(this.props.customMapStyle);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
_updateStyle(customMapStyle) {
|
|
85
|
+
this.map.current?.setNativeProps({
|
|
86
|
+
customMapStyleString: JSON.stringify(customMapStyle),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
_onMapReady() {
|
|
90
|
+
const { region, initialRegion, onMapReady } = this.props;
|
|
91
|
+
if (region) {
|
|
92
|
+
this.map.current?.setNativeProps({ region });
|
|
93
|
+
}
|
|
94
|
+
else if (initialRegion) {
|
|
95
|
+
this.map.current?.setNativeProps({ initialRegion });
|
|
96
|
+
}
|
|
97
|
+
this._updateStyle(this.props.customMapStyle);
|
|
98
|
+
this.setState({ isReady: true }, () => {
|
|
99
|
+
if (onMapReady) {
|
|
100
|
+
onMapReady();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
_onLayout(e) {
|
|
105
|
+
const { layout } = e.nativeEvent;
|
|
106
|
+
if (!layout.width || !layout.height) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (this.state.isReady && !this.__layoutCalled) {
|
|
110
|
+
const { region, initialRegion } = this.props;
|
|
111
|
+
if (region) {
|
|
112
|
+
this.__layoutCalled = true;
|
|
113
|
+
this.map.current?.setNativeProps({ region });
|
|
114
|
+
}
|
|
115
|
+
else if (initialRegion) {
|
|
116
|
+
this.__layoutCalled = true;
|
|
117
|
+
this.map.current?.setNativeProps({ initialRegion });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (this.props.onLayout) {
|
|
121
|
+
this.props.onLayout(e);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
_onChange({ nativeEvent }) {
|
|
125
|
+
this.__lastRegion = nativeEvent.region;
|
|
126
|
+
const isGesture = nativeEvent.isGesture;
|
|
127
|
+
const details = { isGesture };
|
|
128
|
+
if (nativeEvent.continuous) {
|
|
129
|
+
if (this.props.onRegionChange) {
|
|
130
|
+
this.props.onRegionChange(nativeEvent.region, details);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (this.props.onRegionChangeComplete) {
|
|
134
|
+
this.props.onRegionChangeComplete(nativeEvent.region, details);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
getCamera() {
|
|
138
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
139
|
+
return react_native_1.NativeModules.AirMapModule.getCamera(this._getHandle());
|
|
140
|
+
}
|
|
141
|
+
else if (react_native_1.Platform.OS === 'ios') {
|
|
142
|
+
return this._runCommand('getCamera', []);
|
|
143
|
+
}
|
|
144
|
+
return Promise.reject('getCamera not supported on this platform');
|
|
145
|
+
}
|
|
146
|
+
setCamera(camera) {
|
|
147
|
+
this._runCommand('setCamera', [camera]);
|
|
148
|
+
}
|
|
149
|
+
animateCamera(camera, opts) {
|
|
150
|
+
this._runCommand('animateCamera', [camera, opts ? opts.duration : 500]);
|
|
151
|
+
}
|
|
152
|
+
animateToRegion(region, duration = 500) {
|
|
153
|
+
this._runCommand('animateToRegion', [region, duration]);
|
|
154
|
+
}
|
|
155
|
+
fitToElements(options = {}) {
|
|
156
|
+
const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
|
|
157
|
+
this._runCommand('fitToElements', [edgePadding, animated]);
|
|
158
|
+
}
|
|
159
|
+
fitToSuppliedMarkers(markers, options = {}) {
|
|
160
|
+
const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
|
|
161
|
+
this._runCommand('fitToSuppliedMarkers', [markers, edgePadding, animated]);
|
|
162
|
+
}
|
|
163
|
+
fitToCoordinates(coordinates = [], options = {}) {
|
|
164
|
+
const { edgePadding = { top: 0, right: 0, bottom: 0, left: 0 }, animated = true, } = options;
|
|
165
|
+
this._runCommand('fitToCoordinates', [coordinates, edgePadding, animated]);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get visible boudaries
|
|
169
|
+
*
|
|
170
|
+
* @return Promise Promise with the bounding box ({ northEast: <LatLng>, southWest: <LatLng> })
|
|
171
|
+
*/
|
|
172
|
+
async getMapBoundaries() {
|
|
173
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
174
|
+
return await react_native_1.NativeModules.AirMapModule.getMapBoundaries(this._getHandle());
|
|
175
|
+
}
|
|
176
|
+
else if (react_native_1.Platform.OS === 'ios') {
|
|
177
|
+
return await this._runCommand('getMapBoundaries', []);
|
|
178
|
+
}
|
|
179
|
+
return Promise.reject('getMapBoundaries not supported on this platform');
|
|
180
|
+
}
|
|
181
|
+
setMapBoundaries(northEast, southWest) {
|
|
182
|
+
this._runCommand('setMapBoundaries', [northEast, southWest]);
|
|
183
|
+
}
|
|
184
|
+
setIndoorActiveLevelIndex(activeLevelIndex) {
|
|
185
|
+
this._runCommand('setIndoorActiveLevelIndex', [activeLevelIndex]);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Takes a snapshot of the map and saves it to a picture
|
|
189
|
+
* file or returns the image as a base64 encoded string.
|
|
190
|
+
*
|
|
191
|
+
* @param config Configuration options
|
|
192
|
+
* @param [config.width] Width of the rendered map-view (when omitted actual view width is used).
|
|
193
|
+
* @param [config.height] Height of the rendered map-view (when omitted actual height is used).
|
|
194
|
+
* @param [config.region] Region to render (Only supported on iOS).
|
|
195
|
+
* @param [config.format] Encoding format ('png', 'jpg') (default: 'png').
|
|
196
|
+
* @param [config.quality] Compression quality (only used for jpg) (default: 1.0).
|
|
197
|
+
* @param [config.result] Result format ('file', 'base64') (default: 'file').
|
|
198
|
+
*
|
|
199
|
+
* @return Promise Promise with either the file-uri or base64 encoded string
|
|
200
|
+
*/
|
|
201
|
+
takeSnapshot(args) {
|
|
202
|
+
// Sanitize inputs
|
|
203
|
+
const config = {
|
|
204
|
+
width: args.width || 0,
|
|
205
|
+
height: args.height || 0,
|
|
206
|
+
region: args.region || {},
|
|
207
|
+
format: args.format || 'png',
|
|
208
|
+
quality: args.quality || 1.0,
|
|
209
|
+
result: args.result || 'file',
|
|
210
|
+
};
|
|
211
|
+
if (config.format !== 'png' && config.format !== 'jpg') {
|
|
212
|
+
throw new Error('Invalid format specified');
|
|
213
|
+
}
|
|
214
|
+
if (config.result !== 'file' && config.result !== 'base64') {
|
|
215
|
+
throw new Error('Invalid result specified');
|
|
216
|
+
}
|
|
217
|
+
// Call native function
|
|
218
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
219
|
+
return react_native_1.NativeModules.AirMapModule.takeSnapshot(this._getHandle(), config);
|
|
220
|
+
}
|
|
221
|
+
else if (react_native_1.Platform.OS === 'ios') {
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
this._runCommand('takeSnapshot', [
|
|
224
|
+
config.width,
|
|
225
|
+
config.height,
|
|
226
|
+
config.region,
|
|
227
|
+
config.format,
|
|
228
|
+
config.quality,
|
|
229
|
+
config.result,
|
|
230
|
+
(err, snapshot) => {
|
|
231
|
+
if (err) {
|
|
232
|
+
reject(err);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
resolve(snapshot);
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
]);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return Promise.reject('takeSnapshot not supported on this platform');
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Convert a coordinate to address by using default Geocoder
|
|
245
|
+
*
|
|
246
|
+
* @param coordinate Coordinate
|
|
247
|
+
* @param [coordinate.latitude] Latitude
|
|
248
|
+
* @param [coordinate.longitude] Longitude
|
|
249
|
+
*
|
|
250
|
+
* @return Promise with return type Address
|
|
251
|
+
*/
|
|
252
|
+
addressForCoordinate(coordinate) {
|
|
253
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
254
|
+
return react_native_1.NativeModules.AirMapModule.getAddressFromCoordinates(this._getHandle(), coordinate);
|
|
255
|
+
}
|
|
256
|
+
else if (react_native_1.Platform.OS === 'ios') {
|
|
257
|
+
return this._runCommand('getAddressFromCoordinates', [coordinate]);
|
|
258
|
+
}
|
|
259
|
+
return Promise.reject('getAddress not supported on this platform');
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Convert a map coordinate to user-space point
|
|
263
|
+
*
|
|
264
|
+
* @param coordinate Coordinate
|
|
265
|
+
* @param [coordinate.latitude] Latitude
|
|
266
|
+
* @param [coordinate.longitude] Longitude
|
|
267
|
+
*
|
|
268
|
+
* @return Promise Promise with the point ({ x: Number, y: Number })
|
|
269
|
+
*/
|
|
270
|
+
pointForCoordinate(coordinate) {
|
|
271
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
272
|
+
return react_native_1.NativeModules.AirMapModule.pointForCoordinate(this._getHandle(), coordinate);
|
|
273
|
+
}
|
|
274
|
+
else if (react_native_1.Platform.OS === 'ios') {
|
|
275
|
+
return this._runCommand('pointForCoordinate', [coordinate]);
|
|
276
|
+
}
|
|
277
|
+
return Promise.reject('pointForCoordinate not supported on this platform');
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Convert a user-space point to a map coordinate
|
|
281
|
+
*
|
|
282
|
+
* @param point Point
|
|
283
|
+
* @param [point.x] X
|
|
284
|
+
* @param [point.x] Y
|
|
285
|
+
*
|
|
286
|
+
* @return Promise Promise with the coordinate ({ latitude: Number, longitude: Number })
|
|
287
|
+
*/
|
|
288
|
+
coordinateForPoint(point) {
|
|
289
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
290
|
+
return react_native_1.NativeModules.AirMapModule.coordinateForPoint(this._getHandle(), point);
|
|
291
|
+
}
|
|
292
|
+
else if (react_native_1.Platform.OS === 'ios') {
|
|
293
|
+
return this._runCommand('coordinateForPoint', [point]);
|
|
294
|
+
}
|
|
295
|
+
return Promise.reject('coordinateForPoint not supported on this platform');
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Get markers' centers and frames in user-space coordinates
|
|
299
|
+
*
|
|
300
|
+
* @param onlyVisible boolean true to include only visible markers, false to include all
|
|
301
|
+
*
|
|
302
|
+
* @return Promise Promise with { <identifier>: { point: Point, frame: Frame } }
|
|
303
|
+
*/
|
|
304
|
+
getMarkersFrames(onlyVisible = false) {
|
|
305
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
306
|
+
return this._runCommand('getMarkersFrames', [onlyVisible]);
|
|
307
|
+
}
|
|
308
|
+
return Promise.reject('getMarkersFrames not supported on this platform');
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get bounding box from region
|
|
312
|
+
*
|
|
313
|
+
* @param region Region
|
|
314
|
+
*
|
|
315
|
+
* @return Object Object bounding box ({ northEast: <LatLng>, southWest: <LatLng> })
|
|
316
|
+
*/
|
|
317
|
+
boundingBoxForRegion(region) {
|
|
318
|
+
return {
|
|
319
|
+
northEast: {
|
|
320
|
+
latitude: region.latitude + region.latitudeDelta / 2,
|
|
321
|
+
longitude: region.longitude + region.longitudeDelta / 2,
|
|
322
|
+
},
|
|
323
|
+
southWest: {
|
|
324
|
+
latitude: region.latitude - region.latitudeDelta / 2,
|
|
325
|
+
longitude: region.longitude - region.longitudeDelta / 2,
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
_uiManagerCommand(name) {
|
|
330
|
+
const componentName = (0, decorateMapComponent_1.getNativeMapName)(this.props.provider);
|
|
331
|
+
return react_native_1.UIManager.getViewManagerConfig(componentName).Commands[name];
|
|
332
|
+
}
|
|
333
|
+
_mapManagerCommand(name) {
|
|
334
|
+
return react_native_1.NativeModules[`${(0, decorateMapComponent_1.getNativeMapName)(this.props.provider)}Manager`][name];
|
|
335
|
+
}
|
|
336
|
+
_getHandle() {
|
|
337
|
+
return (0, react_native_1.findNodeHandle)(this.map.current);
|
|
338
|
+
}
|
|
339
|
+
_runCommand(name, args) {
|
|
340
|
+
switch (react_native_1.Platform.OS) {
|
|
341
|
+
case 'android':
|
|
342
|
+
return react_native_1.UIManager.dispatchViewManagerCommand(this._getHandle(), this._uiManagerCommand(name), args);
|
|
343
|
+
case 'ios':
|
|
344
|
+
return this._mapManagerCommand(name)(this._getHandle(), ...args);
|
|
345
|
+
default:
|
|
346
|
+
return Promise.reject(`Invalid platform was passed: ${react_native_1.Platform.OS}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
render() {
|
|
350
|
+
let props;
|
|
351
|
+
if (this.state.isReady) {
|
|
352
|
+
props = {
|
|
353
|
+
region: null,
|
|
354
|
+
initialRegion: null,
|
|
355
|
+
onChange: this._onChange,
|
|
356
|
+
onMapReady: this._onMapReady,
|
|
357
|
+
onLayout: this._onLayout,
|
|
358
|
+
ref: this.map,
|
|
359
|
+
...this.props,
|
|
360
|
+
};
|
|
361
|
+
if (react_native_1.Platform.OS === 'ios' &&
|
|
362
|
+
props.provider === ProviderConstants.PROVIDER_DEFAULT &&
|
|
363
|
+
props.mapType &&
|
|
364
|
+
GOOGLE_MAPS_ONLY_TYPES.includes(props.mapType)) {
|
|
365
|
+
props.mapType = exports.MAP_TYPES.STANDARD;
|
|
366
|
+
}
|
|
367
|
+
if (props.onPanDrag) {
|
|
368
|
+
props.handlePanDrag = !!props.onPanDrag;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
props = {
|
|
373
|
+
style: this.props.style,
|
|
374
|
+
region: null,
|
|
375
|
+
initialRegion: this.props.initialRegion || null,
|
|
376
|
+
ref: this.map,
|
|
377
|
+
onChange: this._onChange,
|
|
378
|
+
onMapReady: this._onMapReady,
|
|
379
|
+
onLayout: this._onLayout,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
if (react_native_1.Platform.OS === 'android' && this.props.liteMode) {
|
|
383
|
+
return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
|
|
384
|
+
<AIRMapLite {...props}/>
|
|
385
|
+
</decorateMapComponent_1.ProviderContext.Provider>);
|
|
386
|
+
}
|
|
387
|
+
const AIRMap = getNativeMapComponent(this.props.provider);
|
|
388
|
+
return (<decorateMapComponent_1.ProviderContext.Provider value={this.props.provider}>
|
|
389
|
+
<AIRMap {...props}/>
|
|
390
|
+
</decorateMapComponent_1.ProviderContext.Provider>);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const airMaps = {
|
|
394
|
+
default: (0, react_native_1.requireNativeComponent)('AIRMap'),
|
|
395
|
+
google: () => null,
|
|
396
|
+
};
|
|
397
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
398
|
+
airMaps.google = airMaps.default;
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
airMaps.google = decorateMapComponent_1.googleMapIsInstalled
|
|
402
|
+
? (0, react_native_1.requireNativeComponent)('AIRGoogleMap')
|
|
403
|
+
: (0, decorateMapComponent_1.createNotSupportedComponent)('react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS.');
|
|
404
|
+
}
|
|
405
|
+
const getNativeMapComponent = (provider) => airMaps[provider || 'default'];
|
|
406
|
+
const AIRMapLite = react_native_1.UIManager.getViewManagerConfig('AIRMapLite')
|
|
407
|
+
? (0, react_native_1.requireNativeComponent)('AIRMapLite')
|
|
408
|
+
: () => null;
|
|
409
|
+
exports.AnimatedMapView = react_native_1.Animated.createAnimatedComponent(MapView);
|
|
410
|
+
const enableLatestRenderer = () => {
|
|
411
|
+
if (react_native_1.Platform.OS !== 'android') {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
return react_native_1.NativeModules.AirMapModule.enableLatestRenderer();
|
|
415
|
+
};
|
|
416
|
+
exports.enableLatestRenderer = enableLatestRenderer;
|
|
417
|
+
MapView.Animated = exports.AnimatedMapView;
|
|
418
|
+
exports.default = MapView;
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
exports.default = void 0;
|
|
7
|
+
//@ts-ignore
|
|
8
|
+
var UnimplementedView_1 = require("react-native-web/dist/modules/UnimplementedView");
|
|
9
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(UnimplementedView_1).default; } });
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
import { ProviderContext, NativeComponent, MapManagerCommand, UIManagerCommand } from './decorateMapComponent';
|
|
4
|
+
declare type Props = ViewProps & {
|
|
5
|
+
/**
|
|
6
|
+
* The maximum native zoom level for this tile overlay i.e. the highest zoom level that the tile server provides.
|
|
7
|
+
* Tiles are auto-scaled for higher zoom levels.
|
|
8
|
+
*
|
|
9
|
+
* @platform iOS: Apple Maps only
|
|
10
|
+
* @platform Android: Supported
|
|
11
|
+
*/
|
|
12
|
+
maximumNativeZ?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The maximum zoom level for this tile overlay.
|
|
15
|
+
*
|
|
16
|
+
* @platform iOS: Supported
|
|
17
|
+
* @platform Android: Supported
|
|
18
|
+
*/
|
|
19
|
+
maximumZ?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The minimum zoom level for this tile overlay.
|
|
22
|
+
*
|
|
23
|
+
* @platform iOS: Supported
|
|
24
|
+
* @platform Android: Supported
|
|
25
|
+
*/
|
|
26
|
+
minimumZ?: number;
|
|
27
|
+
/**
|
|
28
|
+
* In offline-mode tiles are not fetched from the tile servers, rather only tiles stored in the cache directory are used.
|
|
29
|
+
* Furthermore automated tile scaling is activated: if tile at a desired zoom level is not found from the cache directory,
|
|
30
|
+
* then lower zoom level tile is used (up to 4 levels lower) and scaled.
|
|
31
|
+
*
|
|
32
|
+
* @default false
|
|
33
|
+
* @platform iOS: Apple Maps only
|
|
34
|
+
* @platform Android: Supported
|
|
35
|
+
*/
|
|
36
|
+
offlineMode?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Map layer opacity. Value between 0 - 1, with 0 meaning fully transparent.
|
|
39
|
+
*
|
|
40
|
+
* @platform iOS: Supported
|
|
41
|
+
* @platform Android: Supported
|
|
42
|
+
*/
|
|
43
|
+
opacity?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Corresponds to MKTileOverlay canReplaceMapContent i.e. if true then underlying iOS basemap is not shown.
|
|
46
|
+
*
|
|
47
|
+
* @default false
|
|
48
|
+
* @platform iOS: Apple Maps only
|
|
49
|
+
* @platform Android: Not supported
|
|
50
|
+
*/
|
|
51
|
+
shouldReplaceMapContent?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Defines maximum age in seconds for a cached tile before it's refreshed.
|
|
54
|
+
*
|
|
55
|
+
* NB! Refresh logic is "serve-stale-while-refresh"
|
|
56
|
+
* i.e. to ensure map availability a stale (over max age) tile is served
|
|
57
|
+
* while a tile refresh process is started in the background.
|
|
58
|
+
*
|
|
59
|
+
* @platform iOS: Apple Maps only
|
|
60
|
+
* @platform Android: Supported
|
|
61
|
+
*/
|
|
62
|
+
tileCacheMaxAge?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Enable caching of tiles in the specified directory.
|
|
65
|
+
* Directory can be specified either as a normal path or in URL format (`file://`).
|
|
66
|
+
*
|
|
67
|
+
* Tiles are stored in tileCachePath directory as `/{z}/{x}/{y}` i.e. in sub-directories 2-levels deep,
|
|
68
|
+
* filename is tile y-coordinate without any filetype-extension.
|
|
69
|
+
*
|
|
70
|
+
* NB! All cache management needs to be implemented by client e.g. deleting tiles to manage use of storage space etc.
|
|
71
|
+
*
|
|
72
|
+
* @platform iOS: Apple Maps only
|
|
73
|
+
* @platform Android: Supported
|
|
74
|
+
*/
|
|
75
|
+
tileCachePath?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Tile size, default size is 256 (for tiles of 256 _ 256 pixels).
|
|
78
|
+
* High-res (aka 'retina') tiles are 512 (tiles of 512 _ 512 pixels)
|
|
79
|
+
*
|
|
80
|
+
* @platform iOS: Supported
|
|
81
|
+
* @platform Android: Supported
|
|
82
|
+
*/
|
|
83
|
+
tileSize?: number;
|
|
84
|
+
/**
|
|
85
|
+
* The url template of the map tileserver.
|
|
86
|
+
* (URLTile) The patterns {x} {y} {z} will be replaced at runtime.
|
|
87
|
+
* For example, http://c.tile.openstreetmap.org/{z}/{x}/{y}.png.
|
|
88
|
+
*
|
|
89
|
+
* It is also possible to refer to tiles in local filesystem with file:///top-level-directory/sub-directory/{z}/{x}/{y}.png URL-format.
|
|
90
|
+
* (WMSTile) The patterns {minX} {maxX} {minY} {maxY} {width} {height} will be replaced at runtime according to EPSG:900913 specification bounding box.
|
|
91
|
+
* For example, https://demo.geo-solutions.it/geoserver/tiger/wms?service=WMS&version=1.1.0&request=GetMap&layers=tiger:poi&styles=&bbox={minX},{minY},{maxX},{maxY}&width={width}&height={height}&srs=EPSG:900913&format=image/png&transparent=true&format_options=dpi:213.
|
|
92
|
+
*
|
|
93
|
+
* @platform iOS: Supported
|
|
94
|
+
* @platform Android: Supported
|
|
95
|
+
*/
|
|
96
|
+
urlTemplate: string;
|
|
97
|
+
/**
|
|
98
|
+
* The order in which this tile overlay is drawn with respect to other overlays.
|
|
99
|
+
* An overlay with a larger z-index is drawn over overlays with smaller z-indices.
|
|
100
|
+
* The order of overlays with the same z-index is arbitrary.
|
|
101
|
+
*
|
|
102
|
+
* @platform iOS: Google Maps only
|
|
103
|
+
* @platform Android: Supported
|
|
104
|
+
*/
|
|
105
|
+
zIndex?: number;
|
|
106
|
+
};
|
|
107
|
+
declare type NativeProps = Props;
|
|
108
|
+
export declare class MapWMSTile extends React.Component<Props> {
|
|
109
|
+
context: React.ContextType<typeof ProviderContext>;
|
|
110
|
+
getNativeComponent: () => NativeComponent<NativeProps>;
|
|
111
|
+
getMapManagerCommand: (name: string) => MapManagerCommand;
|
|
112
|
+
getUIManagerCommand: (name: string) => UIManagerCommand;
|
|
113
|
+
render(): JSX.Element;
|
|
114
|
+
}
|
|
115
|
+
declare const _default: typeof MapWMSTile;
|
|
116
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.MapWMSTile = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const decorateMapComponent_1 = __importStar(require("./decorateMapComponent"));
|
|
29
|
+
class MapWMSTile extends React.Component {
|
|
30
|
+
getNativeComponent;
|
|
31
|
+
getMapManagerCommand;
|
|
32
|
+
getUIManagerCommand;
|
|
33
|
+
render() {
|
|
34
|
+
const AIRMapWMSTile = this.getNativeComponent();
|
|
35
|
+
return <AIRMapWMSTile {...this.props}/>;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.MapWMSTile = MapWMSTile;
|
|
39
|
+
exports.default = (0, decorateMapComponent_1.default)(MapWMSTile, 'WMSTile', {
|
|
40
|
+
google: {
|
|
41
|
+
ios: decorateMapComponent_1.SUPPORTED,
|
|
42
|
+
android: decorateMapComponent_1.USES_DEFAULT_IMPLEMENTATION,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { HostComponent } from 'react-native';
|
|
3
|
+
import { Provider } from './sharedTypes';
|
|
4
|
+
import { MapCallout } from './MapCallout';
|
|
5
|
+
import { MapOverlay } from './MapOverlay';
|
|
6
|
+
import { MapCalloutSubview } from './MapCalloutSubview';
|
|
7
|
+
import { MapCircle } from './MapCircle';
|
|
8
|
+
import { MapHeatmap } from './MapHeatmap';
|
|
9
|
+
import { MapLocalTile } from './MapLocalTile';
|
|
10
|
+
import { MapMarker } from './MapMarker';
|
|
11
|
+
import { MapPolygon } from './MapPolygon';
|
|
12
|
+
import { MapPolyline } from './MapPolyline';
|
|
13
|
+
import { MapUrlTile } from './MapUrlTile';
|
|
14
|
+
import { MapWMSTile } from './MapWMSTile';
|
|
15
|
+
export declare const SUPPORTED: ImplementationStatus;
|
|
16
|
+
export declare const USES_DEFAULT_IMPLEMENTATION: ImplementationStatus;
|
|
17
|
+
export declare const NOT_SUPPORTED: ImplementationStatus;
|
|
18
|
+
export declare const ProviderContext: import("react").Context<Provider>;
|
|
19
|
+
export declare function getNativeMapName(provider: Provider): "AIRMap" | "AIRGoogleMap";
|
|
20
|
+
export declare const createNotSupportedComponent: (message: string) => () => null;
|
|
21
|
+
export declare const googleMapIsInstalled = true;
|
|
22
|
+
export default function decorateMapComponent<Type extends Component>(Component: Type, componentName: ComponentName, providers: Providers): Type;
|
|
23
|
+
declare type ImplementationStatus = 'SUPPORTED' | 'USES_DEFAULT_IMPLEMENTATION' | 'NOT_SUPPORTED';
|
|
24
|
+
declare type Providers = {
|
|
25
|
+
google: {
|
|
26
|
+
ios: ImplementationStatus;
|
|
27
|
+
android: ImplementationStatus;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare type UIManagerCommand = number;
|
|
31
|
+
export declare type MapManagerCommand = any;
|
|
32
|
+
export declare type NativeComponent<H = unknown> = HostComponent<H> | ReturnType<typeof createNotSupportedComponent>;
|
|
33
|
+
declare type Component = typeof MapCallout | typeof MapCalloutSubview | typeof MapCircle | typeof MapHeatmap | typeof MapLocalTile | typeof MapMarker | typeof MapOverlay | typeof MapPolygon | typeof MapPolyline | typeof MapUrlTile | typeof MapWMSTile;
|
|
34
|
+
declare type ComponentName = 'Callout' | 'CalloutSubview' | 'Circle' | 'Heatmap' | 'LocalTile' | 'Marker' | 'Overlay' | 'Polygon' | 'Polyline' | 'UrlTile' | 'WMSTile';
|
|
35
|
+
export {};
|