react-native-maps 0.29.4 → 0.30.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 +8 -1
- package/index.d.ts +25 -10
- package/index.js +1 -3
- package/lib/android/build.gradle +3 -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 +67 -101
- package/lib/components/Geojson.js +67 -40
- package/lib/components/MapCallout.js +3 -5
- package/lib/components/MapCalloutSubview.js +3 -5
- package/lib/components/MapCircle.js +6 -6
- package/lib/components/MapHeatmap.js +5 -7
- package/lib/components/MapLocalTile.js +2 -6
- package/lib/components/MapMarker.js +9 -9
- package/lib/components/MapOverlay.js +3 -2
- package/lib/components/MapPolygon.js +6 -6
- package/lib/components/MapPolyline.js +6 -6
- package/lib/components/MapUrlTile.js +56 -8
- package/lib/components/MapView.js +12 -14
- package/lib/components/MapWMSTile.js +51 -8
- 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 +43 -6
- package/react-native-google-maps.podspec +2 -2
- package/.eslintrc +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -111
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -32
- package/.github/ISSUE_TEMPLATE.md +0 -5
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -53
- package/.github/stale.yml +0 -17
- package/.github/workflows/base.yml +0 -21
- package/.prettierrc +0 -4
- package/CHANGELOG.md +0 -761
- package/docs/callout.md +0 -38
- package/docs/circle.md +0 -28
- package/docs/examples-setup.md +0 -17
- package/docs/geojson.md +0 -50
- package/docs/heatmap.md +0 -32
- package/docs/installation.md +0 -347
- package/docs/mapview.md +0 -252
- package/docs/marker.md +0 -84
- package/docs/overlay.md +0 -27
- package/docs/polygon.md +0 -34
- package/docs/polyline.md +0 -65
- package/enable-google-maps +0 -15
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ColorPropType,
|
|
5
|
+
ViewPropTypes,
|
|
6
|
+
} from 'deprecated-react-native-prop-types';
|
|
4
7
|
import decorateMapComponent, {
|
|
5
8
|
USES_DEFAULT_IMPLEMENTATION,
|
|
6
9
|
SUPPORTED,
|
|
7
10
|
} from './decorateMapComponent';
|
|
8
11
|
|
|
9
|
-
// if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
|
|
10
|
-
const viewPropTypes = ViewPropTypes || View.propTypes;
|
|
11
|
-
|
|
12
12
|
const propTypes = {
|
|
13
|
-
...
|
|
13
|
+
...ViewPropTypes,
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* An array of coordinates to describe the polygon
|
|
@@ -147,7 +147,7 @@ class MapPolyline extends React.Component {
|
|
|
147
147
|
return (
|
|
148
148
|
<AIRMapPolyline
|
|
149
149
|
{...this.props}
|
|
150
|
-
ref={ref => {
|
|
150
|
+
ref={(ref) => {
|
|
151
151
|
this.polyline = ref;
|
|
152
152
|
}}
|
|
153
153
|
/>
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { ViewPropTypes, View } from 'react-native';
|
|
3
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
4
|
|
|
6
5
|
import decorateMapComponent, {
|
|
7
6
|
USES_DEFAULT_IMPLEMENTATION,
|
|
8
7
|
SUPPORTED,
|
|
9
8
|
} from './decorateMapComponent';
|
|
10
9
|
|
|
11
|
-
// if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
|
|
12
|
-
const viewPropTypes = ViewPropTypes || View.propTypes;
|
|
13
|
-
|
|
14
10
|
const propTypes = {
|
|
15
|
-
...
|
|
11
|
+
...ViewPropTypes,
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* The url template of the tile server. The patterns {x} {y} {z} will be replaced at runtime
|
|
@@ -28,12 +24,20 @@ const propTypes = {
|
|
|
28
24
|
* @platform android
|
|
29
25
|
*/
|
|
30
26
|
zIndex: PropTypes.number,
|
|
27
|
+
|
|
31
28
|
/**
|
|
32
29
|
* The maximum zoom level for this tile overlay.
|
|
33
30
|
*
|
|
34
31
|
*/
|
|
35
32
|
maximumZ: PropTypes.number,
|
|
36
33
|
|
|
34
|
+
/**
|
|
35
|
+
* (Optional) The maximum native zoom level for this tile overlay. Tiles are auto-scaled for higher
|
|
36
|
+
* zoom levels.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
maximumNativeZ: PropTypes.number,
|
|
40
|
+
|
|
37
41
|
/**
|
|
38
42
|
* The minimum zoom level for this tile overlay.
|
|
39
43
|
*
|
|
@@ -48,12 +52,20 @@ const propTypes = {
|
|
|
48
52
|
shouldReplaceMapContent: PropTypes.bool,
|
|
49
53
|
|
|
50
54
|
/**
|
|
51
|
-
* (Optional) Tile size
|
|
55
|
+
* (Optional) Tile size only, default size is 256 (for tiles of 256 * 256 pixels)
|
|
52
56
|
*
|
|
53
|
-
* @platform ios
|
|
54
57
|
*/
|
|
55
58
|
tileSize: PropTypes.number,
|
|
56
59
|
|
|
60
|
+
/**
|
|
61
|
+
* (Optional) Doubles tile size from 256 to 512 utilising higher zoom levels i.e.
|
|
62
|
+
* loading 4 higher zoom level tiles and combining them for one high-resolution
|
|
63
|
+
* tile. iOS does this automatically, even if it is not desirable always.
|
|
64
|
+
*
|
|
65
|
+
* @platform android
|
|
66
|
+
*/
|
|
67
|
+
doubleTileSize: PropTypes.bool,
|
|
68
|
+
|
|
57
69
|
/**
|
|
58
70
|
*
|
|
59
71
|
* Allow tiles using the TMS coordinate system (origin bottom left)
|
|
@@ -61,6 +73,42 @@ const propTypes = {
|
|
|
61
73
|
*
|
|
62
74
|
*/
|
|
63
75
|
flipY: PropTypes.bool,
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* (Optional) Enable caching of tiles in the specified directory. Directory
|
|
80
|
+
* can be specified either as a normal path or in URL format (file://). Tiles
|
|
81
|
+
* are stored in tileCachePath directory as follows "/{z}/{x}/{y}" i.e. in
|
|
82
|
+
* sub-directories 2-levels deep, filename tile y-coordinate without any
|
|
83
|
+
* filetype-extension.
|
|
84
|
+
* NB! All cache management needs to be implemented by client e.g. deleting tiles
|
|
85
|
+
* to manage use of storage space etc.
|
|
86
|
+
*
|
|
87
|
+
*/
|
|
88
|
+
tileCachePath: PropTypes.string,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* (Optional) Defines how maximum age in seconds for cached tile before they
|
|
92
|
+
* are refreshed. NB! Refresh logic is "serve-stale-while-refresh" i.e. to
|
|
93
|
+
* ensure map availability a stale (over max age) tile is served while a tile
|
|
94
|
+
* refresh process is started in the background.
|
|
95
|
+
*/
|
|
96
|
+
tileCacheMaxAge: PropTypes.number,
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* (Optional) Sets offline-mode. In offline-mode tiles are not fetched from
|
|
100
|
+
* the tile servers, rather only tiles stored in the cache directory are used.
|
|
101
|
+
* Furthermore automated tile scaling is activated: if tile at a desired zoom
|
|
102
|
+
* level is not found from the cache directory, then lower zoom level tile is
|
|
103
|
+
* used (until minimumZ) and scaled.
|
|
104
|
+
*/
|
|
105
|
+
offlineMode: PropTypes.bool,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* (Optional) Map layer opacity. Value between 0 - 1, with 0 meaning fully
|
|
109
|
+
* transparent.
|
|
110
|
+
*/
|
|
111
|
+
opacity: PropTypes.number,
|
|
64
112
|
};
|
|
65
113
|
|
|
66
114
|
class MapUrlTile extends React.Component {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import {
|
|
4
|
-
EdgeInsetsPropType,
|
|
5
|
-
PointPropType,
|
|
6
4
|
Platform,
|
|
7
5
|
Animated as RNAnimated,
|
|
8
6
|
requireNativeComponent,
|
|
9
7
|
NativeModules,
|
|
10
|
-
ColorPropType,
|
|
11
8
|
findNodeHandle,
|
|
12
|
-
ViewPropTypes,
|
|
13
|
-
View,
|
|
14
9
|
} from 'react-native';
|
|
10
|
+
import {
|
|
11
|
+
EdgeInsetsPropType,
|
|
12
|
+
PointPropType,
|
|
13
|
+
ColorPropType,
|
|
14
|
+
ViewPropTypes,
|
|
15
|
+
} from 'deprecated-react-native-prop-types';
|
|
15
16
|
import MapMarker from './MapMarker';
|
|
16
17
|
import MapPolyline from './MapPolyline';
|
|
17
18
|
import MapPolygon from './MapPolygon';
|
|
@@ -65,11 +66,8 @@ const CameraShape = PropTypes.shape({
|
|
|
65
66
|
zoom: PropTypes.number.isRequired,
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
// if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
|
|
69
|
-
const viewPropTypes = ViewPropTypes || View.propTypes;
|
|
70
|
-
|
|
71
69
|
const propTypes = {
|
|
72
|
-
...
|
|
70
|
+
...ViewPropTypes,
|
|
73
71
|
/**
|
|
74
72
|
* When provider is "google", we will use GoogleMaps.
|
|
75
73
|
* Any value other than "google" will default to using
|
|
@@ -81,7 +79,7 @@ const propTypes = {
|
|
|
81
79
|
* Used to style and layout the `MapView`. See `StyleSheet.js` and
|
|
82
80
|
* `ViewStylePropTypes.js` for more info.
|
|
83
81
|
*/
|
|
84
|
-
style:
|
|
82
|
+
style: ViewPropTypes.style,
|
|
85
83
|
|
|
86
84
|
/**
|
|
87
85
|
* A json object that describes the style of the map. This is transformed to a string
|
|
@@ -1042,7 +1040,7 @@ class MapView extends React.Component {
|
|
|
1042
1040
|
if (Platform.OS === 'android' && this.props.liteMode) {
|
|
1043
1041
|
return (
|
|
1044
1042
|
<AIRMapLite
|
|
1045
|
-
ref={ref => {
|
|
1043
|
+
ref={(ref) => {
|
|
1046
1044
|
this.map = ref;
|
|
1047
1045
|
}}
|
|
1048
1046
|
{...props}
|
|
@@ -1054,7 +1052,7 @@ class MapView extends React.Component {
|
|
|
1054
1052
|
|
|
1055
1053
|
return (
|
|
1056
1054
|
<AIRMap
|
|
1057
|
-
ref={ref => {
|
|
1055
|
+
ref={(ref) => {
|
|
1058
1056
|
this.map = ref;
|
|
1059
1057
|
}}
|
|
1060
1058
|
{...props}
|
|
@@ -1069,7 +1067,7 @@ MapView.childContextTypes = childContextTypes;
|
|
|
1069
1067
|
|
|
1070
1068
|
MapView.MAP_TYPES = MAP_TYPES;
|
|
1071
1069
|
|
|
1072
|
-
const nativeComponent = Component =>
|
|
1070
|
+
const nativeComponent = (Component) =>
|
|
1073
1071
|
requireNativeComponent(Component, MapView, {
|
|
1074
1072
|
nativeOnly: {
|
|
1075
1073
|
onChange: true,
|
|
@@ -1090,7 +1088,7 @@ if (Platform.OS === 'android') {
|
|
|
1090
1088
|
'react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS.'
|
|
1091
1089
|
);
|
|
1092
1090
|
}
|
|
1093
|
-
const getAirMapComponent = provider => airMaps[provider || 'default'];
|
|
1091
|
+
const getAirMapComponent = (provider) => airMaps[provider || 'default'];
|
|
1094
1092
|
|
|
1095
1093
|
let AIRMapLite;
|
|
1096
1094
|
if (!NativeModules.UIManager.getViewManagerConfig) {
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { ViewPropTypes, View } from 'react-native';
|
|
3
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
4
|
|
|
6
5
|
import decorateMapComponent, {
|
|
7
6
|
USES_DEFAULT_IMPLEMENTATION,
|
|
8
7
|
SUPPORTED,
|
|
9
8
|
} from './decorateMapComponent';
|
|
10
9
|
|
|
11
|
-
// if ViewPropTypes is not defined fall back to View.propType (to support RN < 0.44)
|
|
12
|
-
const viewPropTypes = ViewPropTypes || View.propTypes;
|
|
13
|
-
|
|
14
10
|
const propTypes = {
|
|
15
|
-
...
|
|
11
|
+
...ViewPropTypes,
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* The url template of the tile server. The patterns {minX} {maxX} {minY} {maxY} {width} {height}
|
|
@@ -29,12 +25,20 @@ const propTypes = {
|
|
|
29
25
|
* @platform android
|
|
30
26
|
*/
|
|
31
27
|
zIndex: PropTypes.number,
|
|
28
|
+
|
|
32
29
|
/**
|
|
33
30
|
* The maximum zoom level for this tile overlay.
|
|
34
31
|
*
|
|
35
32
|
*/
|
|
36
33
|
maximumZ: PropTypes.number,
|
|
37
34
|
|
|
35
|
+
/**
|
|
36
|
+
* (Optional) The maximum native zoom level for this tile overlay. Tiles are auto-scaled for higher
|
|
37
|
+
* zoom levels.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
maximumNativeZ: PropTypes.number,
|
|
41
|
+
|
|
38
42
|
/**
|
|
39
43
|
* The minimum zoom level for this tile overlay.
|
|
40
44
|
*
|
|
@@ -47,15 +51,54 @@ const propTypes = {
|
|
|
47
51
|
* @platform ios
|
|
48
52
|
*/
|
|
49
53
|
shouldReplaceMapContent: PropTypes.bool,
|
|
54
|
+
|
|
50
55
|
/**
|
|
51
|
-
*
|
|
56
|
+
* (Optional) Tile size only, default size is 256 (for tiles of 256 * 256 pixels)
|
|
52
57
|
*
|
|
53
58
|
*/
|
|
54
59
|
tileSize: PropTypes.number,
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
|
-
* opacity. between 0 - 1
|
|
58
62
|
*
|
|
63
|
+
* Allow tiles using the TMS coordinate system (origin bottom left)
|
|
64
|
+
* to be used, and displayed at their correct coordinates
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
flipY: PropTypes.bool,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* (Optional) Enable caching of tiles in the specified directory. Directory
|
|
72
|
+
* can be specified either as a normal path or in URL format (file://). Tiles
|
|
73
|
+
* are stored in tileCachePath directory as follows "/{z}/{x}/{y}" i.e. in
|
|
74
|
+
* sub-directories 2-levels deep, filename tile y-coordinate without any
|
|
75
|
+
* filetype-extension.
|
|
76
|
+
* NB! All cache management needs to be implemented by client e.g. deleting tiles
|
|
77
|
+
* to manage use of storage space etc.
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
tileCachePath: PropTypes.string,
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* (Optional) Defines how maximum age in seconds for cached tile before they
|
|
84
|
+
* are refreshed. NB! Refresh logic is "serve-stale-while-refresh" i.e. to
|
|
85
|
+
* ensure map availability a stale (over max age) tile is served while a tile
|
|
86
|
+
* refresh process is started in the background.
|
|
87
|
+
*/
|
|
88
|
+
tileCacheMaxAge: PropTypes.number,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* (Optional) Sets offline-mode. In offline-mode tiles are not fetched from
|
|
92
|
+
* the tile servers, rather only tiles stored in the cache directory are used.
|
|
93
|
+
* Furthermore automated tile scaling is activated: if tile at a desired zoom
|
|
94
|
+
* level is not found from the cache directory, then lower zoom level tile is
|
|
95
|
+
* used (until minimumZ) and scaled.
|
|
96
|
+
*/
|
|
97
|
+
offlineMode: PropTypes.bool,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* (Optional) Map layer opacity. Value between 0 - 1, with 0 meaning fully
|
|
101
|
+
* transparent.
|
|
59
102
|
*/
|
|
60
103
|
opacity: PropTypes.number,
|
|
61
104
|
};
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
@property (nonatomic, assign) NSInteger zIndex;
|
|
37
37
|
@property (nonatomic, assign) double opacity;
|
|
38
38
|
@property (nonatomic, assign) BOOL draggable;
|
|
39
|
+
@property (nonatomic, assign) BOOL tappable;
|
|
39
40
|
@property (nonatomic, assign) BOOL tracksViewChanges;
|
|
40
41
|
@property (nonatomic, assign) BOOL tracksInfoWindowChanges;
|
|
41
42
|
|
|
@@ -391,6 +391,14 @@ CGRect unionRect(CGRect a, CGRect b) {
|
|
|
391
391
|
return _realMarker.draggable;
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
+
- (void)setTappable:(BOOL)tappable {
|
|
395
|
+
_realMarker.tappable = tappable;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
- (BOOL)tappable {
|
|
399
|
+
return _realMarker.tappable;
|
|
400
|
+
}
|
|
401
|
+
|
|
394
402
|
- (void)setFlat:(BOOL)flat {
|
|
395
403
|
_realMarker.flat = flat;
|
|
396
404
|
}
|
|
@@ -44,6 +44,7 @@ RCT_EXPORT_VIEW_PROPERTY(anchor, CGPoint)
|
|
|
44
44
|
RCT_EXPORT_VIEW_PROPERTY(calloutAnchor, CGPoint)
|
|
45
45
|
RCT_EXPORT_VIEW_PROPERTY(zIndex, NSInteger)
|
|
46
46
|
RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
|
|
47
|
+
RCT_EXPORT_VIEW_PROPERTY(tappable, BOOL)
|
|
47
48
|
RCT_EXPORT_VIEW_PROPERTY(flat, BOOL)
|
|
48
49
|
RCT_EXPORT_VIEW_PROPERTY(tracksViewChanges, BOOL)
|
|
49
50
|
RCT_EXPORT_VIEW_PROPERTY(tracksInfoWindowChanges, BOOL)
|
|
@@ -734,7 +734,11 @@ RCT_EXPORT_METHOD(getAddressFromCoordinates:(nonnull NSNumber *)reactTag
|
|
|
734
734
|
if (CGPathContainsPoint(mpr, NULL, mapPointAsCGP, FALSE)) {
|
|
735
735
|
id event = @{
|
|
736
736
|
@"action": @"polygon-press",
|
|
737
|
-
|
|
737
|
+
@"coordinate": @{
|
|
738
|
+
@"latitude": @(tapCoordinate.latitude),
|
|
739
|
+
@"longitude": @(tapCoordinate.longitude),
|
|
740
|
+
},
|
|
741
|
+
};
|
|
738
742
|
polygon.onPress(event);
|
|
739
743
|
}
|
|
740
744
|
|
|
@@ -1018,6 +1022,7 @@ static int kDragCenterContext;
|
|
|
1018
1022
|
@"accuracy": @(location.location.horizontalAccuracy),
|
|
1019
1023
|
@"altitudeAccuracy": @(location.location.verticalAccuracy),
|
|
1020
1024
|
@"speed": @(location.location.speed),
|
|
1025
|
+
@"heading": @(location.location.course),
|
|
1021
1026
|
}
|
|
1022
1027
|
};
|
|
1023
1028
|
|
|
@@ -45,6 +45,7 @@ RCT_EXPORT_VIEW_PROPERTY(pinColor, UIColor)
|
|
|
45
45
|
RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
|
|
46
46
|
RCT_EXPORT_VIEW_PROPERTY(zIndex, NSInteger)
|
|
47
47
|
RCT_EXPORT_VIEW_PROPERTY(opacity, double)
|
|
48
|
+
RCT_EXPORT_VIEW_PROPERTY(isPreselected, BOOL)
|
|
48
49
|
|
|
49
50
|
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
|
|
50
51
|
RCT_EXPORT_VIEW_PROPERTY(onSelect, RCTDirectEventBlock)
|
|
@@ -15,19 +15,37 @@
|
|
|
15
15
|
#import "AIRMapCoordinate.h"
|
|
16
16
|
#import "AIRMap.h"
|
|
17
17
|
#import "RCTConvert+AirMap.h"
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
#import "AIRMapUrlTileCachedOverlay.h"
|
|
19
|
+
|
|
20
|
+
@interface AIRMapUrlTile : MKAnnotationView <MKOverlay> {
|
|
21
|
+
BOOL _urlTemplateSet;
|
|
22
|
+
BOOL _tileSizeSet;
|
|
23
|
+
BOOL _flipYSet;
|
|
24
|
+
BOOL _tileCachePathSet;
|
|
25
|
+
BOOL _tileCacheMaxAgeSet;
|
|
26
|
+
BOOL _maximumNativeZSet;
|
|
27
|
+
BOOL _cachedOverlayCreated;
|
|
28
|
+
BOOL _opacitySet;
|
|
29
|
+
}
|
|
20
30
|
|
|
21
31
|
@property (nonatomic, weak) AIRMap *map;
|
|
22
32
|
|
|
23
|
-
@property (nonatomic, strong)
|
|
33
|
+
@property (nonatomic, strong) AIRMapUrlTileCachedOverlay *tileOverlay;
|
|
24
34
|
@property (nonatomic, strong) MKTileOverlayRenderer *renderer;
|
|
25
35
|
@property (nonatomic, copy) NSString *urlTemplate;
|
|
26
36
|
@property NSInteger maximumZ;
|
|
37
|
+
@property NSInteger maximumNativeZ;
|
|
27
38
|
@property NSInteger minimumZ;
|
|
28
39
|
@property BOOL flipY;
|
|
29
40
|
@property BOOL shouldReplaceMapContent;
|
|
30
|
-
@property
|
|
41
|
+
@property NSInteger tileSize;
|
|
42
|
+
@property (nonatomic, copy) NSString *tileCachePath;
|
|
43
|
+
@property NSInteger tileCacheMaxAge;
|
|
44
|
+
@property BOOL offlineMode;
|
|
45
|
+
@property CGFloat opacity;
|
|
46
|
+
|
|
47
|
+
- (void)updateProperties;
|
|
48
|
+
- (void)update;
|
|
31
49
|
|
|
32
50
|
#pragma mark MKOverlay protocol
|
|
33
51
|
|
|
@@ -8,66 +8,151 @@
|
|
|
8
8
|
|
|
9
9
|
#import "AIRMapUrlTile.h"
|
|
10
10
|
#import <React/UIView+React.h>
|
|
11
|
+
#import "AIRMapUrlTileCachedOverlay.h"
|
|
11
12
|
|
|
12
|
-
@implementation AIRMapUrlTile
|
|
13
|
-
BOOL _urlTemplateSet;
|
|
14
|
-
BOOL _tileSizeSet;
|
|
15
|
-
}
|
|
13
|
+
@implementation AIRMapUrlTile
|
|
16
14
|
|
|
17
15
|
- (void)setShouldReplaceMapContent:(BOOL)shouldReplaceMapContent
|
|
18
16
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
_shouldReplaceMapContent = shouldReplaceMapContent;
|
|
18
|
+
if (self.tileOverlay) {
|
|
19
|
+
self.tileOverlay.canReplaceMapContent = _shouldReplaceMapContent;
|
|
20
|
+
}
|
|
21
|
+
[self update];
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
- (void)setMaximumZ:(
|
|
24
|
+
- (void)setMaximumZ:(NSInteger)maximumZ
|
|
27
25
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
_maximumZ = maximumZ;
|
|
27
|
+
if (self.tileOverlay) {
|
|
28
|
+
self.tileOverlay.maximumZ = _maximumZ;
|
|
29
|
+
}
|
|
30
|
+
[self update];
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
- (void)
|
|
33
|
+
- (void)setMaximumNativeZ:(NSInteger)maximumNativeZ
|
|
36
34
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
_maximumNativeZ = maximumNativeZ;
|
|
36
|
+
_maximumNativeZSet = YES;
|
|
37
|
+
if (_cachedOverlayCreated) {
|
|
38
|
+
self.tileOverlay.maximumNativeZ = _maximumNativeZ;
|
|
39
|
+
} else {
|
|
40
|
+
[self createTileOverlayAndRendererIfPossible];
|
|
41
|
+
}
|
|
42
|
+
[self update];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
- (void)setMinimumZ:(NSInteger)minimumZ
|
|
46
|
+
{
|
|
47
|
+
_minimumZ = minimumZ;
|
|
48
|
+
if (self.tileOverlay) {
|
|
49
|
+
self.tileOverlay.minimumZ = _minimumZ;
|
|
50
|
+
}
|
|
51
|
+
[self update];
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
- (void)setFlipY:(BOOL)flipY
|
|
45
55
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
self.tileOverlay
|
|
49
|
-
|
|
56
|
+
_flipY = flipY;
|
|
57
|
+
_flipYSet = YES;
|
|
58
|
+
if (self.tileOverlay) {
|
|
59
|
+
self.tileOverlay.geometryFlipped = _flipY;
|
|
60
|
+
}
|
|
61
|
+
[self update];
|
|
50
62
|
}
|
|
51
63
|
|
|
52
|
-
- (void)setUrlTemplate:(NSString *)urlTemplate
|
|
64
|
+
- (void)setUrlTemplate:(NSString *)urlTemplate
|
|
65
|
+
{
|
|
53
66
|
_urlTemplate = urlTemplate;
|
|
54
67
|
_urlTemplateSet = YES;
|
|
55
68
|
[self createTileOverlayAndRendererIfPossible];
|
|
56
69
|
[self update];
|
|
57
70
|
}
|
|
58
71
|
|
|
59
|
-
- (void)setTileSize:(
|
|
72
|
+
- (void)setTileSize:(NSInteger)tileSize
|
|
73
|
+
{
|
|
60
74
|
_tileSize = tileSize;
|
|
61
75
|
_tileSizeSet = YES;
|
|
62
76
|
[self createTileOverlayAndRendererIfPossible];
|
|
63
77
|
[self update];
|
|
64
78
|
}
|
|
65
79
|
|
|
66
|
-
- (void)
|
|
80
|
+
- (void)setTileCachePath:(NSString *)tileCachePath{
|
|
81
|
+
if (!tileCachePath) return;
|
|
82
|
+
_tileCachePath = tileCachePath;
|
|
83
|
+
_tileCachePathSet = YES;
|
|
84
|
+
[self createTileOverlayAndRendererIfPossible];
|
|
85
|
+
[self update];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (void)setTileCacheMaxAge:(NSInteger)tileCacheMaxAge{
|
|
89
|
+
_tileCacheMaxAge = tileCacheMaxAge;
|
|
90
|
+
_tileCacheMaxAgeSet = YES;
|
|
91
|
+
if (_cachedOverlayCreated) {
|
|
92
|
+
self.tileOverlay.tileCacheMaxAge = _tileCacheMaxAge;
|
|
93
|
+
} else {
|
|
94
|
+
[self createTileOverlayAndRendererIfPossible];
|
|
95
|
+
}
|
|
96
|
+
[self update];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (void)setOfflineMode:(BOOL)offlineMode
|
|
100
|
+
{
|
|
101
|
+
_offlineMode = offlineMode;
|
|
102
|
+
if (_cachedOverlayCreated) {
|
|
103
|
+
self.tileOverlay.offlineMode = _offlineMode;
|
|
104
|
+
}
|
|
105
|
+
if (self.renderer) [self.renderer reloadData];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (void)setOpacity:(CGFloat)opacity
|
|
109
|
+
{
|
|
110
|
+
_opacity = opacity;
|
|
111
|
+
_opacitySet = YES;
|
|
112
|
+
if (self.renderer) {
|
|
113
|
+
self.renderer.alpha = opacity;
|
|
114
|
+
} else {
|
|
115
|
+
[self createTileOverlayAndRendererIfPossible];
|
|
116
|
+
}
|
|
117
|
+
[self update];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (void)createTileOverlayAndRendererIfPossible
|
|
67
121
|
{
|
|
68
122
|
if (!_urlTemplateSet) return;
|
|
69
|
-
|
|
123
|
+
if (_tileCachePathSet || _maximumNativeZSet) {
|
|
124
|
+
NSLog(@"tileCache dir %@", _tileCachePath);
|
|
125
|
+
self.tileOverlay = [[AIRMapUrlTileCachedOverlay alloc] initWithURLTemplate:self.urlTemplate];
|
|
126
|
+
_cachedOverlayCreated = YES;
|
|
127
|
+
if (_tileCachePathSet) {
|
|
128
|
+
NSURL *urlPath = [NSURL URLWithString:[self.tileCachePath stringByAppendingString:@"/"]];
|
|
129
|
+
if (urlPath.fileURL) {
|
|
130
|
+
self.tileOverlay.tileCachePath = urlPath;
|
|
131
|
+
} else {
|
|
132
|
+
NSURL *filePath = [NSURL fileURLWithPath:self.tileCachePath isDirectory:YES];
|
|
133
|
+
self.tileOverlay.tileCachePath = filePath;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (_tileCacheMaxAgeSet) {
|
|
137
|
+
self.tileOverlay.tileCacheMaxAge = self.tileCacheMaxAge;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
NSLog(@"tileCache normal overlay");
|
|
142
|
+
self.tileOverlay = [[MKTileOverlay alloc] initWithURLTemplate:self.urlTemplate];
|
|
143
|
+
_cachedOverlayCreated = NO;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
[self updateProperties];
|
|
70
147
|
|
|
148
|
+
self.renderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:self.tileOverlay];
|
|
149
|
+
if (_opacitySet) {
|
|
150
|
+
self.renderer.alpha = self.opacity;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
- (void)updateProperties
|
|
155
|
+
{
|
|
71
156
|
self.tileOverlay.canReplaceMapContent = self.shouldReplaceMapContent;
|
|
72
157
|
|
|
73
158
|
if(self.minimumZ) {
|
|
@@ -76,16 +161,21 @@
|
|
|
76
161
|
if (self.maximumZ) {
|
|
77
162
|
self.tileOverlay.maximumZ = self.maximumZ;
|
|
78
163
|
}
|
|
79
|
-
if (self.
|
|
164
|
+
if (_cachedOverlayCreated && self.maximumNativeZ) {
|
|
165
|
+
self.tileOverlay.maximumNativeZ = self.maximumNativeZ;
|
|
166
|
+
}
|
|
167
|
+
if (_flipYSet) {
|
|
80
168
|
self.tileOverlay.geometryFlipped = self.flipY;
|
|
81
169
|
}
|
|
82
170
|
if (_tileSizeSet) {
|
|
83
171
|
self.tileOverlay.tileSize = CGSizeMake(self.tileSize, self.tileSize);
|
|
84
172
|
}
|
|
85
|
-
|
|
173
|
+
if (_cachedOverlayCreated && self.offlineMode) {
|
|
174
|
+
self.tileOverlay.offlineMode = self.offlineMode;
|
|
175
|
+
}
|
|
86
176
|
}
|
|
87
177
|
|
|
88
|
-
- (void)
|
|
178
|
+
- (void)update
|
|
89
179
|
{
|
|
90
180
|
if (!_renderer) return;
|
|
91
181
|
|
|
@@ -103,12 +193,12 @@
|
|
|
103
193
|
|
|
104
194
|
#pragma mark MKOverlay implementation
|
|
105
195
|
|
|
106
|
-
- (CLLocationCoordinate2D)
|
|
196
|
+
- (CLLocationCoordinate2D)coordinate
|
|
107
197
|
{
|
|
108
198
|
return self.tileOverlay.coordinate;
|
|
109
199
|
}
|
|
110
200
|
|
|
111
|
-
- (MKMapRect)
|
|
201
|
+
- (MKMapRect)boundingMapRect
|
|
112
202
|
{
|
|
113
203
|
return self.tileOverlay.boundingMapRect;
|
|
114
204
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AIRMapUrlTileCachedOverlay.h
|
|
3
|
+
// Airmaps
|
|
4
|
+
//
|
|
5
|
+
// Created by Markus Suomi on 10/04/2021.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <MapKit/MapKit.h>
|
|
9
|
+
|
|
10
|
+
@interface AIRMapUrlTileCachedOverlay : MKTileOverlay
|
|
11
|
+
|
|
12
|
+
@property NSInteger maximumNativeZ;
|
|
13
|
+
@property (nonatomic, copy) NSURL *tileCachePath;
|
|
14
|
+
@property NSInteger tileCacheMaxAge;
|
|
15
|
+
@property BOOL offlineMode;
|
|
16
|
+
|
|
17
|
+
@end
|