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.
Files changed (63) hide show
  1. package/README.md +8 -1
  2. package/index.d.ts +25 -10
  3. package/index.js +1 -3
  4. package/lib/android/build.gradle +3 -1
  5. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +515 -0
  6. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileWorker.java +122 -0
  7. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java +124 -55
  8. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTileManager.java +34 -0
  9. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +6 -1
  10. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTile.java +31 -87
  11. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTileManager.java +22 -2
  12. package/lib/components/AnimatedRegion.js +67 -101
  13. package/lib/components/Geojson.js +67 -40
  14. package/lib/components/MapCallout.js +3 -5
  15. package/lib/components/MapCalloutSubview.js +3 -5
  16. package/lib/components/MapCircle.js +6 -6
  17. package/lib/components/MapHeatmap.js +5 -7
  18. package/lib/components/MapLocalTile.js +2 -6
  19. package/lib/components/MapMarker.js +9 -9
  20. package/lib/components/MapOverlay.js +3 -2
  21. package/lib/components/MapPolygon.js +6 -6
  22. package/lib/components/MapPolyline.js +6 -6
  23. package/lib/components/MapUrlTile.js +56 -8
  24. package/lib/components/MapView.js +12 -14
  25. package/lib/components/MapWMSTile.js +51 -8
  26. package/lib/components/decorateMapComponent.js +1 -1
  27. package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h +1 -0
  28. package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m +8 -0
  29. package/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +1 -0
  30. package/lib/ios/AirMaps/AIRMapManager.m +6 -1
  31. package/lib/ios/AirMaps/AIRMapMarkerManager.m +1 -0
  32. package/lib/ios/AirMaps/AIRMapUrlTile.h +22 -4
  33. package/lib/ios/AirMaps/AIRMapUrlTile.m +124 -34
  34. package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.h +17 -0
  35. package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.m +235 -0
  36. package/lib/ios/AirMaps/AIRMapUrlTileManager.m +6 -1
  37. package/lib/ios/AirMaps/AIRMapWMSTile.h +10 -16
  38. package/lib/ios/AirMaps/AIRMapWMSTile.m +68 -101
  39. package/lib/ios/AirMaps/AIRMapWMSTileManager.m +6 -1
  40. package/lib/ios/AirMaps.xcodeproj/project.pbxproj +7 -1
  41. package/package.json +43 -6
  42. package/react-native-google-maps.podspec +2 -2
  43. package/.eslintrc +0 -3
  44. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -111
  45. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -32
  46. package/.github/ISSUE_TEMPLATE.md +0 -5
  47. package/.github/PULL_REQUEST_TEMPLATE.md +0 -53
  48. package/.github/stale.yml +0 -17
  49. package/.github/workflows/base.yml +0 -21
  50. package/.prettierrc +0 -4
  51. package/CHANGELOG.md +0 -761
  52. package/docs/callout.md +0 -38
  53. package/docs/circle.md +0 -28
  54. package/docs/examples-setup.md +0 -17
  55. package/docs/geojson.md +0 -50
  56. package/docs/heatmap.md +0 -32
  57. package/docs/installation.md +0 -347
  58. package/docs/mapview.md +0 -252
  59. package/docs/marker.md +0 -84
  60. package/docs/overlay.md +0 -27
  61. package/docs/polygon.md +0 -34
  62. package/docs/polyline.md +0 -65
  63. package/enable-google-maps +0 -15
