Skip to content

Commit

Permalink
Revert "Modifications/Enhancements to MapView.UrlTile (react-native-m…
Browse files Browse the repository at this point in the history
…aps#2136)"

This reverts commit 67d63ef.
  • Loading branch information
Kammeh committed Apr 12, 2018
1 parent a72966e commit 6ed3b32
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ public synchronized URL getTileUrl(int x, int y, int zoom) {
.replace("{y}", Integer.toString(y))
.replace("{z}", Integer.toString(zoom));
URL url = null;

if(this.maximumZ && zoom > maximumZ) {
return url;
}

if(this.minimumZ && zoom < minimumZ) {
return url;
}

try {
url = new URL(s);
} catch (MalformedURLException e) {
Expand All @@ -56,8 +47,6 @@ public void setUrlTemplate(String urlTemplate) {

private String urlTemplate;
private float zIndex;
private float maximumZ;
private float minimumZ;

public AirMapUrlTile(Context context) {
super(context);
Expand All @@ -80,20 +69,6 @@ public void setZIndex(float zIndex) {
}
}

public void setMaximumZ(float maximumZ) {
this.maximumZ = maximumZ;
if (tileOverlay != null) {
tileOverlay.clearTileCache();
}
}

public void setMinimumZ(float minimumZ) {
this.minimumZ = minimumZ;
if (tileOverlay != null) {
tileOverlay.clearTileCache();
}
}

public TileOverlayOptions getTileOverlayOptions() {
if (tileOverlayOptions == null) {
tileOverlayOptions = createTileOverlayOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,4 @@ public void setZIndex(AirMapUrlTile view, float zIndex) {
view.setZIndex(zIndex);
}

@ReactProp(name = "minimumZ", defaultFloat = 0.0f)
public void setMinimumZ(AirMapUrlTile view, float minimumZ) {
view.setMinimumZ(minimumZ)
}

@ReactProp(name = "maximumZ", defaultFloat = 100.0f)
public void setMaximumZ(AirMapUrlTile view, float maximumZ) {
view.setMaximumZ(maximumZ);
}

}
17 changes: 3 additions & 14 deletions lib/components/MapUrlTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,12 @@ const propTypes = {
*/
zIndex: PropTypes.number,
/**
* The maximum zoom level for this tile overlay.
*
*/
maximumZ: PropTypes.number,

/**
* The minimum zoom level for this tile overlay.
*
*/
minimumZ: PropTypes.number,

/**
* Corresponds to MKTileOverlay canReplaceMapContent.
* The maximum zoom level for this tile overlay. Corresponds to the maximumZ setting in
* MKTileOverlay. iOS only.
*
* @platform ios
*/
shouldReplaceMapContent: PropTypes.bool,
maximumZ: PropTypes.number,
};

class MapUrlTile extends React.Component {
Expand Down
2 changes: 0 additions & 2 deletions lib/ios/AirGoogleMaps/AIRGoogleMapURLTileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ - (UIView *)view

RCT_EXPORT_VIEW_PROPERTY(urlTemplate, NSString)
RCT_EXPORT_VIEW_PROPERTY(zIndex, int)
RCT_EXPORT_VIEW_PROPERTY(maximumZ, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(minimumZ, NSInteger)

@end
2 changes: 0 additions & 2 deletions lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@
@property (nonatomic, strong) GMSURLTileLayer *tileLayer;
@property (nonatomic, assign) NSString *urlTemplate;
@property (nonatomic, assign) int zIndex;
@property NSInteger *maximumZ;
@property NSInteger *minimumZ;

@end
16 changes: 2 additions & 14 deletions lib/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,13 @@ - (void)setUrlTemplate:(NSString *)urlTemplate
- (GMSTileURLConstructor)_getTileURLConstructor
{
NSString *urlTemplate = self.urlTemplate;
NSInteger *maximumZ = self.maximumZ;
NSInteger *minimumZ = self.minimumZ;
GMSTileURLConstructor urls = ^NSURL* _Nullable (NSUInteger x, NSUInteger y, NSUInteger zoom) {
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]];

if(maximumZ && (long)zoom > (long)maximumZ) {
return nil;
}

if(minimumZ && (long)zoom < (long)minimumZ) {
return nil;
}

return [NSURL URLWithString:url];
};
return urls;
}

@end
@end
3 changes: 1 addition & 2 deletions lib/ios/AirMaps/AIRMapUrlTile.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@

@property (nonatomic, strong) MKTileOverlay *tileOverlay;
@property (nonatomic, strong) MKTileOverlayRenderer *renderer;

@property (nonatomic, copy) NSString *urlTemplate;
@property NSInteger maximumZ;
@property NSInteger minimumZ;
@property BOOL shouldReplaceMapContent;

#pragma mark MKOverlay protocol

Expand Down
33 changes: 1 addition & 32 deletions lib/ios/AirMaps/AIRMapUrlTile.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,6 @@ @implementation AIRMapUrlTile {
BOOL _urlTemplateSet;
}

- (void)setShouldReplaceMapContent:(BOOL)shouldReplaceMapContent
{
_shouldReplaceMapContent = shouldReplaceMapContent;
if(self.tileOverlay) {
self.tileOverlay.canReplaceMapContent = _shouldReplaceMapContent;
}
[self update];
}

- (void)setMaximumZ:(NSUInteger)maximumZ
{
_maximumZ = maximumZ;
if(self.tileOverlay) {
self.tileOverlay.maximumZ = _maximumZ;
}
[self update];
}

- (void)setMinimumZ:(NSUInteger)minimumZ
{
_minimumZ = minimumZ;
if(self.tileOverlay) {
self.tileOverlay.minimumZ = _minimumZ;
}
[self update];
}

- (void)setUrlTemplate:(NSString *)urlTemplate{
_urlTemplate = urlTemplate;
Expand All @@ -51,12 +25,7 @@ - (void) createTileOverlayAndRendererIfPossible
{
if (!_urlTemplateSet) return;
self.tileOverlay = [[MKTileOverlay alloc] initWithURLTemplate:self.urlTemplate];

self.tileOverlay.canReplaceMapContent = self.shouldReplaceMapContent;

if(self.minimumZ) {
self.tileOverlay.minimumZ = self.minimumZ;
}
self.tileOverlay.canReplaceMapContent = YES;
if (self.maximumZ) {
self.tileOverlay.maximumZ = self.maximumZ;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/ios/AirMaps/AIRMapUrlTileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@ - (UIView *)view

RCT_EXPORT_VIEW_PROPERTY(urlTemplate, NSString)
RCT_EXPORT_VIEW_PROPERTY(maximumZ, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(minimumZ, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(shouldReplaceMapContent, BOOL)

@end

0 comments on commit 6ed3b32

Please sign in to comment.