Change map layer

Hi all,
I would like to give the possibility to change the map layer to user, but I do not know how to do it.
I create a map in mymap div and then give the instruction

mymap.setZoom(12);
				L.tileLayer("https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token="+token, {
					maxZoom: 18,
					attribution: "Map data © OpenStreetMap contributors,KeyFor",
					id: "mapbox/satellite-streets-v12",
					tileSize: 512,
					zoomOffset: -1
				}).addTo(mymap);

I think that I have to change on fly the row

id: "mapbox/with_map_I_whant"

but I think again that is wrong!!
How can I change map on fly?
Best regards and cheers

Sergio

2 posts - 2 participants

Read full topic


Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/change-map-layer/9427