Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
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

Closed

Description

@andrewstay

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

Activity

  1. added
    iOS
    on Jun 22, 2016
  2. boundsj commented on Jun 22, 2016

    @boundsj
    Contributor

    Related #5110

  3. 1ec5 commented on Jun 22, 2016

    @1ec5
    Contributor

    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.

  4. andrewstay commented on Jun 23, 2016

    @andrewstay
    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).
  5. 1ec5 commented on Jun 23, 2016

    @1ec5
    Contributor

    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.

  6. andrewstay commented on Jun 23, 2016

    @andrewstay
    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.

  7. 1ec5 commented on Jun 23, 2016

    @1ec5
    Contributor

    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.

  8. 1ec5 commented on Jan 17, 2018

    @1ec5
    Contributor

    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.

  9. stale commented on Oct 29, 2018

    @stale

    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.

  10. added
    archived
    on Oct 29, 2018
  11. stale commented on Dec 5, 2018

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    archivedfeatureiOSruntime styling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions