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

Markes not dragging #20

Closed Mmisiek closed 2 years ago

Mmisiek commented 2 years ago

Hi, This plugin is really great but I can't make markers to drag. My map structure:

  _flutterMap = FlutterMap(
      options: _mapOptions,
      mapController: _mapController,
      layers: [
        _mapStyle == MAP_STYLE_STREETS
            ? new TileLayerOptions(
                urlTemplate:
                    "https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}",
              )
            : new TileLayerOptions(
                urlTemplate:
                    "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.jpg"),
        new PolygonLayerOptions(
          // concatenat ecurrent list with selected
          polygons: _polygonsList,
        ),
        new MarkerLayerOptions(
          markers: _markersList,
        ),
        new MarkerLayerOptions(
          markers: _currentPosition != null ? [_currentPosition] : [],
        ),
        new DragMarkerPluginOptions(markers: _polyEditor.edit()),
      ],
    );

And MapOptions:

    _mapOptions = new MapOptions(
      // if position not known yet set center of US.
      center: _position != null
          ? LatLng(_position.latitude, _position.longitude)
          : LatLng(38.576525, -121.493217),
      zoom: _zoom,
      onTap: (_tapPosition, _latLng) => handleTap(_latLng),
      onPositionChanged: (position, hasGesture) =>
          handleMove(position, hasGesture),
      plugins: [
        DragMarkerPlugin(),
      ],
    );

I get polyline with markers, I think I can even add new marker to the line but dragging does not work at all :(. Thanks

ibrierley commented 2 years ago

I'll try and take a peek tomorrow at this an the other issue. What is _polyEditor.edit() (it may be useful to see that code), does it just return a list of dragmarkers or something, it could be that is resetting the list with a new one each time ? Have you tried with a List of DragMarkers to start off with like the example ?

Mmisiek commented 2 years ago
    _polyEditor = new PolyEditor(
      addClosePathMarker: true,
      points: _editPolyline.points,
      pointIcon: Icon(Icons.crop_square, size: 23),
      intermediateIcon: Icon(Icons.lens, size: 15, color: Colors.grey),
      callbackRefresh: () => {this.setState(() {})},
    );
      _currentFieldPolygon.points.forEach((latLng) {
        _polyEditor.add(_editPolyline.points, latLng);
      });

I will try with hardcoded list, it is possible it gets refreshed each time I touch ? But my guess is somehow events are not getting to right layer ?

Thanks

Mmisiek commented 2 years ago

Looks like "drag" drags map not marker.

ibrierley commented 2 years ago

Sorry, ignore my last comment, I misunderstood what you were doing...I will take a look tomorrow as I have to go offline now, if you can paste a minimal example highlighting the problem, I will try and test.

ibrierley commented 2 years ago

Out of interest, it may be worth trying to comment out onPositionChanged in MapOptions, just to see if it prevents some grabbing of the drag. Just to isolate if there is some conflict. I don't think it would be that...but maybe start with the line_editor main.dart example and slow reintroduce your parts and see when it breaks.

Mmisiek commented 2 years ago

I will try to write minimal example tonight or tomorrow morning. Thanks for your help.

Mmisiek commented 2 years ago

commenting onPositionChanged did nothing :( the markers get deleted when long press, so events somehow get there.

Mmisiek commented 2 years ago

BTW. you know you example does not work with new Dart/Flutter, onTap has 2 parameters now.

Mmisiek commented 2 years ago

So, I am sorry to say but even your example does not work anymore, you can add and remove markers but not drag them. My version is:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.1, on macOS 11.4 20F71 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.60.2)
[✓] Connected device (2 available)

I had to add "tp" to the onTap as it flutter_map API changed and replace latlng with latlng2. I suspect something in flutter_map API has changed.

ibrierley commented 2 years ago

Ah I think you need to be using the nullsafety branch on this and dragmarker...I think I will move them into master though a bit later,

On Fri, Oct 1, 2021 at 11:34 PM Mmisiek @.***> wrote:

So, I am sorry to say but even your example does not work anymore, you can add and remove markers but not drag them. My version is:

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, 2.5.1, on macOS 11.4 20F71 darwin-x64, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)

