我正在使用 flutter_map 应用程序,并且我有带有标记的地图设置,但我不知道如何使用 MapEventLongPress 类事件。
基本上我想长按地图并从事件中获取坐标,有人愿意帮助我朝那个方向前进吗?
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
class MapPage extends StatelessWidget {
const MapPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlutterMap(
options: MapOptions(center: LatLng(74, 40), minZoom: 10.0),
layers: [
TileLayerOptions(
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subdomains: ['a', 'b', 'c']
}),
MarkerLayerOptions(markers: [
Marker(
width: 45.0,
height: 45.0,
point: LatLng(74, 40),
builder: (context) => Container(
child: IconButton(
icon: Icon(Icons.location_on),
color: Colors.red,
iconSize: 45.0,
onPressed: () async {
},
)
)
)
],
),
]
);
}
}
谷歌上的内容不多,我只能在https://pub.dev/documentation/flutter_map/latest/flutter_map.plugin_api/MapEventLongPress-class.html找到类文档,但我真的需要一些示例代码才能开始.