Skip to content

Commit

Permalink
adding documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hactar committed Mar 31, 2024
1 parent d1a65d8 commit ca182dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ extension MapView {
/// gesture.
/// - sender: The UIGestureRecognizer
@MainActor func processGesture(_ mapView: MLNMapView, _ sender: UIGestureRecognizer) {
guard sender.state == .ended else {
// We should only process gestures that have ended, else built in gestures like double tapping the map
// interfere with ours.
return
}
guard let gesture = gestures.first(where: { $0.gestureRecognizer == sender }) else {
assertionFailure("\(sender) is not a registered UIGestureRecongizer on the MapView")
return
Expand Down
13 changes: 12 additions & 1 deletion Sources/MapLibreSwiftUI/MapViewModifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public extension MapView {
///
/// - Parameters:
/// - count: The number of taps required to run the gesture.
/// - onTapChanged: Emits the context whenever the gesture changes (e.g. began, ended, etc).
/// - onTapChanged: Emits the context whenever the gesture changes (e.g. began, ended, etc), that also contains
/// information like the latitude and longitude of the tap.
/// - Returns: The modified map view.
func onTapMapGesture(count: Int = 1,
onTapChanged: @escaping (MapGestureContext) -> Void) -> MapView
Expand All @@ -65,6 +66,16 @@ public extension MapView {
return newMapView
}

/// Add an tap gesture handler to the MapView that returns any visible map features that were tapped.
///
/// - Parameters:
/// - count: The number of taps required to run the gesture.
/// - on layers: The set of layer ids that you would like to check for visible features that were tapped. If no
/// set is provided, all map layers are checked.
/// - onTapChanged: Emits the context whenever the gesture changes (e.g. began, ended, etc), that also contains
/// information like the latitude and longitude of the tap. Also emits an array of map features that were tapped.
/// Returns an empty array when nothing was tapped on the "on" layer ids that were provided.
/// - Returns: The modified map view.
func onTapMapGesture(count: Int = 1, on layers: Set<String>?,
onTapChanged: @escaping (MapGestureContext, [any MLNFeature]) -> Void) -> MapView
{
Expand Down

0 comments on commit ca182dc

Please sign in to comment.