@@ -0,0 +1,235 @@
1
+ //
2
+ // AIRMapUrlTileCachedOverlay.m
3
+ // Airmaps
4
+ //
5
+ // Created by Markus Suomi on 10/04/2021.
6
+ //
7
+
8
+ #import "AIRMapUrlTileCachedOverlay.h"
9
+
10
+ @interface AIRMapUrlTileCachedOverlay ()
11
+
12
+ @end
13
+
14
+ @implementation AIRMapUrlTileCachedOverlay {
15
+ CIContext *_ciContext;
16
+ CGColorSpaceRef _colorspace;
17
+ NSURLSession *_urlSession;
18
+ }
19
+
20
+ - (void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result
21
+ {
22
+ if (!result) return;
23
+
24
+ NSInteger maximumZ = self.maximumNativeZ ? self.maximumNativeZ : path.z;
25
+ [self scaleIfNeededLowerZoomTile:path maximumZ:maximumZ result:^(NSData *image, NSError *error) {
26
+ if (!image && self.offlineMode && self.tileCachePath) {
27
+ NSInteger zoomLevelToStart = (path.z > maximumZ) ? maximumZ - 1 : path.z - 1;
28
+ NSInteger minimumZoomToSearch = self.minimumZ >= zoomLevelToStart - 3 ? self.minimumZ : zoomLevelToStart - 3;
29
+ [self findLowerZoomTileAndScale:path tryZ:zoomLevelToStart minZ:minimumZoomToSearch result:result];
30
+ } else {
31
+ result(image, error);
32
+ }
33
+ }];
34
+ }
35
+
36
+ - (void)scaleIfNeededLowerZoomTile:(MKTileOverlayPath)path maximumZ:(NSInteger)maximumZ result:(void (^)(NSData *, NSError *))result
37
+ {
38
+ NSInteger overZoomLevel = path.z - maximumZ;
39
+ if (overZoomLevel <= 0) {
40
+ [self getTileImage:path result:result];
41
+ return;
42
+ }
43
+
44
+ NSInteger zoomFactor = 1 << overZoomLevel;
45
+
46
+ MKTileOverlayPath parentTile;
47
+ parentTile.x = path.x >> overZoomLevel;
48
+ parentTile.y = path.y >> overZoomLevel;
49
+ parentTile.z = path.z - overZoomLevel;
50
+ parentTile.contentScaleFactor = path.contentScaleFactor;
51
+
52
+ NSInteger xOffset = path.x % zoomFactor;
53
+ NSInteger yOffset = path.y % zoomFactor;
54
+ NSInteger subTileSize = self.tileSize.width / zoomFactor;
55
+
56
+ if (!_ciContext) _ciContext = [CIContext context];
57
+ if (!_colorspace) _colorspace = CGColorSpaceCreateDeviceRGB();
58
+
59
+ [self getTileImage:parentTile result:^(NSData *image, NSError *error) {
60
+ if (!image) {
61
+ result(nil, nil);
62
+ return;
63
+ }
64
+
65
+ CIImage* originalCIImage = [CIImage imageWithData:image];
66
+
67
+ CGRect rect;
68
+ rect.origin.x = xOffset * subTileSize;
69
+ rect.origin.y = self.tileSize.width - (yOffset + 1) * subTileSize;
70
+ rect.size.width = subTileSize;
71
+ rect.size.height = subTileSize;
72
+ CIVector *inputRect = [CIVector vectorWithCGRect:rect];
73
+ CIFilter* cropFilter = [CIFilter filterWithName:@"CICrop"];
74
+ [cropFilter setValue:originalCIImage forKey:@"inputImage"];
75
+ [cropFilter setValue:inputRect forKey:@"inputRectangle"];
76
+
77
+ CGAffineTransform trans = CGAffineTransformMakeScale(zoomFactor, zoomFactor);
78
+ CIImage* scaledCIImage = [cropFilter.outputImage imageByApplyingTransform:trans];
79
+
80
+ NSData *finalImage = [_ciContext PNGRepresentationOfImage:scaledCIImage format:kCIFormatABGR8 colorSpace:_colorspace options:nil];
81
+ result(finalImage, nil);
82
+ }];
83
+ }
84
+
85
+ - (void)findLowerZoomTileAndScale:(MKTileOverlayPath)path tryZ:(NSInteger)tryZ minZ:(NSInteger)minZ result:(void (^)(NSData *, NSError *))result
86
+ {
87
+ [self scaleIfNeededLowerZoomTile:path maximumZ:tryZ result:^(NSData *image, NSError *error) {
88
+ if (image) {
89
+ result(image, error);
90
+ } else if (tryZ >= minZ) {
91
+ [self findLowerZoomTileAndScale:path tryZ:tryZ - 1 minZ:minZ result:result];
92
+ } else {
93
+ result(nil, nil);
94
+ }
95
+ }];
96
+ }
97
+
98
+ - (void)getTileImage:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result
99
+ {
100
+ NSData *image;
101
+ NSURL *tileCacheFileDirectory = [NSURL URLWithString:[NSString stringWithFormat:@"%d/%d/", (int)path.z, (int)path.x] relativeToURL:self.tileCachePath];
102
+ NSURL *tileCacheFilePath = [NSURL URLWithString:[NSString stringWithFormat:@"%d", (int)path.y] relativeToURL:tileCacheFileDirectory];
103
+
104
+ if (self.tileCachePath) {
105
+ image = [self readTileImage:path fromFilePath:tileCacheFilePath];
106
+ if (image) {
107
+ result(image, nil);
108
+ if (!self.offlineMode && self.tileCacheMaxAge) {
109
+ [self checkForRefresh:path fromFilePath:tileCacheFilePath];
110
+ }
111
+ }
112
+ }
113
+
114
+ if (!image) {
115
+ if (!self.offlineMode) {
116
+ [self fetchTile:path result:^(NSData *image, NSError *error) {
117
+ result(image, error);
118
+ if (image && self.tileCachePath) {
119
+ [self writeTileImage:tileCacheFileDirectory withTileCacheFilePath:tileCacheFilePath withTileData:image];
120
+ }
121
+ }];
122
+ } else {
123
+ result(nil, nil);
124
+ }
125
+ }
126
+ }
127
+
128
+ - (NSData *)readTileImage:(MKTileOverlayPath)path fromFilePath:(NSURL *)tileCacheFilePath
129
+ {
130
+ NSError *error;
131
+
132
+ if ([[NSFileManager defaultManager] fileExistsAtPath:[tileCacheFilePath path]]) {
133
+ if (!self.tileCacheMaxAge) {
134
+ [[NSFileManager defaultManager] setAttributes:@{NSFileModificationDate:[NSDate date]}
135
+ ofItemAtPath:[tileCacheFilePath path]
136
+ error:&error];
137
+ }
138
+
139
+ NSData *tile = [NSData dataWithContentsOfFile:[tileCacheFilePath path]];
140
+ NSLog(@"tileCache HIT for %d_%d_%d", (int)path.z, (int)path.x, (int)path.y);
141
+ NSLog(@"tileCache HIT, with max age set at %d", self.tileCacheMaxAge);
142
+ return tile;
143
+ } else {
144
+ NSLog(@"tileCache MISS for %d_%d_%d", (int)path.z, (int)path.x, (int)path.y);
145
+ return nil;
146
+ }
147
+ }
148
+
149
+ - (void)fetchTile:(MKTileOverlayPath)path result:(void (^)(NSData *, NSError *))result
150
+ {
151
+ if (!_urlSession) [self createURLSession];
152
+
153
+ [[_urlSession dataTaskWithURL:[self URLForTilePath:path]
154
+ completionHandler:^(NSData *data,
155
+ NSURLResponse *response,
156
+ NSError *error) {
157
+ result(data, error);
158
+ }] resume];
159
+ }
160
+
161
+ - (void)writeTileImage:(NSURL *)tileCacheFileDirectory withTileCacheFilePath:(NSURL *)tileCacheFilePath withTileData:(NSData *)data
162
+ {
163
+ NSError *error;
164
+
165
+ if (![[NSFileManager defaultManager] fileExistsAtPath:[tileCacheFileDirectory path]]) {
166
+ [[NSFileManager defaultManager] createDirectoryAtPath:[tileCacheFileDirectory path] withIntermediateDirectories:YES attributes:nil error:&error];
167
+ if (error) {
168
+ NSLog(@"Error: %@", error);
169
+ return;
170
+ }
171
+ }
172
+
173
+ [[NSFileManager defaultManager] createFileAtPath:[tileCacheFilePath path] contents:data attributes:nil];
174
+ NSLog(@"tileCache SAVED tile %@", [tileCacheFilePath path]);
175
+ }
176
+
177
+ - (void)createTileCacheDirectory
178
+ {
179
+ NSError *error;
180
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
181
+ NSString *documentsDirectory = [paths objectAtIndex:0];
182
+ NSString *tileCacheBaseDirectory = [NSString stringWithFormat:@"%@/tileCache", documentsDirectory];
183
+ self.tileCachePath = [NSURL fileURLWithPath:tileCacheBaseDirectory isDirectory:YES];
184
+
185
+ if (![[NSFileManager defaultManager] fileExistsAtPath:[self.tileCachePath path]])
186
+ [[NSFileManager defaultManager] createDirectoryAtPath:[self.tileCachePath path] withIntermediateDirectories:NO attributes:nil error:&error];
187
+ }
188
+
189
+ - (void)createURLSession
190
+ {
191
+ if (!_urlSession) {
192
+ _urlSession = [NSURLSession sharedSession];
193
+ }
194
+ }
195
+
196
+ - (void)checkForRefresh:(MKTileOverlayPath)path fromFilePath:(NSURL *)tileCacheFilePath
197
+ {
198
+ if ([self doesFileNeedRefresh:path fromFilePath:tileCacheFilePath withMaxAge:self.tileCacheMaxAge]) {
199
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^ {
200
+ // This code runs asynchronously!
201
+ if ([self doesFileNeedRefresh:path fromFilePath:tileCacheFilePath withMaxAge:self.tileCacheMaxAge]) {
202
+ if (!_urlSession) [self createURLSession];
203
+
204
+ [[_urlSession dataTaskWithURL:[self URLForTilePath:path]
205
+ completionHandler:^(NSData *data,
206
+ NSURLResponse *response,
207
+ NSError *error) {
208
+ if (!error) {
209
+ [[NSFileManager defaultManager] createFileAtPath:[tileCacheFilePath path] contents:data attributes:nil];
210
+ NSLog(@"tileCache File refreshed at %@", [tileCacheFilePath path]);
211
+ }
212
+ }] resume];
213
+ }
214
+ });
215
+ }
216
+ }
217
+
218
+ - (BOOL)doesFileNeedRefresh:(MKTileOverlayPath)path fromFilePath:(NSURL *)tileCacheFilePath withMaxAge:(NSInteger)tileCacheMaxAge
219
+ {
220
+ NSError *error;
221
+ NSDictionary<NSFileAttributeKey, id> *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[tileCacheFilePath path] error:&error];
222
+
223
+ if (fileAttributes) {
224
+ NSDate *modificationDate = fileAttributes[@"NSFileModificationDate"];
225
+ if (modificationDate) {
226
+ if (-1 * (int)modificationDate.timeIntervalSinceNow > tileCacheMaxAge) {
227
+ return YES;
228
+ }
229
+ }
230
+ }
231
+
232
+ return NO;
233
+ }
234
+
235
+ @end
@@ -34,9 +34,14 @@ RCT_EXPORT_MODULE()
34
34
 
