Skip to content
This repository has been archived by the owner on Jul 11, 2021. It is now read-only.

Markers being rebuild without moving map #90

Open
Swepilot opened this issue Jan 8, 2021 · 2 comments
Open

Markers being rebuild without moving map #90

Swepilot opened this issue Jan 8, 2021 · 2 comments

Comments

@Swepilot
Copy link

Swepilot commented Jan 8, 2021

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:

  1. Add Markers to a flutter_map
  2. Add UserLocationOptions to the layers
  3. 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!

@igaurab
Copy link
Owner

igaurab commented Jan 9, 2021

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.

@Swepilot
Copy link
Author

Swepilot commented Jan 9, 2021

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants