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

[iOS] Support callout for POI (public transport stops, etc) #5432

Closed
andrewstay opened this issue Jun 22, 2016 · 9 comments
Closed

[iOS] Support callout for POI (public transport stops, etc) #5432

andrewstay opened this issue Jun 22, 2016 · 9 comments
Labels
archived Archived because of inactivity feature iOS Mapbox Maps SDK for iOS runtime styling

Comments

@andrewstay
Copy link

SDK should have a functionality to display callouts (including custom ones) for a different POIs preferably public transport stops.

Platform: iOS
Mapbox SDK version: 3.2.2

Steps to trigger behavior

User taps on the public transport stop

Expected behavior

  1. MapView calls appropriate delegate methods to obtain the callout
  2. MapView presents callout to the user

Actual behavior

No callbacks are called to MapView delegate

@boundsj boundsj added iOS Mapbox Maps SDK for iOS feature labels Jun 22, 2016
@boundsj
Copy link
Contributor

boundsj commented Jun 22, 2016

Related #5110

@1ec5
Copy link
Contributor

1ec5 commented 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
Copy link
Author

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.

  1. 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.
  2. 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).

@1ec5
Copy link
Contributor

1ec5 commented 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
Copy link
Author

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:

-[MGLMapViewDelegate mapView:shouldRecognizeFeatureType:]

Or somethings like that to make sure delegate wants to receive callbacks when POIs are clicked.

@1ec5
Copy link
Contributor

1ec5 commented 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=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.

@1ec5
Copy link
Contributor

1ec5 commented Jan 17, 2018

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.

@stale
Copy link

stale bot commented 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 stale bot added the archived Archived because of inactivity label Oct 29, 2018
@stale
Copy link

stale bot commented 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.

@stale stale bot closed this as completed Dec 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived Archived because of inactivity feature iOS Mapbox Maps SDK for iOS runtime styling
Projects
None yet
Development

No branches or pull requests

3 participants