35
35
  RCT_EXPORT_VIEW_PROPERTY(urlTemplate, NSString)
36
36
  RCT_EXPORT_VIEW_PROPERTY(maximumZ, NSInteger)
37
+ RCT_EXPORT_VIEW_PROPERTY(maximumNativeZ, NSInteger)
37
38
  RCT_EXPORT_VIEW_PROPERTY(minimumZ, NSInteger)
38
39
  RCT_EXPORT_VIEW_PROPERTY(flipY, BOOL)
39
40
  RCT_EXPORT_VIEW_PROPERTY(shouldReplaceMapContent, BOOL)
40
- RCT_EXPORT_VIEW_PROPERTY(tileSize, CGFloat)
41
+ RCT_EXPORT_VIEW_PROPERTY(tileSize, NSInteger)
42
+ RCT_EXPORT_VIEW_PROPERTY(tileCachePath, NSString)
43
+ RCT_EXPORT_VIEW_PROPERTY(tileCacheMaxAge, NSInteger)
44
+ RCT_EXPORT_VIEW_PROPERTY(offlineMode, BOOL)
45
+ RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
41
46
 
42
47
  @end
@@ -16,26 +16,20 @@
16
16
  #import "AIRMapCoordinate.h"
17
17
  #import "AIRMap.h"
18
18
  #import "RCTConvert+AirMap.h"
19
+ #import "AIRMapUrlTile.h"
20
+ #import "AIRMapUrlTileCachedOverlay.h"
19
21
 
20
- @interface AIRMapWMSTile : MKAnnotationView <MKOverlay>
22
+ @interface AIRMapWMSTile : AIRMapUrlTile <MKOverlay>
23
+ @end
21
24
 
22
- @property (nonatomic, weak) AIRMap *map;
25
+ @interface AIRMapWMSTileOverlay : MKTileOverlay
26
+ @end
23
27
 
24
- @property (nonatomic, strong) MKTileOverlay *tileOverlay;
25
- @property (nonatomic, strong) MKTileOverlayRenderer *renderer;
26
- @property (nonatomic, copy) NSString *urlTemplate;
27
- @property NSInteger maximumZ;
28
- @property NSInteger minimumZ;
29
- @property NSInteger tileSize;
30
- @property BOOL shouldReplaceMapContent;
28
+ @interface AIRMapWMSTileCachedOverlay : AIRMapUrlTileCachedOverlay
29
+ @end
31
30
 
32
- #pragma mark MKOverlay protocol
31
+ @interface AIRMapWMSTileHelper : NSObject
33
32
 
34
- @property(nonatomic, readonly) CLLocationCoordinate2D coordinate;
35
- @property(nonatomic, readonly) MKMapRect boundingMapRect;
36
- - (BOOL)canReplaceMapContent;
37
- @end
33
+ + (NSURL *)URLForTilePath:(MKTileOverlayPath)path withURLTemplate:(NSString *)URLTemplate withTileSize:(NSInteger)tileSize;
38
34
 
39
- @interface TileOverlay : MKTileOverlay
40
- @property (nonatomic) double MapX,MapY,FULL;
41
35
  @end
@@ -9,141 +9,108 @@
9
9
  #import "AIRMapWMSTile.h"
10
10
  #import <React/UIView+React.h>
11
11
 
12
- @implementation AIRMapWMSTile {
13
- BOOL _urlTemplateSet;
14
- }
15
-
16
- - (void)setShouldReplaceMapContent:(BOOL)shouldReplaceMapContent
17
- {
18
- _shouldReplaceMapContent = shouldReplaceMapContent;
19
- if(self.tileOverlay) {
20
- self.tileOverlay.canReplaceMapContent = _shouldReplaceMapContent;
21
- }
22
- [self update];
23
- }
24
-
25
- - (void)setMaximumZ:(NSUInteger)maximumZ
12
+ @implementation AIRMapWMSTile
13
+
14
+ - (void)createTileOverlayAndRendererIfPossible
26
15
  {
27
- _maximumZ = maximumZ;
28
- if(self.tileOverlay) {
29
- self.tileOverlay.maximumZ = _maximumZ;
30
- }
31
- [self update];
32
- }
16
+ if (!_urlTemplateSet) return;
17
+ if (_tileCachePathSet || _maximumNativeZSet) {
18
+ NSLog(@"tileCache new overlay dir %@", self.tileCachePath);
19
+ NSLog(@"tileCache %d", _tileCachePathSet);
20
+ NSLog(@"tileCache %d", _maximumNativeZSet);
21
+ self.tileOverlay = [[AIRMapWMSTileCachedOverlay alloc] initWithURLTemplate:self.urlTemplate];
22
+ _cachedOverlayCreated = YES;
23
+ if (_tileCachePathSet) {
24
+ NSURL *urlPath = [NSURL URLWithString:[self.tileCachePath stringByAppendingString:@"/"]];
25
+ if (urlPath.fileURL) {
26
+ self.tileOverlay.tileCachePath = urlPath;
27
+ } else {
28
+ NSURL *filePath = [NSURL fileURLWithPath:self.tileCachePath isDirectory:YES];
29
+ self.tileOverlay.tileCachePath = filePath;
30
+ }
31
+
32
+ if (_tileCacheMaxAgeSet) {
33
+ self.tileOverlay.tileCacheMaxAge = self.tileCacheMaxAge;
34
+ }
35
+ }
36
+ } else {
37
+ NSLog(@"tileCache normal overlay");
38
+ self.tileOverlay = [[AIRMapWMSTileOverlay alloc] initWithURLTemplate:self.urlTemplate];
39
+ _cachedOverlayCreated = NO;
40
+ }
33
41
 
34
- - (void)setMinimumZ:(NSUInteger)minimumZ
35
- {
36
- _minimumZ = minimumZ;
37
- if(self.tileOverlay) {
38
- self.tileOverlay.minimumZ = _minimumZ;
39
- }
40
- [self update];
41
- }
42
+ [self updateProperties];
42
43
 
43
- - (void)setTileSize:(NSInteger)tileSize
44
- {
45
- _tileSize = tileSize;
46
- if(self.tileOverlay) {
47
- self.tileOverlay.tileSize = CGSizeMake(tileSize, tileSize);
44
+ self.renderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:self.tileOverlay];
45
+ if (_opacitySet) {
46
+ self.renderer.alpha = self.opacity;
48
47
  }
49
- [self update];
50
- }
51
- - (void)setUrlTemplate:(NSString *)urlTemplate{
52
- _urlTemplate = urlTemplate;
53
- _urlTemplateSet = YES;
54
- [self createTileOverlayAndRendererIfPossible];
55
- [self update];
56
48
  }
57
49
 
58
- - (void) createTileOverlayAndRendererIfPossible
59
- {
60
- if (!_urlTemplateSet) return;
61
- self.tileOverlay = [[TileOverlay alloc] initWithURLTemplate:self.urlTemplate];
62
- self.tileOverlay.canReplaceMapContent = self.shouldReplaceMapContent;
50
+ @end
63
51
 
64
- if(self.minimumZ) {
65
- self.tileOverlay.minimumZ = self.minimumZ;
66
- }
67
- if (self.maximumZ) {
68
- self.tileOverlay.maximumZ = self.maximumZ;
69
- }
70
- if (self.tileSize) {
71
- self.tileOverlay.tileSize = CGSizeMake(self.tileSize, self.tileSize);;
72
- }
73
- self.renderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:self.tileOverlay];
74
- }
75
52
 
76
- - (void) update
53
+ @implementation AIRMapWMSTileOverlay
54
+
55
+ - (id)initWithURLTemplate:(NSString *)URLTemplate
77
56
  {
78
- if (!_renderer) return;
79
-
80
- if (_map == nil) return;
81
- [_map removeOverlay:self];
82
- [_map addOverlay:self level:MKOverlayLevelAboveLabels];
83
- for (id<MKOverlay> overlay in _map.overlays) {
84
- if ([overlay isKindOfClass:[AIRMapWMSTile class]]) {
85
- continue;
86
- }
87
- [_map removeOverlay:overlay];
88
- [_map addOverlay:overlay];
89
- }
57
+ self = [super initWithURLTemplate:URLTemplate];
58
+ return self;
90
59
  }
91
60
 
92
- #pragma mark MKOverlay implementation
93
-
94
- - (CLLocationCoordinate2D) coordinate
61
+ - (NSURL *)URLForTilePath:(MKTileOverlayPath)path
95
62
  {
96
- return self.tileOverlay.coordinate;
63
+ return [AIRMapWMSTileHelper URLForTilePath:path withURLTemplate:self.URLTemplate withTileSize:self.tileSize.width];
97
64
  }
98
65
 
