maplibre / flutter-maplibre-gl

Customizable, performant and vendor-free vector and raster maps, flutter wrapper for maplibre-native and maplibre-gl-js (fork of flutter-mapbox-gl/maps)
https://pub.dev/packages/maplibre_gl
Other
186 stars 106 forks source link

map in stack with Widget on top, if click drag on widget the map move on Web, not on iOs #391

Closed chrisDupuis closed 2 months ago

chrisDupuis commented 3 months ago

On Web (this is ok on iOs) I create a Stack with in first the Map then widget over the map. When I click (and drag) on widget the widget receive the events, but the map receive the events too and the map move as the cursor drag.

How to prevent that ?

chrisDupuis commented 3 months ago

To test, modify the sample CustomMarker

@override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ MaplibreMap( // CHD styleString: getSpotsydeMapStyle(), trackCameraPosition: true, onMapCreated: _onMapCreated, onMapLongClick: _onMapLongClickCallback, onCameraIdle: _onCameraIdleCallback, onStyleLoadedCallback: _onStyleLoadedCallback, initialCameraPosition: const CameraPosition(target: LatLng(35.0, 135.0), zoom: 5), iosLongClickDuration: const Duration(milliseconds: 200), ),

      Stack(
        children: _markers,
      )

// IgnorePointer( // ignoring: false, // child: Stack( // children: _markers, // ))

The _markers should consume the mouse event

stefanschaller commented 2 months ago

@chrisDupuis This is a known issue with PlatformViews in general. Could be fixed by using the following library: https://pub.dev/packages/pointer_interceptor

Just wrap your button into a PointerInterceptor()