[✓] Xcode - develop for iOS and macOS

[✓] Chrome - develop for the web

[✓] Android Studio (version 4.2)

[✓] VS Code (version 1.60.2)

[✓] Connected device (2 available)

I had to add "tp" to the onTap as it flutter_map API changed and replace latlng with latlng2. I suspect something in flutter_map API has changed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932615073, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5YN5KYAEDBV2BOFWZTDM3UEYZQRANCNFSM5FFP23NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Mmisiek commented 2 years ago

For the moment I am using new version of Dart but without null safety. I would need to change a lot of code to migrate to null safety. But I will update your example and force null safety in your code and check if it works.

On Fri, Oct 1, 2021, 23:59 Ian @.***> wrote:

Ah I think you need to be using the nullsafety branch on this and dragmarker...I think I will move them into master though a bit later,

On Fri, Oct 1, 2021 at 11:34 PM Mmisiek @.***> wrote:

So, I am sorry to say but even your example does not work anymore, you can add and remove markers but not drag them. My version is:

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, 2.5.1, on macOS 11.4 20F71 darwin-x64, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)

[✓] Xcode - develop for iOS and macOS

[✓] Chrome - develop for the web

[✓] Android Studio (version 4.2)

[✓] VS Code (version 1.60.2)

[✓] Connected device (2 available)

I had to add "tp" to the onTap as it flutter_map API changed and replace latlng with latlng2. I suspect something in flutter_map API has changed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932615073 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA5YN5KYAEDBV2BOFWZTDM3UEYZQRANCNFSM5FFP23NQ

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932696850, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABC7O4NOQJL5FD2TYPM3BMTUE2UWPANCNFSM5FFP23NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ibrierley commented 2 years ago

Ok, flutter_map 0.14.0 breaks dragmarker (and hence line_editor), it works with 0.13.1.

I suspect something is overriding/conflicting with the drag/pan start, as I can't even get onPanStart to fire any more. I'm not sure how easy it will be to fix, but it looks like that's the problem.

On Sat, Oct 2, 2021 at 12:46 PM Mmisiek @.***> wrote:

For the moment I am using new version of Dart but without null safety. I would need to change a lot of code to migrate to null safety. But I will update your example and force null safety in your code and check if it works.

On Fri, Oct 1, 2021, 23:59 Ian @.***> wrote:

Ah I think you need to be using the nullsafety branch on this and dragmarker...I think I will move them into master though a bit later,

On Fri, Oct 1, 2021 at 11:34 PM Mmisiek @.***> wrote:

So, I am sorry to say but even your example does not work anymore, you can add and remove markers but not drag them. My version is:

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, 2.5.1, on macOS 11.4 20F71 darwin-x64, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)

[✓] Xcode - develop for iOS and macOS

[✓] Chrome - develop for the web

[✓] Android Studio (version 4.2)

[✓] VS Code (version 1.60.2)

[✓] Connected device (2 available)

I had to add "tp" to the onTap as it flutter_map API changed and replace latlng with latlng2. I suspect something in flutter_map API has changed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932615073

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AA5YN5KYAEDBV2BOFWZTDM3UEYZQRANCNFSM5FFP23NQ

. Triage notifications on the go with GitHub Mobile for iOS <

https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android <

https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932696850 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABC7O4NOQJL5FD2TYPM3BMTUE2UWPANCNFSM5FFP23NQ

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932738084, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5YN5L4KZFFLOSDYEBUX3LUE3WHRANCNFSM5FFP23NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Mmisiek commented 2 years ago

Ok, I was about to write to you I tried null safe option and same happened (no drag). Not sure if I can rollback map to 0.13.1, I will try.

