...
|
...
|
@@ -210,9 +210,9 @@ |
|
|
|
|
|
- (void)performInitializationWithTilesource:(id <RMTileSource>)newTilesource
|
|
|
centerCoordinate:(CLLocationCoordinate2D)initialCenterCoordinate
|
|
|
zoomLevel:(float)initialZoomLevel
|
|
|
maxZoomLevel:(float)maxZoomLevel
|
|
|
minZoomLevel:(float)minZoomLevel
|
|
|
zoomLevel:(float)initialTileSourceZoomLevel
|
|
|
maxZoomLevel:(float)initialTileSourceMaxZoomLevel
|
|
|
minZoomLevel:(float)initialTileSourceMinZoomLevel
|
|
|
backgroundImage:(UIImage *)backgroundImage
|
|
|
{
|
|
|
_constrainMovement = _enableBouncing = _zoomingInPivotsAroundCenter = NO;
|
...
|
...
|
@@ -266,11 +266,11 @@ |
|
|
[self setBackgroundView:_loadingTileView];
|
|
|
}
|
|
|
|
|
|
if (minZoomLevel < newTilesource.minZoom) minZoomLevel = newTilesource.minZoom;
|
|
|
if (maxZoomLevel > newTilesource.maxZoom) maxZoomLevel = newTilesource.maxZoom;
|
|
|
[self setMinZoom:minZoomLevel];
|
|
|
[self setMaxZoom:maxZoomLevel];
|
|
|
[self setZoom:initialZoomLevel];
|
|
|
if (initialTileSourceMinZoomLevel < newTilesource.minZoom) initialTileSourceMinZoomLevel = newTilesource.minZoom;
|
|
|
if (initialTileSourceMaxZoomLevel > newTilesource.maxZoom) initialTileSourceMaxZoomLevel = newTilesource.maxZoom;
|
|
|
[self setTileSourcesMinZoom:initialTileSourceMinZoomLevel];
|
|
|
[self setTileSourcesMaxZoom:initialTileSourceMaxZoomLevel];
|
|
|
[self setTileSourcesZoom:initialTileSourceZoomLevel];
|
|
|
|
|
|
[self setTileSource:newTilesource];
|
|
|
[self setCenterCoordinate:initialCenterCoordinate animated:NO];
|
...
|
...
|
@@ -995,16 +995,13 @@ |
|
|
self.userTrackingMode = RMUserTrackingModeNone;
|
|
|
|
|
|
// Calculate rounded zoom
|
|
|
float newZoom = fmin(ceilf([self zoom]) + 0.99, [self maxZoom]);
|
|
|
|
|
|
if (newZoom == self.zoom)
|
|
|
return;
|
|
|
float newZoom = fmin(ceilf([self zoom]) + 1.0, [self maxZoom]);
|
|
|
|
|
|
float factor = exp2f(newZoom - [self zoom]);
|
|
|
|
|
|
if (factor > 2.25)
|
|
|
{
|
|
|
newZoom = fmin(ceilf([self zoom]) - 0.01, [self maxZoom]);
|
|
|
newZoom = fmin(ceilf([self zoom]), [self maxZoom]);
|
|
|
factor = exp2f(newZoom - [self zoom]);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1020,16 +1017,13 @@ |
|
|
- (void)zoomOutToNextNativeZoomAt:(CGPoint)pivot animated:(BOOL) animated
|
|
|
{
|
|
|
// Calculate rounded zoom
|
|
|
float newZoom = fmax(floorf([self zoom]) - 0.01, [self minZoom]);
|
|
|
|
|
|
if (newZoom == self.zoom)
|
|
|
return;
|
|
|
float newZoom = fmax(floorf([self zoom]), [self minZoom]);
|
|
|
|
|
|
float factor = exp2f(newZoom - [self zoom]);
|
|
|
|
|
|
if (factor > 0.75)
|
|
|
{
|
|
|
newZoom = fmax(floorf([self zoom]) - 1.01, [self minZoom]);
|
|
|
newZoom = fmax(floorf([self zoom]) - 1.0, [self minZoom]);
|
|
|
factor = exp2f(newZoom - [self zoom]);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1160,10 +1154,7 @@ |
|
|
{
|
|
|
RMMapTiledLayerView *tiledLayerView = [[RMMapTiledLayerView alloc] initWithFrame:CGRectMake(0.0, 0.0, contentSize.width, contentSize.height) mapView:self forTileSource:tileSource];
|
|
|
|
|
|
if (self.adjustTilesForRetinaDisplay && _screenScale > 1.0)
|
|
|
((CATiledLayer *)tiledLayerView.layer).tileSize = CGSizeMake(tileSideLength * 2.0, tileSideLength * 2.0);
|
|
|
else
|
|
|
((CATiledLayer *)tiledLayerView.layer).tileSize = CGSizeMake(tileSideLength, tileSideLength);
|
|
|
((CATiledLayer *)tiledLayerView.layer).tileSize = CGSizeMake(tileSideLength, tileSideLength);
|
|
|
|
|
|
[_tiledLayersSuperview addSubview:tiledLayerView];
|
|
|
}
|
...
|
...
|
@@ -1801,8 +1792,8 @@ |
|
|
else
|
|
|
_constrainingProjectedBounds = _projection.planetBounds;
|
|
|
|
|
|
[self setMinZoom:_tileSourcesContainer.minZoom];
|
|
|
[self setMaxZoom:_tileSourcesContainer.maxZoom];
|
|
|
[self setTileSourcesMinZoom:_tileSourcesContainer.minZoom];
|
|
|
[self setTileSourcesMaxZoom:_tileSourcesContainer.maxZoom];
|
|
|
[self setZoom:[self zoom]]; // setZoom clamps zoom level to min/max limits
|
|
|
|
|
|
// Recreate the map layer
|
...
|
...
|
@@ -1841,8 +1832,8 @@ |
|
|
else
|
|
|
_constrainingProjectedBounds = _projection.planetBounds;
|
|
|
|
|
|
[self setMinZoom:_tileSourcesContainer.minZoom];
|
|
|
[self setMaxZoom:_tileSourcesContainer.maxZoom];
|
|
|
[self setTileSourcesMinZoom:_tileSourcesContainer.minZoom];
|
|
|
[self setTileSourcesMaxZoom:_tileSourcesContainer.maxZoom];
|
|
|
[self setZoom:[self zoom]]; // setZoom clamps zoom level to min/max limits
|
|
|
|
|
|
// Recreate the map layer
|
...
|
...
|
@@ -1859,10 +1850,7 @@ |
|
|
|
|
|
RMMapTiledLayerView *tiledLayerView = [[RMMapTiledLayerView alloc] initWithFrame:CGRectMake(0.0, 0.0, contentSize.width, contentSize.height) mapView:self forTileSource:newTileSource];
|
|
|
|
|
|
if (self.adjustTilesForRetinaDisplay && _screenScale > 1.0)
|
|
|
((CATiledLayer *)tiledLayerView.layer).tileSize = CGSizeMake(tileSideLength * 2.0, tileSideLength * 2.0);
|
|
|
else
|
|
|
((CATiledLayer *)tiledLayerView.layer).tileSize = CGSizeMake(tileSideLength, tileSideLength);
|
|
|
((CATiledLayer *)tiledLayerView.layer).tileSize = CGSizeMake(tileSideLength, tileSideLength);
|
|
|
|
|
|
if (index >= [[_tileSourcesContainer tileSources] count])
|
|
|
[_tiledLayersSuperview addSubview:tiledLayerView];
|
...
|
...
|
@@ -2064,6 +2052,9 @@ |
|
|
|
|
|
- (void)setMinZoom:(float)newMinZoom
|
|
|
{
|
|
|
if (newMinZoom < 0.0)
|
|
|
newMinZoom = 0.0;
|
|
|
|
|
|
_minZoom = newMinZoom;
|
|
|
|
|
|
// RMLog(@"New minZoom:%f", newMinZoom);
|
...
|
...
|
@@ -2073,8 +2064,26 @@ |
|
|
[self correctMinZoomScaleForBoundingMask];
|
|
|
}
|
|
|
|
|
|
- (float)tileSourcesMinZoom
|
|
|
{
|
|
|
return self.tileSourcesContainer.minZoom;
|
|
|
}
|
|
|
|
|
|
- (void)setTileSourcesMinZoom:(float)tileSourcesMinZoom
|
|
|
{
|
|
|
tileSourcesMinZoom = ceilf(tileSourcesMinZoom) - 0.99;
|
|
|
|
|
|
if ( ! self.adjustTilesForRetinaDisplay && _screenScale > 1.0)
|
|
|
tileSourcesMinZoom -= 1.0;
|
|
|
|
|
|
[self setMinZoom:tileSourcesMinZoom];
|
|
|
}
|
|
|
|
|
|
- (void)setMaxZoom:(float)newMaxZoom
|
|
|
{
|
|
|
if (newMaxZoom < 0.0)
|
|
|
newMaxZoom = 0.0;
|
|
|
|
|
|
_maxZoom = newMaxZoom;
|
|
|
|
|
|
// RMLog(@"New maxZoom:%f", newMaxZoom);
|
...
|
...
|
@@ -2082,6 +2091,21 @@ |
|
|
_mapScrollView.maximumZoomScale = exp2f(newMaxZoom);
|
|
|
}
|
|
|
|
|
|
- (float)tileSourcesMaxZoom
|
|
|
{
|
|
|
return self.tileSourcesContainer.maxZoom;
|
|
|
}
|
|
|
|
|
|
- (void)setTileSourcesMaxZoom:(float)tileSourcesMaxZoom
|
|
|
{
|
|
|
tileSourcesMaxZoom = floorf(tileSourcesMaxZoom);
|
|
|
|
|
|
if ( ! self.adjustTilesForRetinaDisplay && _screenScale > 1.0)
|
|
|
tileSourcesMaxZoom -= 1.0;
|
|
|
|
|
|
[self setMaxZoom:tileSourcesMaxZoom];
|
|
|
}
|
|
|
|
|
|
- (float)zoom
|
|
|
{
|
|
|
return _zoom;
|
...
|
...
|
@@ -2093,11 +2117,31 @@ |
|
|
_zoom = (newZoom > _maxZoom) ? _maxZoom : newZoom;
|
|
|
_zoom = (_zoom < _minZoom) ? _minZoom : _zoom;
|
|
|
|
|
|
// RMLog(@"New zoom:%f", zoom);
|
|
|
// RMLog(@"New zoom:%f", _zoom);
|
|
|
|
|
|
_mapScrollView.zoomScale = exp2f(_zoom);
|
|
|
}
|
|
|
|
|
|
- (float)tileSourcesZoom
|
|
|
{
|
|
|
float zoom = ceilf(_zoom);
|
|
|
|
|
|
if ( ! self.adjustTilesForRetinaDisplay && _screenScale > 1.0)
|
|
|
zoom += 1.0;
|
|
|
|
|
|
return zoom;
|
|
|
}
|
|
|
|
|
|
- (void)setTileSourcesZoom:(float)tileSourcesZoom
|
|
|
{
|
|
|
tileSourcesZoom = floorf(tileSourcesZoom);
|
|
|
|
|
|
if ( ! self.adjustTilesForRetinaDisplay && _screenScale > 1.0)
|
|
|
tileSourcesZoom -= 1.0;
|
|
|
|
|
|
[self setZoom:tileSourcesZoom];
|
|
|
}
|
|
|
|
|
|
- (void)setEnableClustering:(BOOL)doEnableClustering
|
|
|
{
|
|
|
_enableClustering = doEnableClustering;
|
...
|
...
|
@@ -2904,9 +2948,9 @@ |
|
|
_userHeadingTrackingView.contentMode = UIViewContentModeTop;
|
|
|
|
|
|
_userHeadingTrackingView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
|
|
|
UIViewAutoresizingFlexibleRightMargin |
|
|
|
UIViewAutoresizingFlexibleTopMargin |
|
|
|
UIViewAutoresizingFlexibleBottomMargin;
|
|
|
UIViewAutoresizingFlexibleRightMargin |
|
|
|
UIViewAutoresizingFlexibleTopMargin |
|
|
|
UIViewAutoresizingFlexibleBottomMargin;
|
|
|
|
|
|
_userHeadingTrackingView.alpha = 0.0;
|
|
|
|
...
|
...
|
@@ -2918,9 +2962,9 @@ |
|
|
round([self bounds].size.height / 2));
|
|
|
|
|
|
_userLocationTrackingView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
|
|
|
UIViewAutoresizingFlexibleRightMargin |
|
|
|
UIViewAutoresizingFlexibleTopMargin |
|
|
|
UIViewAutoresizingFlexibleBottomMargin;
|
|
|
UIViewAutoresizingFlexibleRightMargin |
|
|
|
UIViewAutoresizingFlexibleTopMargin |
|
|
|
UIViewAutoresizingFlexibleBottomMargin;
|
|
|
|
|
|
[self insertSubview:_userLocationTrackingView aboveSubview:_userHeadingTrackingView];
|
|
|
|
...
|
...
|
|