FlutterMap(
options: MapOptions(
onTap: (p, point) async {
GeoData location = await Geocoder2.getDataFromCoordinates(
latitude: p.latitude, longitude: p.longitude, googleMapApiKey: '');
);
print("${location.country}");
setState((){
point=p;
});
},
center: LatLng(49.5, -0.09),
zoom: 10.0
),我正试图在我的颤振应用程序中使用geocoder2来处理地图。但我正面临着这个错误。如果有人能帮忙,那就太好了。
LatLng point=LatLng(49, -1);这是我的变量声明。现在的错误是:
The getter 'latitude' isn't defined for the type 'TapPosition'.The getter 'longitude' isn't defined for the type 'TapPosition'.A value of type 'TapPosition' can't be assigned to a variable of type 'LatLng'. point: point, builder: (ctx)=> Icon(这是我试图使用点的错误。
发布于 2022-07-13 19:22:54
onTap回调提供tapPosition和point。
typedef TapCallback = void Function(TapPosition tapPosition, LatLng point);包含另一个用于解决此情况的参数,如
onTap: (tapPos, p) async {更多关于MapOptions和map/TapCallback的信息
更新
完整的片段就像
LatLng point = LatLng(49, -1);
GeoData? location;
...
FlutterMap(
options: MapOptions(
onTap: (f, p) async {
p.latitude;
location = await Geocoder2.getDataFromCoordinates(
latitude: p.latitude,
longitude: p.longitude,
googleMapApiKey: '');
setState(() {
point = p;
});
},
zoom: 10.0,
center: LatLng(49, -1)),
);注意使用包的问题
latlong2和geocoder2
https://stackoverflow.com/questions/72971531
复制相似问题