I am trying to get the coordinates for a long press gesture on a map. When I add the long press gesture the user can no longer move the map around. I tried using a simultaneous gesture and it did not work. This works however with a tap gesture as seen in this answer.
struct ContentView: View {
var body: some View {
MapReader { reader in
Map()
.gesture (
LongPressGesture(minimumDuration: 1.0)
.sequenced(before: DragGesture(minimumDistance: 0))
.onEnded { value in
switch value {
case .second(true, let drag):
if let location = drag?.location {
let pinLocation = mapProxy.convert(location, from: .local)
if let pin = pinLocation {
UIImpactFeedbackGenerator(style: .rigid).impactOccurred()
let lat = pin.latitude
let long = pin.longitude
}
}
default:
break
}
}
)
}
}
}