-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync/internal to public main (#1937)
* Enable zoom during dragging gesture (#1391) * Enable Pinch and Pan gestures work together * Fix unit tests * Bugfix/mapsios 538 bearing is incorrect when rotate (#1396) * Correct PanZoomPinchBehavior drag camera options. * Correct PanPinchBehavior drag camera options * allow animations during longtap (#1415) (#1418) * Mark snapshotter tile mode as deprecated (#1427) * Prepare v10.12.0 release (#1435) * Bump MapboxCoreMaps to 10.12.0 and MapboxCommon to 23.4.0 * Bump MapboxMaps version to 10.12.0 * Update LICENSE.md * Pass metal view size instead of map view size as they can diverge to MapboxMap (#1437) Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com> * Bypass Edit Home Screen alert in iOS 16.2 test lab devices (#1438) * Bypass Edit Home Screen alert in iOS 16.2 test lab devices * Dismiss Edit Home Screen alert before first test --------- Co-authored-by: Roman Gardukevich <roman.gardukevich@mapbox.com> Co-authored-by: Ivan Persidsky <ivan.persidskii@mapbox.com> Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com>
- Loading branch information
1 parent
3257f24
commit 203af16
Showing
30 changed files
with
198 additions
and
199 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
65 changes: 65 additions & 0 deletions
65
Apps/Examples/Examples/All Examples/LongTapAnimationExample.swift
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,65 @@ | ||
import MapboxMaps | ||
import UIKit | ||
|
||
private extension String { | ||
static let blueMarker = "blue-marker" | ||
} | ||
|
||
// This examples shows how to animate camera to a long-tapped coordinate. | ||
public class LongTapAnimationExample: UIViewController, ExampleProtocol { | ||
internal var mapView: MapView! | ||
private var pointAnnotationManager: PointAnnotationManager! | ||
|
||
override public func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// Center the map over the United States. | ||
let centerCoordinate = CLLocationCoordinate2D(latitude: 39.368279, | ||
longitude: -97.646484) | ||
let options = MapInitOptions(cameraOptions: CameraOptions(center: centerCoordinate, zoom: 2.4)) | ||
|
||
mapView = MapView(frame: view.bounds, mapInitOptions: options) | ||
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | ||
view.addSubview(mapView) | ||
|
||
mapView.mapboxMap.onNext(event: .mapLoaded) { _ in | ||
self.setupExample() | ||
|
||
// The following line is just for testing purposes. | ||
self.finish() | ||
} | ||
pointAnnotationManager = mapView.annotations.makePointAnnotationManager() | ||
} | ||
|
||
func setupExample() { | ||
try! mapView.mapboxMap.style.addImage(UIImage(named: "blue_marker_view")!, id: .blueMarker) | ||
let tapGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress)) | ||
mapView.addGestureRecognizer(tapGesture) | ||
} | ||
|
||
@objc public func longPress(_ sender: UILongPressGestureRecognizer) { | ||
switch sender.state { | ||
case .began: | ||
longPressBegan(at: sender.location(in: mapView)) | ||
default: | ||
break | ||
} | ||
} | ||
|
||
private func longPressBegan(at location: CGPoint) { | ||
haptic() | ||
let coordinate = mapView.mapboxMap.coordinate(for: location) | ||
|
||
var annotation = PointAnnotation(point: Point(coordinate)) | ||
annotation.iconImage = .blueMarker | ||
pointAnnotationManager.annotations.append(annotation) | ||
|
||
let camera = CameraOptions(center: coordinate) | ||
mapView.camera.ease(to: camera, duration: 0.5) | ||
} | ||
|
||
private func haptic() { | ||
let impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .heavy) | ||
impactFeedbackGenerator.impactOccurred() | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
11 changes: 4 additions & 7 deletions
11
Sources/MapboxMaps/Gestures/GestureHandlers/AnyTouchGestureHandler.swift
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
22 changes: 7 additions & 15 deletions
22
Sources/MapboxMaps/Gestures/GestureHandlers/PinchBehaviors/PanPinchBehavior.swift
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 |
---|---|---|
@@ -1,28 +1,20 @@ | ||
internal final class PanPinchBehavior: PinchBehavior { | ||
private let initialCameraState: CameraState | ||
private let initialPinchMidpoint: CGPoint | ||
private var currentPinchMidpoint: CGPoint | ||
private let mapboxMap: MapboxMapProtocol | ||
|
||
internal init(initialCameraState: CameraState, | ||
initialPinchMidpoint: CGPoint, | ||
mapboxMap: MapboxMapProtocol) { | ||
self.initialCameraState = initialCameraState | ||
self.initialPinchMidpoint = initialPinchMidpoint | ||
internal init(initialPinchMidpoint: CGPoint, mapboxMap: MapboxMapProtocol) { | ||
self.currentPinchMidpoint = initialPinchMidpoint | ||
self.mapboxMap = mapboxMap | ||
} | ||
|
||
internal func update(pinchMidpoint: CGPoint, pinchScale: CGFloat) { | ||
mapboxMap.performWithoutNotifying { | ||
mapboxMap.setCamera(to: CameraOptions( | ||
center: initialCameraState.center, | ||
bearing: initialCameraState.bearing)) | ||
} | ||
|
||
mapboxMap.dragStart(for: initialPinchMidpoint) | ||
mapboxMap.dragStart(for: currentPinchMidpoint) | ||
let dragOptions = mapboxMap.dragCameraOptions( | ||
from: initialPinchMidpoint, | ||
from: currentPinchMidpoint, | ||
to: pinchMidpoint) | ||
mapboxMap.setCamera(to: dragOptions) | ||
mapboxMap.dragEnd() | ||
|
||
currentPinchMidpoint = pinchMidpoint | ||
} | ||
} |
Oops, something went wrong.