liodali / osm_flutter

OpenStreetMap plugin for flutter
https://pub.dev/packages/flutter_osm_plugin
MIT License
231 stars 97 forks source link

Support scrolling on maps within ListView #334

Open Adam-D-Lewis opened 2 years ago

Adam-D-Lewis commented 2 years ago

If you create a map within a ListView and try to scroll, you'll scroll the ListView instead of the map. It would be nice to be able to override the default behavior to instead preferentially scroll the map. One option of what this might look like to users could be similar to what google_maps_flutter does. That package gets around the issue by allowing users to pass in gestureRecognizers directly (https://stackoverflow.com/a/57088480/9848141)

liodali commented 2 years ago

ok i will check that but i will be better to provide me real use case

jeyremy commented 8 months ago

i would be interested in this too. @liodali what do you need ? an exemple of the issue ?

liodali commented 8 months ago

yep

jeyremy commented 8 months ago

Ok mate;

Here is an exemple of map not scrolling zooming : in this exemple you have a singleChildScrollView with column and two children. map is the second one and all gestures are retained by scrollview.

Google map has made a work around like @Adam-D-Lewis said, i did tested it and work great. it would be awesome to have it in OSM


Scaffold( key: scaffoldKey, backgroundColor: ColorRes.white, appBar: null, body: SingleChildScrollView( child: Column( children: [ Container( margin: const EdgeInsets.only(bottom: 24), padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( children: [ Container( height: 500, color: Colors.lightGreen, ), SizedBox( width: double.infinity, height: 450, child: OSMFlutter( controller:controller, mapIsLoading: Center( child: Container(), ), osmOption: OSMOption( roadConfiguration: const RoadOption( roadColor: Colors.yellowAccent, ), markerOption: MarkerOption( defaultMarker: const MarkerIcon( icon: Icon( Icons.location_on, color: Colors.blue, size: 56, ), ) ), userTrackingOption: const UserTrackingOption( enableTracking: false, unFollowUser: false, ), zoomOption: const ZoomOption( initZoom: 12, minZoomLevel: 10, maxZoomLevel: 18, stepZoom: 1.0,

                   ),
                 ),
               ),
             )
           ],

         ),
       ),

     ],
      ),
  ),
);