Closed jesussmile closed 1 year ago
Hi, After i use this plugin, the gesture detector on overlayImages are not working anymore for example here, if i remove the CurrentLocationLayer the gestures work else not.
CurrentLocationLayer
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map_location_marker/flutter_map_location_marker.dart'; import 'package:fly_nepal/screens/scale_plugin.dart'; import 'package:latlong2/latlong.dart'; class MapWithDraggableImage extends StatefulWidget { @override _MapWithDraggableImageState createState() => _MapWithDraggableImageState(); } class _MapWithDraggableImageState extends State<MapWithDraggableImage> { LatLng _imagePosition = LatLng(27.41, 85.23); late LatLng _lastPosition; MapController _mapController = MapController(); List<BaseOverlayImage> image = [ OverlayImage( bounds: LatLngBounds(LatLng(27.41, 85.23), LatLng(26.41, 84.23)), imageProvider: AssetImage('assets/guras_aip.png')) ]; @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Column( children: [ SizedBox( height: 950, child: FlutterMap( mapController: _mapController, options: MapOptions( center: _imagePosition, //zoom: 13.0, swPanBoundary: LatLng(26.347892, 80.067963), // Southwest corner of Nepal nePanBoundary: LatLng(30.446945, 88.201523), zoom: 10, minZoom: 3, interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag, ), nonRotatedChildren: [ ScaleLayerWidget( options: ScaleLayerPluginOption( lineColor: Colors.white, lineWidth: 2, textStyle: const TextStyle(color: Colors.white, fontSize: 12), padding: const EdgeInsets.only(top: 30))), ], children: [ TileLayer( urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", subdomains: ['a', 'b', 'c'], ), GestureDetector( onTap: printu, onPanStart: _onDragStart, onPanUpdate: _onDragUpdate, onPanEnd: _onDragEnd, child: OverlayImageLayer( overlayImages: image, ), ), CurrentLocationLayer(), ], ), ), ], ), )); } printu() { print("hello"); } void _onDragStart(DragStartDetails details) { _lastPosition = _imagePosition; } void _onDragUpdate(DragUpdateDetails details) { final Offset offset = details.delta; final double zoomScale = _mapController.zoom; final double latAdjust = offset.dy / 111111.0 * zoomScale; final double lngAdjust = offset.dx / 111111.0 * zoomScale / cos(_imagePosition.latitude); final LatLng newPosition = LatLng(_lastPosition.latitude - latAdjust, _lastPosition.longitude + lngAdjust); setState(() { _imagePosition = newPosition; }); } void _onDragEnd(DragEndDetails details) { _lastPosition = LatLng(0, 0); } }
one solution is to use ignorePointers is there any other way ?
ignorePointers
Reordering the layers may help. Try to put CurrentLocationLayer right after the TileLayer.
TileLayer
Hi, After i use this plugin, the gesture detector on overlayImages are not working anymore for example here, if i remove the
CurrentLocationLayer
the gestures work else not.