99
- - (MKMapRect) boundingMapRect
66
+ @end
67
+
68
+
69
+ @implementation AIRMapWMSTileCachedOverlay
70
+
71
+ - (id)initWithURLTemplate:(NSString *)URLTemplate
100
72
  {
101
- return self.tileOverlay.boundingMapRect;
73
+ self = [super initWithURLTemplate:URLTemplate];
74
+ return self;
102
75
  }
103
76
 
104
- - (BOOL)canReplaceMapContent
77
+ - (NSURL *)URLForTilePath:(MKTileOverlayPath)path
105
78
  {
106
- return self.tileOverlay.canReplaceMapContent;
79
+ return [AIRMapWMSTileHelper URLForTilePath:path withURLTemplate:self.URLTemplate withTileSize:self.tileSize.width];
107
80
  }
108
81
 
109
82
  @end
110
83
 
111
- @implementation TileOverlay
112
- @synthesize MapX;
113
- @synthesize MapY;
114
- @synthesize FULL;
115
-
116
- -(id) initWithURLTemplate:(NSString *)URLTemplate {
117
- self = [super initWithURLTemplate:URLTemplate];
118
- MapX = -20037508.34789244;
119
- MapY = 20037508.34789244;
120
- FULL = 20037508.34789244 * 2;
121
- return self ;
122
- }
123
84
 
124
- -(NSURL *)URLForTilePath:(MKTileOverlayPath)path{
85
+ @implementation AIRMapWMSTileHelper
86
+ + (NSURL *)URLForTilePath:(MKTileOverlayPath)path withURLTemplate:(NSString *)URLTemplate withTileSize:(NSInteger)tileSize
87
+ {
125
88
  NSArray *bb = [self getBoundBox:path.x yAxis:path.y zoom:path.z];
126
- NSMutableString *url = [self.URLTemplate mutableCopy];
89
+ NSMutableString *url = [URLTemplate mutableCopy];
127
90
  [url replaceOccurrencesOfString: @"{minX}" withString:[NSString stringWithFormat:@"%@", bb[0]] options:0 range:NSMakeRange(0, url.length)];
128
91
  [url replaceOccurrencesOfString: @"{minY}" withString:[NSString stringWithFormat:@"%@", bb[1]] options:0 range:NSMakeRange(0, url.length)];
129
92
  [url replaceOccurrencesOfString: @"{maxX}" withString:[NSString stringWithFormat:@"%@", bb[2]] options:0 range:NSMakeRange(0, url.length)];
130
93
  [url replaceOccurrencesOfString: @"{maxY}" withString:[NSString stringWithFormat:@"%@", bb[3]] options:0 range:NSMakeRange(0, url.length)];
131
- [url replaceOccurrencesOfString: @"{width}" withString:[NSString stringWithFormat:@"%d", (int)self.tileSize.width] options:0 range:NSMakeRange(0, url.length)];
132
- [url replaceOccurrencesOfString: @"{height}" withString:[NSString stringWithFormat:@"%d", (int)self.tileSize.height] options:0 range:NSMakeRange(0, url.length)];
94
+ [url replaceOccurrencesOfString: @"{width}" withString:[NSString stringWithFormat:@"%d", (int)tileSize] options:0 range:NSMakeRange(0, url.length)];
95
+ [url replaceOccurrencesOfString: @"{height}" withString:[NSString stringWithFormat:@"%d", (int)tileSize] options:0 range:NSMakeRange(0, url.length)];
133
96
  return [NSURL URLWithString:url];
134
97
  }
135
98
 
136
- -(NSArray *)getBoundBox:(NSInteger)x yAxis:(NSInteger)y zoom:(NSInteger)zoom{
99
+ + (NSArray *)getBoundBox:(NSInteger)x yAxis:(NSInteger)y zoom:(NSInteger)zoom
100
+ {
101
+ double MapX = -20037508.34789244;
102
+ double MapY = 20037508.34789244;
103
+ double FULL = 20037508.34789244 * 2;
137
104
  double tile = FULL / pow(2.0, (double)zoom);
138
105
 
139
106
  NSArray *result =[[NSArray alloc] initWithObjects:
140
- [NSNumber numberWithDouble:MapX + (double)x * tile ],
141
- [NSNumber numberWithDouble:MapY - (double)(y+1) * tile ],
142
- [NSNumber numberWithDouble:MapX + (double)(x+1) * tile ],
143
- [NSNumber numberWithDouble:MapY - (double)y * tile ],
107
+ [NSNumber numberWithDouble:MapX + (double)x * tile],
108
+ [NSNumber numberWithDouble:MapY - (double)(y + 1) * tile],
109
+ [NSNumber numberWithDouble:MapX + (double)(x + 1) * tile],
110
+ [NSNumber numberWithDouble:MapY - (double)y * tile],
144
111
  nil];
145
112
 
146
- return result;
147
-
113
+ return result;
148
114
  }
149
- @end
115
+
116
+ @end
@@ -35,8 +35,13 @@ RCT_EXPORT_MODULE()
35
35
 
36
36
  RCT_EXPORT_VIEW_PROPERTY(urlTemplate, NSString)
37
37
  RCT_EXPORT_VIEW_PROPERTY(maximumZ, NSInteger)
38
+ RCT_EXPORT_VIEW_PROPERTY(maximumNativeZ, NSInteger)
38
39
  RCT_EXPORT_VIEW_PROPERTY(minimumZ, NSInteger)
39
- RCT_EXPORT_VIEW_PROPERTY(tileSize, NSInteger)
40
40
  RCT_EXPORT_VIEW_PROPERTY(shouldReplaceMapContent, BOOL)
41
+ RCT_EXPORT_VIEW_PROPERTY(tileSize, NSInteger)
42
+ RCT_EXPORT_VIEW_PROPERTY(tileCachePath, NSString)
43
+ RCT_EXPORT_VIEW_PROPERTY(tileCacheMaxAge, NSInteger)
44
+ RCT_EXPORT_VIEW_PROPERTY(offlineMode, BOOL)
45
+ RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
41
46
 
42
47
  @end
@@ -57,6 +57,7 @@
57
57
  A8494E2E218891180092506D /* AIRGoogleMapWMSTileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A8494E2A218891180092506D /* AIRGoogleMapWMSTileManager.m */; };
58
58
  A8494E2F218891180092506D /* AIRGoogleMapWMSTile.m in Sources */ = {isa = PBXBuildFile; fileRef = A8494E2D218891180092506D /* AIRGoogleMapWMSTile.m */; };
59
59
  B5EA3BA92098E22B000E7AFD /* AIRDummyView.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EA3BA72098E22B000E7AFD /* AIRDummyView.m */; };
60
+ BE2E4EC92621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.m in Sources */ = {isa = PBXBuildFile; fileRef = BE2E4EC82621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.m */; };
60
61
  DA6C26381C9E2AFE0035349F /* AIRMapUrlTile.m in Sources */ = {isa = PBXBuildFile; fileRef = DA6C26371C9E2AFE0035349F /* AIRMapUrlTile.m */; };
61
62
  DA6C263E1C9E324A0035349F /* AIRMapUrlTileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DA6C263D1C9E324A0035349F /* AIRMapUrlTileManager.m */; };
62
63
  /* End PBXBuildFile section */
@@ -175,6 +176,8 @@
175
176
  A8494E2D218891180092506D /* AIRGoogleMapWMSTile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIRGoogleMapWMSTile.m; path = AirGoogleMaps/AIRGoogleMapWMSTile.m; sourceTree = "<group>"; };
176
177
  B5EA3BA72098E22B000E7AFD /* AIRDummyView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIRDummyView.m; path = AirGoogleMaps/AIRDummyView.m; sourceTree = "<group>"; };
177
178
  B5EA3BA82098E22B000E7AFD /* AIRDummyView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIRDummyView.h; path = AirGoogleMaps/AIRDummyView.h; sourceTree = "<group>"; };
179
+ BE2E4EC72621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIRMapUrlTileCachedOverlay.h; path = AirMaps/AIRMapUrlTileCachedOverlay.h; sourceTree = SOURCE_ROOT; };
180
+ BE2E4EC82621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIRMapUrlTileCachedOverlay.m; path = AirMaps/AIRMapUrlTileCachedOverlay.m; sourceTree = SOURCE_ROOT; };
178
181
  DA6C26361C9E2AFE0035349F /* AIRMapUrlTile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIRMapUrlTile.h; sourceTree = "<group>"; };
179
182
  DA6C26371C9E2AFE0035349F /* AIRMapUrlTile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIRMapUrlTile.m; sourceTree = "<group>"; };
180
183
  DA6C263C1C9E324A0035349F /* AIRMapUrlTileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIRMapUrlTileManager.h; sourceTree = "<group>"; };
@@ -214,6 +217,8 @@
214
217
  11FA5C531C4A1296003AC2EE /* AirMaps */ = {
215
218
  isa = PBXGroup;
216
219
  children = (
220
+ BE2E4EC72621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.h */,
221
+ BE2E4EC82621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.m */,
217
222
  1125B2BD1C4AD3DA007D0023 /* AIRMap.h */,
218
223
  1125B2BE1C4AD3DA007D0023 /* AIRMap.m */,
219
224
  1125B2BF1C4AD3DA007D0023 /* AIRMapCallout.h */,
@@ -402,7 +407,7 @@
402
407
  9B9498CE2017EFB800158761 /* AIRGMSMarker.m in Sources */,
403
408
  9B9498D72017EFB800158761 /* AIRGoogleMapManager.m in Sources */,
404
409
  19DABC7F1E7C9D3C00F41150 /* RCTConvert+AirMap.m in Sources */,
405
- A8494E2E218891180092506D /* AIRGoogleMapWMSTileManager.m in Sources */,
410
+ A8494E2E218891180092506D /* AIRGoogleMapWMSTileManager.m in Sources */,
406
411
  8B19A3C82257BBDF00BB8735 /* AIRMapCalloutSubview.m in Sources */,
407
412
  1125B2E51C4AD3DA007D0023 /* AIRMapPolyline.m in Sources */,
408
413
  4C99C9E12226D8C400A8693E /* AIRWeakMapReference.m in Sources */,
@@ -410,6 +415,7 @@
410
415
  9B9498CF2017EFB800158761 /* AIRGMSPolyline.m in Sources */,
411
416
  9B9498D42017EFB800158761 /* RCTConvert+GMSMapViewType.m in Sources */,
412
417
  9B9498D32017EFB800158761 /* AIRGoogleMap.m in Sources */,
418
+ BE2E4EC92621F63C00CC7F2E /* AIRMapUrlTileCachedOverlay.m in Sources */,
413
419
  DA6C263E1C9E324A0035349F /* AIRMapUrlTileManager.m in Sources */,
414
420
  9B9498DB2017EFB800158761 /* AIRGoogleMapMarker.m in Sources */,
415
421
  628F81201FD16DF80058313A /* AIRMapLocalTile.m in Sources */,
package/package.json CHANGED
@@ -3,11 +3,25 @@
3
3
  "description": "React Native Mapview component for iOS + Android",
4
4
  "main": "index.js",
5
5
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
6
- "version": "0.29.4",
6
+ "version": "0.30.2",
7
7
  "scripts": {
8
- "lint": "./node_modules/eslint/bin/eslint.js .",
9
- "ci": "npm run lint"
8
+ "lint": "eslint . --max-warnings 0",
9
+ "test": "jest",
10
+ "prepare": "husky install",
11
+ "release": "semantic-release"
10
12
  },
13
+ "files": [
14
+ "index.d.ts",
15
+ "lib",
16
+ "react-native-google-maps.podspec",
17
+ "react-native-maps.podspec",
18
+ "react-native.config.js",
19
+ "!lib/android/build",
20
+ "!lib/ios/build",
21
+ "!**/__tests__",
22
+ "!**/__fixtures__",
23
+ "!**/__mocks__"
24
+ ],
11
25
  "repository": {
12
26
  "type": "git",
13
27
  "url": "https://github.com/react-native-maps/react-native-maps"
@@ -27,10 +41,33 @@
27
41
  "react-native-web": ">= 0.11"
28
42
  },
29
43
  "devDependencies": {
30
- "@react-native-community/eslint-config": "0.0.5",
31
- "eslint": "5.16.0"
44
+ "@commitlint/cli": "16.2.3",
45
+ "@commitlint/config-conventional": "16.2.1",
46
+ "@react-native-community/eslint-config": "^3.0.1",
47
+ "babel-jest": "^27.3.1",
48
+ "eslint": "7.32.0",
49
+ "husky": "7.0.4",
50
+ "jest": "^27.3.1",
51
+ "react": "^17.0.2",
52
+ "react-native": "^0.66.3",
53
+ "semantic-release": "19.0.2",
54
+ "typescript": "^4.4.3"
32
55
  },
33
56
  "dependencies": {
34
- "@types/geojson": "^7946.0.7"
57
+ "@types/geojson": "^7946.0.7",
58
+ "deprecated-react-native-prop-types": "^2.3.0"
59
+ },
60
+ "jest": {
61
+ "preset": "react-native",
62
+ "testRegex": "<rootDir>/__tests__/.*|(\\.|/)(test|spec)\\.jsx?$",
63
+ "transform": {
64
+ "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
65
+ },
66
+ "moduleFileExtensions": [
67
+ "js"
68
+ ],
69
+ "transformIgnorePatterns": [
70
+ "node_modules/(?!@react-native|react-native)"
71
+ ]
35
72
  }
36
73
  }
@@ -17,6 +17,6 @@ Pod::Spec.new do |s|
17
17
  s.compiler_flags = '-DHAVE_GOOGLE_MAPS=1', '-DHAVE_GOOGLE_MAPS_UTILS=1', '-fno-modules'
18
18
 
19
19
  s.dependency 'React-Core'
20
- s.dependency 'GoogleMaps', '3.5.0'
21
- s.dependency 'Google-Maps-iOS-Utils', '2.1.0'
20
+ s.dependency 'GoogleMaps', '5.1.0'
21
+ s.dependency 'Google-Maps-iOS-Utils', '3.10.3'
22
22
  end
package/.eslintrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@react-native-community"
3
- }