flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

[BUG] Should polygon bounding box cache never be reset ?

Open ibrierley opened this issue 1 year ago • 0 comments

What is the bug?

When investigating a problem updating flutter_map_line_editor I noted that polygons no longer display https://github.com/ibrierley/flutter_map_line_editor/issues/47

I'm fairly sure the issue is this line...

LatLngBounds get boundingBox =>
      _boundingBox ??= LatLngBounds.fromPoints(points);

Where a poly bounding box is cached, which makes perfect sense. In the line_editors case, typically points are added/modified, rather than created anew (which is a possible workaround I've noted in the other issue).

So the bounding box needs to be updated in this case one way or another. Like I said, this can be forced by creating a new poly each time (which I keep fluctuating between it making perfect sense and other times not). However, it also made me think if this is quite correct on flutter_maps side.

If the poly has checks for equality for example (not sure where this is used), or needs a repaint as the points are changed, if it's not equal, then should the bbox cache be updated...or in general should the bbox ever be updated ?

It won't be an issue in flutter_map for most cases as the points rarely change, but wanted to double check for any further thoughts.

How can we reproduce it?

Run flutter_map_line_editor, but code has been highlighted in question.

Do you have a potential solution?

There is a possible workaround to recreate the polygon rather than amend it's points.

Platforms

All

Severity

Minimum: Allows normal functioning

ibrierley avatar Jul 13 '24 10:07 ibrierley