forked from react-native-maps/react-native-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS google maps custom tile support (react-native-maps#770)
- Loading branch information
Showing
10 changed files
with
139 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// AIRGoogleMapURLTileManager.m | ||
// Created by Nick Italiano on 11/5/16. | ||
// | ||
|
||
#import "AIRGoogleMapUrlTileManager.h" | ||
#import "AIRGoogleMapUrlTile.h" | ||
|
||
@interface AIRGoogleMapUrlTileManager() | ||
|
||
@end | ||
|
||
@implementation AIRGoogleMapUrlTileManager | ||
|
||
RCT_EXPORT_MODULE() | ||
|
||
- (UIView *)view | ||
{ | ||
AIRGoogleMapUrlTile *tileLayer = [AIRGoogleMapUrlTile new]; | ||
return tileLayer; | ||
} | ||
|
||
RCT_EXPORT_VIEW_PROPERTY(urlTemplate, NSString) | ||
RCT_EXPORT_VIEW_PROPERTY(zIndex, int) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// AIRGoogleMapURLTile.h | ||
// Created by Nick Italiano on 11/5/16. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <GoogleMaps/GoogleMaps.h> | ||
|
||
@interface AIRGoogleMapUrlTile : UIView | ||
|
||
@property (nonatomic, strong) GMSURLTileLayer *tileLayer; | ||
@property (nonatomic, assign) NSString *urlTemplate; | ||
@property (nonatomic, assign) int zIndex; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// AIRGoogleMapURLTile.m | ||
// Created by Nick Italiano on 11/5/16. | ||
// | ||
|
||
#import "AIRGoogleMapUrlTile.h" | ||
|
||
@implementation AIRGoogleMapUrlTile | ||
|
||
- (void)setZIndex:(int)zIndex | ||
{ | ||
_zIndex = zIndex; | ||
_tileLayer.zIndex = zIndex; | ||
} | ||
|
||
- (void)setUrlTemplate:(NSString *)urlTemplate | ||
{ | ||
_urlTemplate = urlTemplate; | ||
_tileLayer = [GMSURLTileLayer tileLayerWithURLConstructor:[self _getTileURLConstructor]]; | ||
} | ||
|
||
- (GMSTileURLConstructor)_getTileURLConstructor | ||
{ | ||
NSString *urlTemplate = self.urlTemplate; | ||
GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) { | ||
NSString *url = urlTemplate; | ||
url = [url stringByReplacingOccurrencesOfString:@"{x}" withString:[NSString stringWithFormat: @"%ld", (long)x]]; | ||
url = [url stringByReplacingOccurrencesOfString:@"{y}" withString:[NSString stringWithFormat: @"%ld", (long)y]]; | ||
url = [url stringByReplacingOccurrencesOfString:@"{z}" withString:[NSString stringWithFormat: @"%ld", (long)zoom]]; | ||
return [NSURL URLWithString:url]; | ||
}; | ||
return urls; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// AIRGoogleMapURLTileManager.h | ||
// Created by Nick Italiano on 11/5/16. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "RCTViewManager.h" | ||
|
||
@interface AIRGoogleMapUrlTileManager : RCTViewManager | ||
@end |