osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

Support scrolling on maps within ListView

Open Adam-D-Lewis opened this issue 2 years ago • 4 comments

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)

Adam-D-Lewis avatar Sep 21 '22 00:09 Adam-D-Lewis

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

liodali avatar Sep 23 '22 15:09 liodali

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

jeyremy avatar Feb 01 '24 13:02 jeyremy

yep

liodali avatar Feb 01 '24 13:02 liodali

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,

                   ),
                 ),
               ),
             )
           ],

         ),
       ),

     ],
      ),
  ),
);

jeyremy avatar Feb 01 '24 16:02 jeyremy