-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] Google Maps: Dragging Marker (by long pressing the marker) triggers MapView's onLongPress #2002
Comments
I am not sure if others are having this problem but I have had this for a while and still have not manage to resolve this. Any others having this problem? Thanks.. |
@gunsym I was able to solve this by using state. It seems onDragStart will fire before the Map's onLongPress. So onDragStart set an "isDragging" flag to true, and in your handler for onLongPress, return early if isDragging is true. Another onDragEnd handler sets isDragging back to false. |
Thanks @chrismcleod for sharing your findings! I appreciate it very much |
@gunsym My new approach is to use setTimeout when long pressing the map. So, in the MapView onLongPress handler start a timeout of a few milliseconds. When that timeout executes, check a variable in your component that represents whether a marker is being dragged. If it is, do nothing, otherwise handle the long press. Add an onStartDrag to the marker that will update the state of the component to indicate a marker is being dragged. onEndDrag sets it back to false. The flow might be: Should Not Fire Long Press: Should Fire Long Press: |
Is this a bug report?
Yes
Have you read the Installation Instructions?
Yes
Environment
Target Platform: iOS - 10.2.1 / iPhone 6S / GoogleMaps
Map provider: Google
Steps to Reproduce
(Write your steps here:)
Expected Behavior
The marker becomes draggable without adding a new marker (triggering onLongPress)
Actual Behavior
The marker becomes draggable but it adds a new marker (triggered onLongPress)
Reproducible Demo
https://snack.expo.io/@gunsym/google-map-on-ios
https://snack.expo.io/@gunsym/apple-map-on-ios
https://snack.expo.io/@gunsym/google-map-on-android
The text was updated successfully, but these errors were encountered: