You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
[iOS] Support callout for POI (public transport stops, etc) #5432
With #5110 in v3.3.0-beta.1, you could install a tap gesture recognizer to query for rendered bus stops at the tapped location, assuming that you’re displaying a style that renders bus stops, and add an annotation and callout if you find a bus stop that way. The documentation for -[MGLMapView visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:] explains how to look for bus stops if your style uses the Mapbox Streets source.
We could consider automatically doing this only for Mapbox Streets–based styles, but source-specific logic depends on #5368, which we haven’t hooked up to the iOS SDK yet.
POI is already rendered in the Map. Adding a dummy annotation to simply facilitate the callout presentation flow does not look like a good architectural choice.
It is unclear then what image I should provide for MGLAnnotationImage in -[MGLMapView mapView:imageForAnnotation:] POIs already has a presentation in the Map. So I should probably either set a transparent image or no image at all. Which looks like a dirty hack.
Considering a feature is already an annotation, adding yet another dummy annotation at some point will double the number of added annotations to the map (if user clicks over all the features). Moreover it will force client (application) to keep track of all added dummy annotations for the features. This adds redundant extra logic to the client especially when it comes to interaction with the map (panning/zooming).
At the moment, we’re trading off convenience for customizability. A built-in tappable POI feature wouldn’t make sense when the map is showing a style that doesn’t use Mapbox Streets, such as (pure) Satellite, or a custom Mapbox Studio style that happens to hide bus stops. In these cases, the map simply doesn’t have the data it would need to find the bus stop.
You’re right that adding annotations to the map, as I suggested above, would be duplicative. Perhaps it would make more sense to expose an API for displaying callouts that aren’t attached to annotations. Mapbox GL JS has had this API for awhile. It would be much more feasible in the iOS SDK once we implement #4392.
In the meantime, as things stand in v3.3.0-beta.1, you could indeed specify an invisible annotation view (in -[MGLMapViewDelegate mapView:viewForAnnotation:]). I agree that it isn’t an especially elegant solution; however, your intent is essentially to imbue an arbitrary map feature with the behavior of an annotation, but without adding a visible annotation. The cleanest way to avoid a mess of dummy annotations would be to remove the dummy annotation from the map in -[MGLMapViewDelegate mapView:didDeselectAnnotation:]. This is admittedly an elaborate workaround, and I agree that we should better facilitate your use case.
I still do not understand your concern about the case when POIs are not displayed/hidden. If map does not have/does not show POIs, it does not call any delegate callout method for those annotations. That simple.
Also, you could add additional optional method to the map delegate:
My point is that we’d be writing a feature specifically for the Mapbox Streets source, which is one out of many potential sources. I’m not ruling out the feature you’re requesting. Rather, in v3.3.0, the platform-specific code just doesn’t have the ability to know what source is being loaded, so it doesn’t know that, for example, maki=bus means a bus stop. (Using the Mapbox Studio dataset editor, you could for instance make maki=bus mean something entirely different.) The ability to distinguish between different sources is coming in v3.4.0, which would be the appropriate timeframe to revisit this issue.
Perhaps it would make more sense to expose an API for displaying callouts that aren’t attached to annotations. Mapbox GL JS has had this API for awhile. It would be much more feasible in the iOS SDK once we implement #4392.
#6515 would simplify the process of detecting the tap and associating it with a feature, but #4392 would still be required for making the callout functionality modular enough to work with non-annotations.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
boundsj commentedon Jun 22, 2016
Related #5110
1ec5 commentedon Jun 22, 2016
With #5110 in v3.3.0-beta.1, you could install a tap gesture recognizer to query for rendered bus stops at the tapped location, assuming that you’re displaying a style that renders bus stops, and add an annotation and callout if you find a bus stop that way. The documentation for
-[MGLMapView visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:]explains how to look for bus stops if your style uses the Mapbox Streets source.We could consider automatically doing this only for Mapbox Streets–based styles, but source-specific logic depends on #5368, which we haven’t hooked up to the iOS SDK yet.
andrewstay commentedon Jun 23, 2016
POI is already rendered in the Map. Adding a dummy annotation to simply facilitate the callout presentation flow does not look like a good architectural choice.
MGLAnnotationImagein-[MGLMapView mapView:imageForAnnotation:]POIs already has a presentation in the Map. So I should probably either set a transparent image or no image at all. Which looks like a dirty hack.1ec5 commentedon Jun 23, 2016
At the moment, we’re trading off convenience for customizability. A built-in tappable POI feature wouldn’t make sense when the map is showing a style that doesn’t use Mapbox Streets, such as (pure) Satellite, or a custom Mapbox Studio style that happens to hide bus stops. In these cases, the map simply doesn’t have the data it would need to find the bus stop.
You’re right that adding annotations to the map, as I suggested above, would be duplicative. Perhaps it would make more sense to expose an API for displaying callouts that aren’t attached to annotations. Mapbox GL JS has had this API for awhile. It would be much more feasible in the iOS SDK once we implement #4392.
In the meantime, as things stand in v3.3.0-beta.1, you could indeed specify an invisible annotation view (in
-[MGLMapViewDelegate mapView:viewForAnnotation:]). I agree that it isn’t an especially elegant solution; however, your intent is essentially to imbue an arbitrary map feature with the behavior of an annotation, but without adding a visible annotation. The cleanest way to avoid a mess of dummy annotations would be to remove the dummy annotation from the map in-[MGLMapViewDelegate mapView:didDeselectAnnotation:]. This is admittedly an elaborate workaround, and I agree that we should better facilitate your use case.andrewstay commentedon Jun 23, 2016
I still do not understand your concern about the case when POIs are not displayed/hidden. If map does not have/does not show POIs, it does not call any delegate callout method for those annotations. That simple.
Also, you could add additional optional method to the map delegate:
Or somethings like that to make sure delegate wants to receive callbacks when POIs are clicked.
1ec5 commentedon Jun 23, 2016
My point is that we’d be writing a feature specifically for the Mapbox Streets source, which is one out of many potential sources. I’m not ruling out the feature you’re requesting. Rather, in v3.3.0, the platform-specific code just doesn’t have the ability to know what source is being loaded, so it doesn’t know that, for example,
maki=busmeans a bus stop. (Using the Mapbox Studio dataset editor, you could for instance makemaki=busmean something entirely different.) The ability to distinguish between different sources is coming in v3.4.0, which would be the appropriate timeframe to revisit this issue.1ec5 commentedon Jan 17, 2018
#6515 would simplify the process of detecting the tap and associating it with a feature, but #4392 would still be required for making the callout functionality modular enough to work with non-annotations.
stale commentedon Oct 29, 2018
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Dec 5, 2018
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.