Google maps 我想实现GoogleMapView来获取用户点击的位置
在安卓系统中,我可以调用GooglePlaces屏幕,让用户选择一个位置来保存它,我想用Flatter来实现这一点 我搜索并发现几乎没有实现这一点,我知道现在这是最正式的图书馆(仍然没有实现我想做的事情)Google maps 我想实现GoogleMapView来获取用户点击的位置,google-maps,flutter,google-places,Google Maps,Flutter,Google Places,在安卓系统中,我可以调用GooglePlaces屏幕,让用户选择一个位置来保存它,我想用Flatter来实现这一点 我搜索并发现几乎没有实现这一点,我知道现在这是最正式的图书馆(仍然没有实现我想做的事情) 而且它还没有完成(开发者预览)我在我的pubspec中使用它 map_view: git: url: git://github.com/Eimji/flutter_google_map_view 然后您可以在地图上捕获onclick事件 mapView.onMapTap
而且它还没有完成(开发者预览)我在我的pubspec中使用它
map_view:
git:
url: git://github.com/Eimji/flutter_google_map_view
然后您可以在地图上捕获onclick事件
mapView.onMapTapped.listen((location) {
currentLatitude = location.latitude;
currentLongitude = location.longitude;
//Show only one marker
mapView.clearAnnotations();
mapView.setMarkers(
[Marker("1", "Location", currentLatitude, currentLongitude)]);
//Do whatever you want with the chosen location
mapView.setCameraPosition(
CameraPosition(Location(currentLatitude, currentLongitude), 18));
.............
});
GoogleMap(
onTap: _mapTapped,
compassEnabled: true,
onMapCreated: makeController,
initialCameraPosition: CameraPosition(
target: LatLng(40.712776,-74.005974),
zoom: 12.0,
),
)
_mapTapped(LatLng location) {
print(location);
// The result will be the location you've been selected
// something like this LatLng(12.12323,34.12312)
// you can do whatever you do with it
}