Reputation: 29
Here is the code of 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(),
),
),
],
),
],
);
}
Upvotes: 3
Views: 6237
Reputation: 31
You can add a MapController (defined in your app) in your FlutterMap widget
MapController _mapctl = MapController();
...
void showFlutterMap(){
return new FlutterMap(
mapController: _mapctl,
...
);
}
Then you have to move into the new location
latlng = LatLng(coordinates_you_want);
double zoom = 4.0; //the zoom you want
_mapctl.move(latlng,zoom);
Upvotes: 3
Reputation: 2105
I know it's been a while, but in order to change the center of map in flutter_map you just need to change the values of center property of MapOptions. It's a LatLng object which accepts Latitude and Longitude.
options: new MapOptions(
center: new LatLng(51.5, -0.09),
zoom: 13.0,
),
Upvotes: 1