igaurab/user_location_plugin

Location marker disappears

Closed this issue · 2 comments

Describe the bug
Location marker disappears for a moment every time markers change

To Reproduce
Steps to reproduce the behavior:

  1. Use the example project
  2. Make the markers list change, f.ex. by clicking on a button

Expected behavior
The location marker should stay where it is without disappearing

Actual behavior
The location marker disappears for a moment before coming back

I've run into this issue. Happens when updating the UI through setState... figure out a fix?

Update: calling setState is what breaks the plugin

I fixed this by removing all markers except the user marker, it's ghetto but it works.

In my solution I use a combination of https://github.com/synw/map_controller and this hack.

For all your normal markers create a marker class that extends Marker, then wherever your are building empty the set and repopulate it without removing the user
Something like...
_statefulMapController.markers.removeWhere((Marker marker) => marker is MyMarkerClass);

I should note that I don't redraw the map once it is instanced.