-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support selection of shape and polyline annotations #2082
Comments
General Android annotation selection has been on my plate over in #1969 but is incomplete. As for shapes, I don't think MapKit even supports this, or if it does, I know for a fact it doesn't support callouts on them. We hit this with the raster SDK and it was due to difficult callout placement algorithms. But we could try here? |
This would be nice for Leaflet parity. |
The way this is done in JS is with
EDIT: AFIK |
You don't necessarily need to support callouts. Perhaps just a way to select/hit test polygons. |
We definitely need callout support as well as selection. |
+1 for callout support as well. |
Would it be acceptable to require the developer to indicate where on a polyline/polygon the callout should attach? That would take the guesswork off of the framework. We could support some simple options like top/bottom/left/right/centroid and leave it at that. The problem is when you get into polylines like this — where do you attach the callout? Prior art: mapbox/DEPRECATED-mapbox-ios-sdk#285 |
Definiteyly, that's a lot better than not being able to do it at all! |
@incanus The callout for line can be attached to a 'point on the line' that passed the hit-test for tap. |
Aye, tapped-point would be the most intuitive solution for polyline callouts. Polygons, seems like centroid would be best? |
@friedbunny Please leave an option to set any point or tapped point on the polygon as well. Centroid won't always work in our use case. |
Callout arrows aside, this is trickier without full support for |
#5502 (which I think we should fold into #5165) adds support for selecting polygon and polyline annotations. As to the default callout anchor point strategy, another consideration is that the shape may extend beyond the viewport, meaning that an obvious anchor point like the centroid could fall outside the viewport. We’d have to crop the shape to the viewport before computing an anchor point. As an alternative to adjusting the callout anchor point of a shape, once #5502/#5165 lands, you could also display your own callout in response to a shape annotation getting selected. As part of #4392, we could perhaps expose an API for displaying a popup independently of a particular annotation; you’d use that API to create a popup that you could position anywhere you want on the shape. |
The anchor placement issue illustrated in #2082 (comment) would be addressed by a port of @mourner's Polylabel library to C++. The additional consideration in #2082 (comment) still applies, but mbgl probably already has a solution for clipping polygons that could be reused for this problem. |
While we wait for a port of Polylabel, plan B would be to anchor the callout as close as possible to the tap location. This would require porting some minimal Turf functionally from JavaScript. Then once Polylabel is ready, we could switch to that implementation without any API changes. |
Polylabel was integrated into mbgl in #7070. |
I am implementing the workaround, since I need support for tapping polylines representing route sections. For simplicity the whole route is one section at the moment. I cannot find any ways to associate the MGLPolylineFeature returned from |
Comparing the returned feature’s coordinates is currently the only way to match feature querying results with a feature you’re interested in. See this document for guidance on working with |
Howdy! I've seen several references to being able to get an event at click/touch MGLPolyLine where you might release it at 3.4.1. It's currently 3.4.2. Can you give a current estimate of when you think that feature will be realized? I appreciate all of the effort and any direction you can lend on this would be helpful. Thanks! |
@iFarmSupport I obviously can't speak on behalf of the developers, but in case you need a temporary workaround, mine is just that.
Returned polyline:
Depending on your use case, it is definitely possible to match the returned line with original. For my use case, I found a simpler solution though. I keep references to all the polylines the user can tap on (it is never too many) and then check for intersection of bounds.
The side effect of this is that bounds refers to whole shape, rather than line. (True marks where tap is detected) |
Removing |
Hi class CustomPolygonFeature: MGLPolygonFeature { I am adding these polygons on top of mapView using .add(Overlay:) method let spot = gesture.location(in: mapView) I am expecting the result to be Is there anything wrong? |
@CodeKunal, this is an inherent limitation of the feature querying APIs and runtime styling in general: #6178. In #9540, we amended the documentation to note this limitation. |
This feature was implemented for in #9984, which is in iOS map SDK v3.7.0 and will be in macOS SDK v0.6.0 shortly. |
We explicitly don't support selecting non-point annotations in iOS (820d2da), so polylines and polygons aren't particularly interactive yet.
Related: #1504
/cc @incanus @1ec5
The text was updated successfully, but these errors were encountered: