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: https://github.com/mapbox/mapbox-gl-native/pull/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
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
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?
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.
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.
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.
Most helpful comment
This would be a great feature for my use case on iOS. I'm drawing features in a symbol layer that all have
iconAllowsOverlapset 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 executesvisibleFeaturesInRect:inStyleLayersWithIdentifiers:a few times every second after adding the style layer.This solution isn't super clean. A callback would make things much better.