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
|
@@ -28,12 +28,20 @@ const propTypes = {
|
|
|
28
28
|
* @platform android
|
|
29
29
|
*/
|
|
30
30
|
zIndex: PropTypes.number,
|
|
31
|
+
|
|
31
32
|
/**
|
|
32
33
|
* The maximum zoom level for this tile overlay.
|
|
33
34
|
*
|
|
34
35
|
*/
|
|
35
36
|
maximumZ: PropTypes.number,
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
* (Optional) The maximum native zoom level for this tile overlay. Tiles are auto-scaled for higher
|
|
40
|
+
* zoom levels.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
maximumNativeZ: PropTypes.number,
|
|
44
|
+
|
|
37
45
|
/**
|
|
38
46
|
* The minimum zoom level for this tile overlay.
|
|
39
47
|
*
|
|
@@ -48,12 +56,20 @@ const propTypes = {
|
|
|
48
56
|
shouldReplaceMapContent: PropTypes.bool,
|
|
49
57
|
|
|
50
58
|
/**
|
|
51
|
-
* (Optional) Tile size
|
|
59
|
+
* (Optional) Tile size only, default size is 256 (for tiles of 256 * 256 pixels)
|
|
52
60
|
*
|
|
53
|
-
* @platform ios
|
|
54
61
|
*/
|
|
55
62
|
tileSize: PropTypes.number,
|
|
56
63
|
|
|
64
|
+
/**
|
|
65
|
+
* (Optional) Doubles tile size from 256 to 512 utilising higher zoom levels i.e.
|
|
66
|
+
* loading 4 higher zoom level tiles and combining them for one high-resolution
|
|
67
|
+
* tile. iOS does this automatically, even if it is not desirable always.
|
|
68
|
+
*
|
|
69
|
+
* @platform android
|
|
70
|
+
*/
|
|
71
|
+
doubleTileSize: PropTypes.bool,
|
|
72
|
+
|
|
57
73
|
/**
|
|
58
74
|
*
|
|
59
75
|
* Allow tiles using the TMS coordinate system (origin bottom left)
|
|
@@ -61,6 +77,42 @@ const propTypes = {
|
|
|
61
77
|
*
|
|
62
78
|
*/
|
|
63
79
|
flipY: PropTypes.bool,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* (Optional) Enable caching of tiles in the specified directory. Directory
|
|
84
|
+
* can be specified either as a normal path or in URL format (file://). Tiles
|
|
85
|
+
* are stored in tileCachePath directory as follows "/{z}/{x}/{y}" i.e. in
|
|
86
|
+
* sub-directories 2-levels deep, filename tile y-coordinate without any
|
|
87
|
+
* filetype-extension.
|
|
88
|
+
* NB! All cache management needs to be implemented by client e.g. deleting tiles
|
|
89
|
+
* to manage use of storage space etc.
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
tileCachePath: PropTypes.string,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* (Optional) Defines how maximum age in seconds for cached tile before they
|
|
96
|
+
* are refreshed. NB! Refresh logic is "serve-stale-while-refresh" i.e. to
|
|
97
|
+
* ensure map availability a stale (over max age) tile is served while a tile
|
|
98
|
+
* refresh process is started in the background.
|
|
99
|
+
*/
|
|
100
|
+
tileCacheMaxAge: PropTypes.number,
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* (Optional) Sets offline-mode. In offline-mode tiles are not fetched from
|
|
104
|
+
* the tile servers, rather only tiles stored in the cache directory are used.
|
|
105
|
+
* Furthermore automated tile scaling is activated: if tile at a desired zoom
|
|
106
|
+
* level is not found from the cache directory, then lower zoom level tile is
|
|
107
|
+
* used (until minimumZ) and scaled.
|
|
108
|
+
*/
|
|
109
|
+
offlineMode: PropTypes.bool,
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* (Optional) Map layer opacity. Value between 0 - 1, with 0 meaning fully
|
|
113
|
+
* transparent.
|
|
114
|
+
*/
|
|
115
|
+
opacity: PropTypes.number,
|
|
64
116
|
};
|
|
65
117
|
|
|
66
118
|
class MapUrlTile extends React.Component {
|
|
@@ -1042,7 +1042,7 @@ class MapView extends React.Component {
|
|
|
1042
1042
|
if (Platform.OS === 'android' && this.props.liteMode) {
|
|
1043
1043
|
return (
|
|
1044
1044
|
<AIRMapLite
|
|
1045
|
-
ref={ref => {
|
|
1045
|
+
ref={(ref) => {
|
|
1046
1046
|
this.map = ref;
|
|
1047
1047
|
}}
|
|
1048
1048
|
{...props}
|
|
@@ -1054,7 +1054,7 @@ class MapView extends React.Component {
|
|
|
1054
1054
|
|
|
1055
1055
|
return (
|
|
1056
1056
|
<AIRMap
|
|
1057
|
-
ref={ref => {
|
|
1057
|
+
ref={(ref) => {
|
|
1058
1058
|
this.map = ref;
|
|
1059
1059
|
}}
|
|
1060
1060
|
{...props}
|
|
@@ -1069,7 +1069,7 @@ MapView.childContextTypes = childContextTypes;
|
|
|
1069
1069
|
|
|
1070
1070
|
MapView.MAP_TYPES = MAP_TYPES;
|
|
1071
1071
|
|
|
1072
|
-
const nativeComponent = Component =>
|
|
1072
|
+
const nativeComponent = (Component) =>
|
|
1073
1073
|
requireNativeComponent(Component, MapView, {
|
|
1074
1074
|
nativeOnly: {
|
|
1075
1075
|
onChange: true,
|
|
@@ -1090,7 +1090,7 @@ if (Platform.OS === 'android') {
|
|
|
1090
1090
|
'react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS.'
|
|
1091
1091
|
);
|
|
1092
1092
|
}
|
|
1093
|
-
const getAirMapComponent = provider => airMaps[provider || 'default'];
|
|
1093
|
+
const getAirMapComponent = (provider) => airMaps[provider || 'default'];
|
|
1094
1094
|
|
|
1095
1095
|
let AIRMapLite;
|
|
1096
1096
|
if (!NativeModules.UIManager.getViewManagerConfig) {
|
|
@@ -29,12 +29,20 @@ const propTypes = {
|
|
|
29
29
|
* @platform android
|
|
30
30
|
*/
|
|
31
31
|
zIndex: PropTypes.number,
|
|
32
|
+
|
|
32
33
|
/**
|
|
33
34
|
* The maximum zoom level for this tile overlay.
|
|
34
35
|
*
|
|
35
36
|
*/
|
|
36
37
|
maximumZ: PropTypes.number,
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* (Optional) The maximum native zoom level for this tile overlay. Tiles are auto-scaled for higher
|
|
41
|
+
* zoom levels.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
maximumNativeZ: PropTypes.number,
|
|
45
|
+
|
|
38
46
|
/**
|
|
39
47
|
* The minimum zoom level for this tile overlay.
|
|
40
48
|
*
|
|
@@ -47,15 +55,54 @@ const propTypes = {
|
|
|
47
55
|
* @platform ios
|
|
48
56
|
*/
|
|
49
57
|
shouldReplaceMapContent: PropTypes.bool,
|
|
58
|
+
|
|
50
59
|
/**
|
|
51
|
-
*
|
|
60
|
+
* (Optional) Tile size only, default size is 256 (for tiles of 256 * 256 pixels)
|
|
52
61
|
*
|
|
53
62
|
*/
|
|
54
63
|
tileSize: PropTypes.number,
|
|
55
64
|
|
|
56
65
|
/**
|
|
57
|
-
* opacity. between 0 - 1
|
|
58
66
|
*
|
|
67
|
+
* Allow tiles using the TMS coordinate system (origin bottom left)
|
|
68
|
+
* to be used, and displayed at their correct coordinates
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
flipY: PropTypes.bool,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* (Optional) Enable caching of tiles in the specified directory. Directory
|
|
76
|
+
* can be specified either as a normal path or in URL format (file://). Tiles
|
|
77
|
+
* are stored in tileCachePath directory as follows "/{z}/{x}/{y}" i.e. in
|
|
78
|
+
* sub-directories 2-levels deep, filename tile y-coordinate without any
|
|
79
|
+
* filetype-extension.
|
|
80
|
+
* NB! All cache management needs to be implemented by client e.g. deleting tiles
|
|
81
|
+
* to manage use of storage space etc.
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
tileCachePath: PropTypes.string,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* (Optional) Defines how maximum age in seconds for cached tile before they
|
|
88
|
+
* are refreshed. NB! Refresh logic is "serve-stale-while-refresh" i.e. to
|
|
89
|
+
* ensure map availability a stale (over max age) tile is served while a tile
|
|
90
|
+
* refresh process is started in the background.
|
|
91
|
+
*/
|
|
92
|
+
tileCacheMaxAge: PropTypes.number,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* (Optional) Sets offline-mode. In offline-mode tiles are not fetched from
|
|
96
|
+
* the tile servers, rather only tiles stored in the cache directory are used.
|
|
97
|
+
* Furthermore automated tile scaling is activated: if tile at a desired zoom
|
|
98
|
+
* level is not found from the cache directory, then lower zoom level tile is
|
|
99
|
+
* used (until minimumZ) and scaled.
|
|
100
|
+
*/
|
|
101
|
+
offlineMode: PropTypes.bool,
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* (Optional) Map layer opacity. Value between 0 - 1, with 0 meaning fully
|
|
105
|
+
* transparent.
|
|
59
106
|
*/
|
|
60
107
|
opacity: PropTypes.number,
|
|
61
108
|
};
|
|
@@ -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
|