-
-
Notifications
You must be signed in to change notification settings - Fork 893
Closed
Description
Hi,
I have two map layers: OSM and MapBox Satellite:
layers: [
TileLayerOptions(
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
tileProvider: CachedNetworkTileProvider()
),
TileLayerOptions(
urlTemplate: 'https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}@2x.jpg90?access_token={accessToken}',
additionalOptions: {
'accessToken': '...'
},
tileProvider: CachedNetworkTileProvider()
)
]
Is there a way to add a layer switch to switch between both layers?
As workaround I tried to add a button with setState() in onPressed(). However, althought the build() is called, the underlying map is not changing:
_showSatellite = false;
...
layers: [
_showSatellite ? TileLayerOptions(/*mapbox*/) : TileLayerOptions(/*osm*/)
]
...
Button(
onPressed: () {
setState() {
_showSatellite = !_showSatellite;
}
}
)
Any help is appreciated :) Thanks in advance!
Edit: It seems that the layer changes. When I pan or zoom, the switch layer is shown. So, I need a way to refresh the currently shown tiles anyway...
Metadata
Metadata
Assignees
Labels
No labels