From: Ian @.> Date: Saturday, October 2, 2021 at 5:41 AM To: ibrierley/flutter_map_line_editor @.> Cc: Mmisiek @.>, Author @.> Subject: Re: [ibrierley/flutter_map_line_editor] Markes not dragging (#20) Ok, flutter_map 0.14.0 breaks dragmarker (and hence line_editor), it works with 0.13.1.

I suspect something is overriding/conflicting with the drag/pan start, as I can't even get onPanStart to fire any more. I'm not sure how easy it will be to fix, but it looks like that's the problem.

On Sat, Oct 2, 2021 at 12:46 PM Mmisiek @.***> wrote:

For the moment I am using new version of Dart but without null safety. I would need to change a lot of code to migrate to null safety. But I will update your example and force null safety in your code and check if it works.

On Fri, Oct 1, 2021, 23:59 Ian @.***> wrote:

Ah I think you need to be using the nullsafety branch on this and dragmarker...I think I will move them into master though a bit later,

On Fri, Oct 1, 2021 at 11:34 PM Mmisiek @.***> wrote:

So, I am sorry to say but even your example does not work anymore, you can add and remove markers but not drag them. My version is:

Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, 2.5.1, on macOS 11.4 20F71 darwin-x64, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)

[✓] Xcode - develop for iOS and macOS

[✓] Chrome - develop for the web

[✓] Android Studio (version 4.2)

[✓] VS Code (version 1.60.2)

[✓] Connected device (2 available)

I had to add "tp" to the onTap as it flutter_map API changed and replace latlng with latlng2. I suspect something in flutter_map API has changed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932615073

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AA5YN5KYAEDBV2BOFWZTDM3UEYZQRANCNFSM5FFP23NQ

. Triage notifications on the go with GitHub Mobile for iOS <

https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android <

https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932696850 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABC7O4NOQJL5FD2TYPM3BMTUE2UWPANCNFSM5FFP23NQ

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932738084, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5YN5L4KZFFLOSDYEBUX3LUE3WHRANCNFSM5FFP23NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932745884, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABC7O4IMLSXVCKFBOINAIEDUE34ZFANCNFSM5FFP23NQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ibrierley commented 2 years ago

I think the solution for 0.14.0 is to use allowPanningOnScrollingParent: false in MapOptions (allowPanningOnScrollingParent I think was introduced at https://github.com/fleaflet/flutter_map/pull/994 which was rolled into 0.14 which wasn't obvious at all there was a breaking change in there).

See if that helps, if it does, I think I will add that to the docs and merge nullsafety with the master.

ibrierley commented 2 years ago

Note, I've added a new branch "panfix" if you want to try that (it uses a new branch of dragmarker called panfix also).

If I get a confirmation or two that things work, I'll move to master

Mmisiek commented 2 years ago

Hi Ian, I think this works (at least your example) :) Can you update master and nullsafe branches ? I prefer to use master (no null dafe) at the moment. Thanks for fixing it. Michal

ibrierley commented 2 years ago

I have merged it with master, so see how you go.

In reality, it's not really a fix thinking about it, it's simply adding allowPanningOnScrollingParent: false, to the example and readme I guess! But it should help others.

If it all works ok, thanks for raising the issue and testing etc!

Mmisiek commented 2 years ago

Can you kick cupertino_icons too ? Because every version of flutter_map_line_editor from git depends on flutter_map_dragmarker from git which depends on cupertino_icons ^0.1.2, every version of flutter_map_line_editor from git requires cupertino_icons ^0.1.2. So, because pest_scope depends on both cupertino_icons ^1.0.3 and flutter_map_line_editor from git, version solving failed.

ibrierley commented 2 years ago

That any better ?

Mmisiek commented 2 years ago

I would saybit work as expected. Thanks

On Sat, Oct 2, 2021, 13:59 Ian @.***> wrote:

That any better ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ibrierley/flutter_map_line_editor/issues/20#issuecomment-932819573, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABC7O4IJZZFEAODDGM53WX3UE5XB3ANCNFSM5FFP23NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.