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

[core] Add callback for collision detection #15441

Closed
julianrex opened this issue Aug 21, 2019 · 5 comments
Closed

[core] Add callback for collision detection #15441

julianrex opened this issue Aug 21, 2019 · 5 comments
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity Core The cross-platform C++ core, aka mbgl feature iOS Mapbox Maps SDK for iOS

Comments

@julianrex
Copy link
Contributor

It would be useful to have a callback when collision detection has run. This could be a new RendererObserver function or an additional parameter to onDidFinishRenderingFrame (proof of concept by @pozdnyakov here: #15440).

This can be useful after camera changes, when the developer then wants to query features (e.g. annotations) in the camera change completion callback/block (for example see @astojilj's comment here).

/cc @tobrun

@julianrex julianrex added iOS Mapbox Maps SDK for iOS Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl labels Aug 21, 2019
@asheemmamoowala
Copy link
Contributor

This can be useful after camera changes, when the developer then wants to query features

How does a a developer know when to and when not to depend on this new callback? If a style has no symbol layer, it would never invoke this callback. It makes it hard to write generic code to do this after a camera change is complete because it requires knowing if the style currently loaded has symbol layers

@julianrex
Copy link
Contributor Author

This is a good point - I was thinking that we would need a separate iOS delegate method anyway (referencing "collision detection" isn't particularly user friendly), so that logic could potentially check for symbol layers. Do you think that would be sufficient @asheemmamoowala @pozdnyakov?

@pozdnyakov
Copy link
Contributor

pozdnyakov commented Aug 23, 2019

referencing "collision detection" isn't particularly user friendly

right, we probably should not expose "placement update" status but rather use it as an internal flag in the SDK implementation.

@johnnewman
Copy link

This would be a great feature for my use case on iOS. I'm drawing features in a symbol layer that all have iconAllowsOverlap set to false. I also have a UI component on screen that corresponds to each of the visible features in that style layer. To draw this custom component, I need to know which features are going to be hidden by the SDK's collision detection and which will be visible.

The delegate mapViewDidBecomeIdle: is reliable, but its execution can be delayed. Since there isn't a fast callback for this case, my solution was to create a timer that executes visibleFeaturesInRect:inStyleLayersWithIdentifiers: a few times every second after adding the style layer.

This solution isn't super clean. A callback would make things much better.

@stale stale bot added the archived Archived because of inactivity label Aug 2, 2020
@stale
Copy link

stale bot commented Aug 2, 2020

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 Aug 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android archived Archived because of inactivity Core The cross-platform C++ core, aka mbgl feature iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

5 participants