|
@@ -896,7 +896,7 @@ |
|
@@ -896,7 +896,7 @@ |
896
|
[mapScrollView addSubview:tiledLayerView];
|
896
|
[mapScrollView addSubview:tiledLayerView];
|
897
|
|
897
|
|
898
|
[mapScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:NULL];
|
898
|
[mapScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:NULL];
|
899
|
- [mapScrollView setZoomScale:exp2f([self zoom] - 1.0) animated:NO];
|
899
|
+ [mapScrollView setZoomScale:exp2f([self zoom]) animated:NO];
|
900
|
|
900
|
|
901
|
_lastZoom = [self zoom];
|
901
|
_lastZoom = [self zoom];
|
902
|
_lastContentOffset = mapScrollView.contentOffset;
|
902
|
_lastContentOffset = mapScrollView.contentOffset;
|
|
@@ -1057,10 +1057,17 @@ |
|
@@ -1057,10 +1057,17 @@ |
1057
|
{
|
1057
|
{
|
1058
|
RMProjectedRect planetBounds = projection.planetBounds;
|
1058
|
RMProjectedRect planetBounds = projection.planetBounds;
|
1059
|
metersPerPixel = planetBounds.size.width / mapScrollView.contentSize.width;
|
1059
|
metersPerPixel = planetBounds.size.width / mapScrollView.contentSize.width;
|
1060
|
- zoom = log2f(mapScrollView.zoomScale) + 1.0;
|
1060
|
+ zoom = log2f(mapScrollView.zoomScale);
|
1061
|
|
1061
|
|
1062
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(correctPositionOfAllAnnotations) object:nil];
|
1062
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(correctPositionOfAllAnnotations) object:nil];
|
1063
|
|
1063
|
|
|
|
1064
|
+ if (_constrainMovement && ![self projectedBounds:tileSourceProjectedBounds containsPoint:[self centerProjectedPoint]]) {
|
|
|
1065
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
1066
|
+ [mapScrollView setContentOffset:_lastContentOffset animated:NO];
|
|
|
1067
|
+ });
|
|
|
1068
|
+ return;
|
|
|
1069
|
+ }
|
|
|
1070
|
+
|
1064
|
if (zoom == _lastZoom)
|
1071
|
if (zoom == _lastZoom)
|
1065
|
{
|
1072
|
{
|
1066
|
CGPoint contentOffset = mapScrollView.contentOffset;
|
1073
|
CGPoint contentOffset = mapScrollView.contentOffset;
|
|
@@ -1109,6 +1116,9 @@ |
|
@@ -1109,6 +1116,9 @@ |
1109
|
mercatorToTileProjection = [[tileSource mercatorToTileProjection] retain];
|
1116
|
mercatorToTileProjection = [[tileSource mercatorToTileProjection] retain];
|
1110
|
tileSourceProjectedBounds = (RMProjectedRect)[self projectedRectFromLatitudeLongitudeBounds:[tileSource latitudeLongitudeBoundingBox]];
|
1117
|
tileSourceProjectedBounds = (RMProjectedRect)[self projectedRectFromLatitudeLongitudeBounds:[tileSource latitudeLongitudeBoundingBox]];
|
1111
|
|
1118
|
|
|
|
1119
|
+ RMSphericalTrapezium bounds = [tileSource latitudeLongitudeBoundingBox];
|
|
|
1120
|
+ _constrainMovement = !(bounds.northEast.latitude == 90 && bounds.northEast.longitude == 180 && bounds.southWest.latitude == -90 && bounds.southWest.longitude == -180);
|
|
|
1121
|
+
|
1112
|
[self setMinZoom:newTileSource.minZoom];
|
1122
|
[self setMinZoom:newTileSource.minZoom];
|
1113
|
[self setMaxZoom:newTileSource.maxZoom];
|
1123
|
[self setMaxZoom:newTileSource.maxZoom];
|
1114
|
[self setZoom:[self zoom]]; // setZoom clamps zoom level to min/max limits
|
1124
|
[self setZoom:[self zoom]]; // setZoom clamps zoom level to min/max limits
|
|
@@ -1174,13 +1184,19 @@ |
|
@@ -1174,13 +1184,19 @@ |
1174
|
- (void)setMinZoom:(float)newMinZoom
|
1184
|
- (void)setMinZoom:(float)newMinZoom
|
1175
|
{
|
1185
|
{
|
1176
|
minZoom = newMinZoom;
|
1186
|
minZoom = newMinZoom;
|
1177
|
- mapScrollView.minimumZoomScale = exp2f(newMinZoom - 1.0);
|
1187
|
+
|
|
|
1188
|
+// RMLog(@"New minZoom:%f", newMinZoom);
|
|
|
1189
|
+
|
|
|
1190
|
+ mapScrollView.minimumZoomScale = exp2f(newMinZoom);
|
1178
|
}
|
1191
|
}
|
1179
|
|
1192
|
|
1180
|
- (void)setMaxZoom:(float)newMaxZoom
|
1193
|
- (void)setMaxZoom:(float)newMaxZoom
|
1181
|
{
|
1194
|
{
|
1182
|
maxZoom = newMaxZoom;
|
1195
|
maxZoom = newMaxZoom;
|
1183
|
- mapScrollView.maximumZoomScale = exp2f(newMaxZoom - 1.0);
|
1196
|
+
|
|
|
1197
|
+// RMLog(@"New maxZoom:%f", newMaxZoom);
|
|
|
1198
|
+
|
|
|
1199
|
+ mapScrollView.maximumZoomScale = exp2f(newMaxZoom);
|
1184
|
}
|
1200
|
}
|
1185
|
|
1201
|
|
1186
|
- (float)zoom
|
1202
|
- (float)zoom
|
|
@@ -1194,7 +1210,9 @@ |
|
@@ -1194,7 +1210,9 @@ |
1194
|
zoom = (newZoom > maxZoom) ? maxZoom : newZoom;
|
1210
|
zoom = (newZoom > maxZoom) ? maxZoom : newZoom;
|
1195
|
zoom = (zoom < minZoom) ? minZoom : zoom;
|
1211
|
zoom = (zoom < minZoom) ? minZoom : zoom;
|
1196
|
|
1212
|
|
1197
|
- mapScrollView.zoomScale = exp2f(zoom - 1.0);
|
1213
|
+// RMLog(@"New zoom:%f", zoom);
|
|
|
1214
|
+
|
|
|
1215
|
+ mapScrollView.zoomScale = exp2f(zoom);
|
1198
|
}
|
1216
|
}
|
1199
|
|
1217
|
|
1200
|
- (void)setEnableClustering:(BOOL)doEnableClustering
|
1218
|
- (void)setEnableClustering:(BOOL)doEnableClustering
|
|
@@ -1568,25 +1586,4 @@ |
|
@@ -1568,25 +1586,4 @@ |
1568
|
return annotation.position;
|
1586
|
return annotation.position;
|
1569
|
}
|
1587
|
}
|
1570
|
|
1588
|
|
1571
|
-//
|
|
|
1572
|
-//- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
|
|
1573
|
-//{
|
|
|
1574
|
-// RMGestureDetails newGesture = [self gestureDetails:[event allTouches]];
|
|
|
1575
|
-// CALayer *hit = [self.overlay hitTest:[touch locationInView:self]];
|
|
|
1576
|
-//// RMLog(@"LAYER of type %@",[hit description]);
|
|
|
1577
|
-//
|
|
|
1578
|
-// if (hit != nil)
|
|
|
1579
|
-// {
|
|
|
1580
|
-// if ([hit isKindOfClass: [RMMarker class]]) {
|
|
|
1581
|
-// if (!_delegateHasShouldDragMarker || (_delegateHasShouldDragMarker && [delegate mapView:self shouldDragAnnotation:((RMMarker *)hit).annotation withEvent:event]))
|
|
|
1582
|
-// {
|
|
|
1583
|
-// if (_delegateHasDidDragMarker) {
|
|
|
1584
|
-// [delegate mapView:self didDragAnnotation:((RMMarker *)hit).annotation withEvent:event];
|
|
|
1585
|
-// return;
|
|
|
1586
|
-// }
|
|
|
1587
|
-// }
|
|
|
1588
|
-// }
|
|
|
1589
|
-// }
|
|
|
1590
|
-//
|
|
|
1591
|
-
|
|
|
1592
|
@end |
1589
|
@end |