Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Prevent annotation deselection when panning/zooming map #4389

Closed
n8chur opened this issue Mar 18, 2016 · 1 comment
Closed

Prevent annotation deselection when panning/zooming map #4389

n8chur opened this issue Mar 18, 2016 · 1 comment
Labels
iOS Mapbox Maps SDK for iOS

Comments

@n8chur
Copy link

n8chur commented Mar 18, 2016

In the iOS SDK - (void)mapView:(MGLMapView *)mapView didDeselectAnnotation:(id<MGLAnnotation>)annotation is called whenever the user pans or zooms the MGLMapView. It would be great to have a way to prevent annotation deselection when panning or zooming the MGLMapView.

In the project I am currently working on we swap out the annotation image when an annotation is selected (we do not show a callout) to indicate the selected state of the annotation and would like to retain that selection state when the user pans/zooms the map. We are currently working around the issue by keeping track of the selected annotation in our own property and we ignore the deselection callback. The disadvantage to this approach is that we have no way of deselecting our annotation when a user taps outside of the annotation since the deselection callback does not allow us differentiate between a deselection due to a pan/zoom vs deselection due to a tap outside of the currently selected annotation.

I realize this has implications to how callout functionality would work as you would want the callout to dismiss when the user pans/zooms even if you do want the annotation to remain selected in that case. Since the callout state and the selection state are coupled, decoupling the callout may be necessary in order to implement this feature properly.

@1ec5
Copy link
Contributor

1ec5 commented Mar 18, 2016

Once #3154 is fixed, that method won’t get called as soon as the user pans or zooms the map. Your approach to tracking selection – with a property on a custom subclass of MGLPointAnnotation – would be a good approach in general.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

2 participants