react-native-maps 0.29.4 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +8 -1
  3. package/docs/geojson.md +5 -3
  4. package/docs/installation.md +1 -1
  5. package/docs/marker.md +1 -0
  6. package/docs/tiles.md +35 -0
  7. package/index.d.ts +25 -10
  8. package/index.js +1 -3
  9. package/lib/android/build.gradle +3 -1
  10. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +515 -0
  11. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileWorker.java +122 -0
  12. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java +124 -55
  13. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTileManager.java +34 -0
  14. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +6 -1
  15. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTile.java +31 -87
  16. package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTileManager.java +22 -2
  17. package/lib/components/AnimatedRegion.js +64 -101
  18. package/lib/components/Geojson.js +66 -39
  19. package/lib/components/MapCircle.js +1 -1
  20. package/lib/components/MapHeatmap.js +2 -2
  21. package/lib/components/MapMarker.js +4 -2
  22. package/lib/components/MapPolygon.js +1 -1
  23. package/lib/components/MapPolyline.js +1 -1
  24. package/lib/components/MapUrlTile.js +54 -2
  25. package/lib/components/MapView.js +4 -4
  26. package/lib/components/MapWMSTile.js +49 -2
  27. package/lib/components/decorateMapComponent.js +1 -1
  28. package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h +1 -0
  29. package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m +8 -0
  30. package/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +1 -0
  31. package/lib/ios/AirMaps/AIRMapManager.m +6 -1
  32. package/lib/ios/AirMaps/AIRMapMarkerManager.m +1 -0
  33. package/lib/ios/AirMaps/AIRMapUrlTile.h +22 -4
  34. package/lib/ios/AirMaps/AIRMapUrlTile.m +124 -34
  35. package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.h +17 -0
  36. package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.m +235 -0
  37. package/lib/ios/AirMaps/AIRMapUrlTileManager.m +6 -1
  38. package/lib/ios/AirMaps/AIRMapWMSTile.h +10 -16
  39. package/lib/ios/AirMaps/AIRMapWMSTile.m +68 -101
  40. package/lib/ios/AirMaps/AIRMapWMSTileManager.m +6 -1
  41. package/lib/ios/AirMaps.xcodeproj/project.pbxproj +7 -1
  42. package/package.json +4 -3
  43. package/react-native-google-maps.podspec +2 -2
@@ -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,7 +3,7 @@
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.0",
7
7
  "scripts": {
8
8
  "lint": "./node_modules/eslint/bin/eslint.js .",
9
9
  "ci": "npm run lint"
@@ -27,8 +27,9 @@
27
27
  "react-native-web": ">= 0.11"
28
28
  },
29
29
  "devDependencies": {
30
- "@react-native-community/eslint-config": "0.0.5",
31
- "eslint": "5.16.0"
30
+ "@react-native-community/eslint-config": "3.0.1",
31
+ "eslint": "7.32.0",
32
+ "typescript": "^4.4.3"
32
33
  },
33
34
  "dependencies": {
34
35
  "@types/geojson": "^7946.0.7"
@@ -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