Markers being rebuild without moving map
When adding UserLocationOptions to the map layers it causes my map markers to rebuild every second which has a performance issue since I'm adding hundreds of Markers to the map. The same thing happens when zooming/panning the map but that's more understandable as this requires the markers to be redrawn.
Steps to reproduce the behaviour:
- Add Markers to a flutter_map
- Add
UserLocationOptionsto the layers - Add debug code to print out the Marker build function
I have tried setting a higher value in locationUpdateIntervalMs to reduce the frequency of the rebuild but that does not seem to reduce the frequency or the rebuild. This is on a physical Android device.
Interested to know if this is by design, any easy way around it or I need to look on how my Markers are build?
TIA!
Hi, thank you for pointing out the issue.
No, that is not a choice by design.
The reason you are facing performance issues might be because we rebuild all the markers every locationUpdateIntervalMs, not when the map moves or you zoom in/out.
This is a problem in the plugin itself I guess, and we would need to make changes to how markers are rendered, one quick try could be to delete and add only those markers whose position is changed and see if that changes anything
widget.options.markers.remove(_locationMarker);
widget.options.markers.add(_locationMarker);
I am quite busy with my exams, as of now, I am really sorry I am not able to work on this issue as of now. Please, write back if you found a solution to the issue, and once again thank you for this issue.
No worries, I will try to find a way in the meantime. I'm beginner/intermediate with Flutter so just wanted to see if I was doing something terrible wrong or not. I'll keep you updated. Good luck with the exams!