
I am plotting some points on a map with some tiles in the background. I am adding a select menu to chose from different tiles providers. When I change the provider the new tiles are displayed but on top of the points AND the former tiles which stay below.
How can I just replace the tiles by the new ones without piling up layers and keeping them below the points?
Example code below:
tiles = {‘OpenStreetMap c’: WMTSTileSource(url=‘http://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png’),
‘ESRI’: WMTSTileSource(url=‘https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg’)}#Setting up the figure
p = figure()
p.circle(‘x’, ‘y’, source=source)
p.add_tiles(tiles[‘ESRI’])#select menu
tile_prov_select = Select(title=“Tile Provider”, value=‘NA’, options=[‘OpenStreetMap c’, ‘ESRI’])#select menu action
def change_tiles_callback(attr, old, new):
p.add_tile(tiles[new])
tile_prov_select.on_change(‘value’, change_tiles_callback)
Thanks!


