Google maps 颤振:如何在谷歌地图上的不同位置放置mylocation按钮?
我正在使用谷歌地图,默认情况下,myLocation按钮显示在右上角。我想把它放在右下角。 我似乎在GoogleMap小部件中没有任何属性Google maps 颤振:如何在谷歌地图上的不同位置放置mylocation按钮?,google-maps,flutter,Google Maps,Flutter,我正在使用谷歌地图,默认情况下,myLocation按钮显示在右上角。我想把它放在右下角。 我似乎在GoogleMap小部件中没有任何属性 GoogleMap( myLocationEnabled: true, myLocationButtonEnabled: true, initialCameraPosition: CameraPosition( target: _currentLocation,
GoogleMap(
myLocationEnabled: true,
myLocationButtonEnabled: true,
initialCameraPosition: CameraPosition(
target: _currentLocation,
zoom: 11.0,
),
onMapCreated: _onMapCreated,
),
尝试使用
浮动按钮
GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
myLocationEnabled: true,
),
floatingActionButton: FloatingActionButton.extended(
onPressed: _currentLocation,
label: Text('My Location'),
icon: Icon(Icons.location_on),
),
);
}
也可以使用当前位置进行设置
void _currentLocation() async {
final GoogleMapController controller = await _controller.future;
LocationData currentLocation;
var location = new Location();
try {
currentLocation = await location.getLocation();
} on Exception {
currentLocation = null;
}
controller.animateCamera(CameraUpdate.newCameraPosition(
CameraPosition(
bearing: 0,
target: LatLng(currentLocation.latitude, currentLocation.longitude),
zoom: 17.0,
),
));
}
我使用了你代码中的controller.animateCamera来适应我的代码,它工作得非常好。干杯它提供了更多的控制。但与此同时,奇怪的是,我们没有使用GoogleMap小部件本身进行这种开箱即用的控制。