summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@users.noreply.github.com>2015-03-27 20:02:22 -0700
committerJustin R. Miller <incanus@users.noreply.github.com>2015-03-27 20:02:22 -0700
commit843a09fdc36de1845c13bbd07b28ce5d2d2aca01 (patch)
tree2c3bdb06e8f60527470efabdfd7901bf0346ab58
parent2aa7f9ad979f0894bddd9cf56b87420a9d0d9f51 (diff)
parentac3ba85120d878a610ceff6b2afd958e89db599c (diff)
downloadqtlocation-mapboxgl-ios-v0.2.5.tar.gz
Merge pull request #1151 from mapbox/1125-improvementsios-v0.2.5ios-beta-preview-sirius-0.0.6
refs #1125: user dot improvements
-rw-r--r--platform/ios/MGLMapView.mm60
1 files changed, 47 insertions, 13 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 7c997d615f..4049e55f5b 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -775,16 +775,16 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
mbgl::LatLngBounds tapBounds;
coordinate = [self convertPoint:tapRectLowerLeft toCoordinateFromView:self];
- tapBounds.extend(mbgl::LatLng(coordinate.latitude, coordinate.longitude));
+ tapBounds.extend(coordinateToLatLng(coordinate));
coordinate = [self convertPoint:tapRectUpperLeft toCoordinateFromView:self];
- tapBounds.extend(mbgl::LatLng(coordinate.latitude, coordinate.longitude));
+ tapBounds.extend(coordinateToLatLng(coordinate));
coordinate = [self convertPoint:tapRectUpperRight toCoordinateFromView:self];
- tapBounds.extend(mbgl::LatLng(coordinate.latitude, coordinate.longitude));
+ tapBounds.extend(coordinateToLatLng(coordinate));
coordinate = [self convertPoint:tapRectLowerRight toCoordinateFromView:self];
- tapBounds.extend(mbgl::LatLng(coordinate.latitude, coordinate.longitude));
+ tapBounds.extend(coordinateToLatLng(coordinate));
// query for nearby annotations
std::vector<uint32_t> nearbyAnnotations = mbglMap->getAnnotationsInBounds(tapBounds);
@@ -875,12 +875,30 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
if (doubleTap.state == UIGestureRecognizerStateBegan)
{
[self trackGestureEvent:MGLEventGestureDoubleTap forRecognizer:doubleTap];
-
- self.userTrackingMode = MGLUserTrackingModeNone;
}
else if (doubleTap.state == UIGestureRecognizerStateEnded)
{
- mbglMap->scaleBy(2, [doubleTap locationInView:doubleTap.view].x, [doubleTap locationInView:doubleTap.view].y, secondsAsDuration(MGLAnimationDuration));
+ CGPoint doubleTapPoint = [doubleTap locationInView:doubleTap.view];
+
+ CGPoint zoomInPoint;
+
+ if (self.userTrackingMode != MGLUserTrackingModeNone)
+ {
+ CGPoint userPoint = [self convertCoordinate:self.userLocation.coordinate toPointToView:self];
+ CGRect userLocationRect = CGRectMake(userPoint.x - 40, userPoint.y - 40, 80, 80);
+ if (CGRectContainsPoint(userLocationRect, doubleTapPoint))
+ {
+ zoomInPoint = userPoint;
+ }
+ }
+ else
+ {
+ self.userTrackingMode = MGLUserTrackingModeNone;
+
+ zoomInPoint = doubleTapPoint;
+ }
+
+ mbglMap->scaleBy(2, zoomInPoint.x, zoomInPoint.y, secondsAsDuration(MGLAnimationDuration));
self.animatingGesture = YES;
@@ -908,12 +926,23 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
if (twoFingerTap.state == UIGestureRecognizerStateBegan)
{
[self trackGestureEvent:MGLEventGestureTwoFingerSingleTap forRecognizer:twoFingerTap];
-
- self.userTrackingMode = MGLUserTrackingModeNone;
}
else if (twoFingerTap.state == UIGestureRecognizerStateEnded)
{
- mbglMap->scaleBy(0.5, [twoFingerTap locationInView:twoFingerTap.view].x, [twoFingerTap locationInView:twoFingerTap.view].y, secondsAsDuration(MGLAnimationDuration));
+ CGPoint zoomOutPoint;
+
+ if (self.userTrackingMode != MGLUserTrackingModeNone)
+ {
+ zoomOutPoint = self.center;
+ }
+ else
+ {
+ self.userTrackingMode = MGLUserTrackingModeNone;
+
+ zoomOutPoint = CGPointMake([twoFingerTap locationInView:twoFingerTap.view].x, [twoFingerTap locationInView:twoFingerTap.view].y);
+ }
+
+ mbglMap->scaleBy(0.5, zoomOutPoint.x, zoomOutPoint.y, secondsAsDuration(MGLAnimationDuration));
self.animatingGesture = YES;
@@ -1182,7 +1211,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(UIView *)view
{
- mbgl::vec2<double> pixel = mbglMap->pixelForLatLng(mbgl::LatLng(coordinate.latitude, coordinate.longitude));
+ mbgl::vec2<double> pixel = mbglMap->pixelForLatLng(coordinateToLatLng(coordinate));
// flip y coordinate for iOS view origin in top left
//
@@ -1775,8 +1804,6 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
}
}
- self.userLocationAnnotationView.layer.hidden = ! CLLocationCoordinate2DIsValid(self.userLocation.coordinate);
-
self.userLocationAnnotationView.haloLayer.hidden = ! CLLocationCoordinate2DIsValid(self.userLocation.coordinate) ||
newLocation.horizontalAccuracy > 10;
@@ -2070,6 +2097,11 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
- (void)updateUserLocationAnnotationView
{
+ if ( ! CLLocationCoordinate2DIsValid(self.userLocation.coordinate)) {
+ self.userLocationAnnotationView.layer.hidden = YES;
+ return;
+ }
+
if ( ! self.userLocationAnnotationView.superview) [self.glView addSubview:self.userLocationAnnotationView];
CGPoint userPoint = [self convertCoordinate:self.userLocation.coordinate toPointToView:self];
@@ -2079,6 +2111,8 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
{
self.userLocationAnnotationView.center = userPoint;
+ self.userLocationAnnotationView.layer.hidden = NO;
+
[self.userLocationAnnotationView setupLayers];
}
else