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

iOS equivalent to Android setOnPolylineClickListener #10934

Closed
bradmartin opened this issue Jan 16, 2018 · 2 comments
Closed

iOS equivalent to Android setOnPolylineClickListener #10934

bradmartin opened this issue Jan 16, 2018 · 2 comments

Comments

@bradmartin
Copy link

Platform:
iOS
Mapbox SDK version:
pod 'Mapbox-iOS-SDK', '~> 3.7.3'

Unfortunately, this isn't an issue, I've tried stackoverflow here and it bugs me even opening an issue on the repo 馃槩 so apologies from me.

I've been working with the SDKs for sometime now and am very familiar with android but iOS is not my strong suit and being more comfortable with java/android its hard for me to follow iOS naming conventions and the other bits. At any rate, my question is in the SO post and I'm looking for a way to define some click/tap event on polylines and polygons when they're added to the map. Android provides the clickListeners to set it but I cannot find an approach for iOS. I've poured over the docs so if this is in there I'd gladly accept a link response to silence me 馃槃 .

Here is how I'm adding the source to the map and it does get added just fine but of course now I have no clue on how to approach setting up a click listener for that polyline (I'm working on adding polygons too but not there yet).

 const shape = MGLShape.shapeWithDataEncodingError(
        geo,
        NSUTF8StringEncoding
      );
      const source = MGLShapeSource.alloc().initWithIdentifierShapeOptions(
        polylineID,
        shape,
        null
      );
      theMap.style.addSource(source);

      const layer = MGLLineStyleLayer.alloc().initWithIdentifierSource(
        polylineID,
        source
      );
@jmkiley
Copy link
Contributor

jmkiley commented Jan 16, 2018

Hi @bradmartin -

You can use -mapView:didSelectAnnotation: to handle taps on a MGLPolyline. This example shows how to add a polyline with our annotations API.

With a MGLLineStyleLayer, you will need to implement a tap gesture recognizer that accesses visible features. Hope this helps!

@bradmartin
Copy link
Author

bradmartin commented Jan 16, 2018

Yes, thank you very much @jmkiley - it pained me to open this issue 馃槥 but I very much appreciate the answer. I assume the didSelectAnnotation approach would work for a polygon as well 馃 ?

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

No branches or pull requests

2 participants