ibrierley / flutter_map_line_editor

A basic line/poly editor that works with flutter_map and dragmarkers.
MIT License
44 stars 25 forks source link

Upgrade to flutter_map v7 #47

Open bishen opened 1 month ago

bishen commented 1 month ago

Do you have any plans to support v7

ibrierley commented 1 month ago

Yes, just not in a rush atm as I think v7 needs to settle first. However, if anyone has a compelling reason, I'll try and make it happen sooner.

manlyman29 commented 3 weeks ago

@ibrierley It seems that v7 does not have a major breaking change. Personally I hope to see the upgrade happen on this library sooner :)

ibrierley commented 3 weeks ago

Heya, no there's not a breaking change, but I think there is an issue on latest release so I wouldn't recommend updating yet, this issue highlights the problem with polygons vanishing.. https://github.com/fleaflet/flutter_map/issues/1921 but if anyone needs a v7 version, I'll do an update.

Henk-Keijzer commented 1 week ago

It seems that the issue mentioned is solved in flutter_map 7.0.2. I would really appreciate an update of this package...

ibrierley commented 4 days ago

Ok, weird, I think something has gone astray with some flutter_map change (maybe), I can't get the polygon example to fill the poly. I can see there has been a change to isFilled, but I don't think that's related, as it doesn't draw borders if I include those in the poly params.

ibrierley commented 4 days ago

I think the problem is that in flutter_maps polygon.dart is has this line...

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

so it's caching the bounding box now. As the poly from an editor starts with nothing, I don't think that will get updated, so I'm assuming it just gets culled for optimisation every time...

I think it can be worked around by creating a new Poly every time, so it's never cached...so the code would look something like the following code. I'm not sure if I like this or not, as on the one hand, it cuts out the normal flutter flow (I'm a bit out of touch), on the other, it's an editor so performance not such an issue here, and also maybe it's more correct...not quite sure.

Any thoughts, let me know.

final polyPoints = <LatLng>[];

  @override
  void initState() {
    super.initState();

    polyEditor = PolyEditor(
      addClosePathMarker: true,
      points: polyPoints,
      pointIcon: const Icon(Icons.crop_square, size: 23),
      intermediateIcon: const Icon(Icons.lens, size: 15, color: Colors.grey),
      callbackRefresh: (LatLng? _) => {setState(() {})},
    );
  }

  @override
  Widget build(BuildContext context) {

    final polygons = <Polygon>[];
    final testPolygon = Polygon(
      label: 'Label!',
      color: Colors.deepOrange,
      borderColor: Colors.red,
      borderStrokeWidth: 4,
      points: polyPoints,
    );
    polygons.add(testPolygon);

    return Scaffold(
ibrierley commented 4 days ago

I have raised an issue at https://github.com/fleaflet/flutter_map/issues/1932 just to get some thoughts