Skip to content

Commit 4b7d01f

Browse files
fozhaochristopherdro
authored andcommitted
Adding tileSize props for iOS. (react-native-maps#2627)
* Adding tileSize props for iOS. * Fixing error for travic CI
1 parent 5b9da4a commit 4b7d01f

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ declare module "react-native-maps" {
387387
urlTemplate: string;
388388
maximumZ?: number;
389389
zIndex?: number;
390+
tileSize?: number;
390391
}
391392

392393
export class UrlTile extends React.Component<MapUrlTileProps, any> {

lib/components/MapUrlTile.js

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ const propTypes = {
4949
* @platform ios
5050
*/
5151
shouldReplaceMapContent: PropTypes.bool,
52+
53+
/**
54+
* (Optional) Tile size for iOS only, default size is 256 * 256.
55+
*
56+
* @platform ios
57+
*/
58+
tileSize: PropTypes.number,
5259
};
5360

5461
class MapUrlTile extends React.Component {

lib/ios/AirMaps/AIRMapUrlTile.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@property NSInteger maximumZ;
2727
@property NSInteger minimumZ;
2828
@property BOOL shouldReplaceMapContent;
29+
@property CGFloat tileSize;
2930

3031
#pragma mark MKOverlay protocol
3132

lib/ios/AirMaps/AIRMapUrlTile.m

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@implementation AIRMapUrlTile {
1313
BOOL _urlTemplateSet;
14+
BOOL _tileSizeSet;
1415
}
1516

1617
- (void)setShouldReplaceMapContent:(BOOL)shouldReplaceMapContent
@@ -47,6 +48,13 @@ - (void)setUrlTemplate:(NSString *)urlTemplate{
4748
[self update];
4849
}
4950

51+
- (void)setTileSize:(CGFloat)tileSize{
52+
_tileSize = tileSize;
53+
_tileSizeSet = YES;
54+
[self createTileOverlayAndRendererIfPossible];
55+
[self update];
56+
}
57+
5058
- (void) createTileOverlayAndRendererIfPossible
5159
{
5260
if (!_urlTemplateSet) return;
@@ -60,6 +68,9 @@ - (void) createTileOverlayAndRendererIfPossible
6068
if (self.maximumZ) {
6169
self.tileOverlay.maximumZ = self.maximumZ;
6270
}
71+
if (_tileSizeSet) {
72+
self.tileOverlay.tileSize = CGSizeMake(self.tileSize, self.tileSize);
73+
}
6374
self.renderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:self.tileOverlay];
6475
}
6576

lib/ios/AirMaps/AIRMapUrlTileManager.m

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ - (UIView *)view
3636
RCT_EXPORT_VIEW_PROPERTY(maximumZ, NSInteger)
3737
RCT_EXPORT_VIEW_PROPERTY(minimumZ, NSInteger)
3838
RCT_EXPORT_VIEW_PROPERTY(shouldReplaceMapContent, BOOL)
39+
RCT_EXPORT_VIEW_PROPERTY(tileSize, CGFloat)
3940

4041
@end

0 commit comments

Comments
 (0)