我正在扑打传单。我建立了标记生成器以使它们动态移动。 我有一个按钮可以使地图以我确定的坐标为中心。
这是用于创建地图的小部件。
Widget _initMap(BuildContext context){
return Stack(
children: <Widget>[
new FlutterMap(
options: Mapoptions(
minzoom: _minzoom,maxzoom: _maxzoom,center: LatLng(mylatitude,mylongitude),),layers: [
new TileLayerOptions(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',subdomains: ['a','b','c']),new MarkerLayerOptions(
markers: _generateMarker(context)
),]
),Align(
alignment: Alignment.bottomRight,child: Padding(
padding: EdgeInsets.all(20.0),child: new FloatingactionButton(
onpressed: (){_initMap(context);},child: Icon(Icons.gps_fixed),],);
}
我希望按钮重新创建_initMap小部件,以便地图将根据变量mylatitude和mylongitude重置其中心,因为这两个变量是动态变化的。 有人知道该怎么做吗?