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.
getPointAnnotationsInBounds with a rotated map #5151
This is a follow up issue on #5051. In that issue we implemented that camera animations and projection should take MapView padding into account. While testing my changes for projection, I started to notice that getAnnotationsInBounds was not returning the actual annotations for the projection.
After some debugging and playing around with some values. I started to notice that having tilt = 0 and direction = 0 returns the correct annotations in bounds, When the map is rotated we aren't receiving the correct values anymore.
Example
In below gif I'm seeing the top left marker as an annotations in bounds even though it's not a part of the current projection. When I make the map face north again it becomes a part of the projection.
Are you sure you’re passing in a suitable bounding box? When the map is rotated, a bounding box obtained by converting the four corners of the view to coordinates may circumscribe or be circumscribed by the actual viewport. (See mbgl::Map::cameraForLatLngs() for an attempt at compensating for rotation.) Additionally, when the map is tilted, the viewport covers a trapezoidal region rather than a rectangular region. To find all the visible annotations using getPointAnnotationsInBounds(), you need to specify a bounding box that somehow circumscribes the visible region.
We ran into the same issue on iOS: #4801 (comment). In fb759e8, @boundsj worked around this issue by removing the call to annotationTagsInRect(), instead iterating over an index of annotations in the SDK code to find the annotations within bounds. (This is also explains the behavior in #5138 (comment) .)
Thanks for 👀 @1ec5 , I guess I was doing the same as what iOS was doing. Will look into adding the same fix in next days. Now that it's clear it isn't a core bug, adding android label.
I still think it would be worthwhile at some point to go back to getPointAnnotationsInBounds() (or perhaps queryRenderedFeatures()) on iOS, because then we can take advantage of the indexing that AnnotationManager performs, to avoid any penalty for annotations that are nowhere near the viewport.
As explained in #5165 (comment), I think we’ll have to punt on fixing getPointAnnotationsInBounds() until querySourceFeatures() is implemented as part of #352.
Closing as inittial observation was not correct and we are planning to resolve this with querySourceFeatures(). See #5165 for more information. Closing for now.
Activity
1ec5 commentedon May 26, 2016
Are you sure you’re passing in a suitable bounding box? When the map is rotated, a bounding box obtained by converting the four corners of the view to coordinates may circumscribe or be circumscribed by the actual viewport. (See
mbgl::Map::cameraForLatLngs()for an attempt at compensating for rotation.) Additionally, when the map is tilted, the viewport covers a trapezoidal region rather than a rectangular region. To find all the visible annotations usinggetPointAnnotationsInBounds(), you need to specify a bounding box that somehow circumscribes the visible region.We ran into the same issue on iOS: #4801 (comment). In fb759e8, @boundsj worked around this issue by removing the call to
annotationTagsInRect(), instead iterating over an index of annotations in the SDK code to find the annotations within bounds. (This is also explains the behavior in #5138 (comment) .)tobrun commentedon May 26, 2016
Thanks for 👀 @1ec5 , I guess I was doing the same as what iOS was doing. Will look into adding the same fix in next days. Now that it's clear it isn't a core bug, adding
androidlabel.1ec5 commentedon May 26, 2016
I still think it would be worthwhile at some point to go back to
getPointAnnotationsInBounds()(or perhapsqueryRenderedFeatures()) on iOS, because then we can take advantage of the indexing thatAnnotationManagerperforms, to avoid any penalty for annotations that are nowhere near the viewport.jfirebaugh commentedon May 26, 2016
Is it possible for the SDKs to switch over to
queryRenderedFeaturesso we can removegetPointAnnotationsInBoundsentirely?1ec5 commentedon May 26, 2016
Yes, I’m looking into this now. All that should be required is for the
AnnotationTileFeatures to know their IDs.1ec5 commentedon May 27, 2016
As explained in #5165 (comment), I think we’ll have to punt on fixing
getPointAnnotationsInBounds()untilquerySourceFeatures()is implemented as part of #352.[core, android, ios, osx] Replaced getPointAnnotationsInBounds() w/ q…
tobrun commentedon Jun 23, 2016
Closing as inittial observation was not correct and we are planning to resolve this with
querySourceFeatures(). See #5165 for more information. Closing for now.[core, android, ios, macos] Replaced getPointAnnotationsInBounds() w/…