这是Flutter Map的代码
void showFlutterMap(){
return new FlutterMap(
options: new MapOptions(
center: new LatLng(51.5, -0.09),
zoom: 13.0,
),
layers: [
new TileLayerOptions(
urlTemplate: "https://api.tiles.mapbox.com/v4/"
"{id}/{z}/{x}/{y}@2x.png?access_token={accessToken}",
additionalOptions: {
'accessToken': '<PUT_ACCESS_TOKEN_HERE>',
'id': 'mapbox.streets',
},
),
new MarkerLayerOptions(
markers: [
new Marker(
width: 80.0,
height: 80.0,
point: new LatLng(51.5, -0.09),
builder: (ctx) =>
new Container(
child: new FlutterLogo(),
),
),
],
),
],
);
}
答案 0 :(得分:1)
我知道它已经有一段时间了,但是为了在flutter_map中更改地图中心,您只需要更改MapOptions的center属性值。它是 LatLng 对象,可接受纬度和经度。
options: new MapOptions(
center: new LatLng(51.5, -0.09),
zoom: 13.0,
),
答案 1 :(得分:0)
您可以在FlutterMap小部件中添加一个MapController(在您的应用中定义)
MapController _mapctl = MapController();
...
void showFlutterMap(){
return new FlutterMap(
mapController: _mapctl,
...
);
}
然后您必须移至新位置
latlng = LatLng(coordinates_you_want);
double zoom = 4.0; //the zoom you want
_mapctl.move(latlng,zoom);