fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.68k stars 848 forks source link

[BUG] Unstable `PolygonLayer` & `PolylineLayer` #1921

Closed IAmHereAtGithub closed 5 days ago

IAmHereAtGithub commented 1 week ago

What is the bug?

The users clicks min. 4 points on the map to draw an area. The polygon will not be drawn at all zoom levels and cannot be deleted. (This worked fine on flutter map version 6.0.1, but no more on 7.0.0/7.0.1 .

How can we reproduce it?

I have uploaded the code for reproduction Link to github. I recorded the behavior in this video:

https://github.com/fleaflet/flutter_map/assets/89143144/292bfada-6b12-49e1-8736-de4baa7c17d4

Manual reproduction:

  1. Run the project on an android emulator.
  2. Click on the pen icon to get in the edit mode.
  3. Draw an area by clicking min. 4 times in the map.
  4. Click on the pen icon to get out of the edit mode.
  5. You will see no polygon between the circles (bug).
  6. Zoom out and/or zoom in, the polygon will be shown.
  7. Click on the X on the right bottom button, this should clear the circle and polygon lists.
  8. The polygon (depending on the zoom level) will not be cleared and will stay forever.

Do you have a potential solution?

I tried to debug flutter map. It looks like that in the state.dart , the _cachedSimplifiedElements don´t recognized that a new polygon is created in the zoom level. And general the _cachedProjectedElements will not getting updated if the user cleared the polygon.

Platforms

e.g. Android emulator Pixel 7

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console

IAmHereAtGithub commented 1 week ago

Hi!

I know that this is not the solution, but if I comment out line 74 in the \lib\src\layer\shared\layer_projection_simplification\state.dart: if (getElements(oldWidget) == elements) return;

Everything works.

rhogro commented 1 week ago

I noticed the exact same behavior on my app too. I use a PolylineLayer to display a geojson track and on some specific zoom level the polylines disappear, but on other levels they show up. image image

JaffaKetchup commented 1 week ago

Hi all, We're aware we're having some issues with these layers right now, I've added a notice to the documentation front page and will try to remember to pin an issue. For the time being, please downgrade to v7.0.0 or v6.2.1. We're working to fix the issue, please have patience as the maintainers are quite busy at the moment! You may also be able to avoid the issue by setting useDynamicUpdate false and potentially assigning a UniqueKey - but this could have no effect or make things worse.