Change a map's style

Switch to another map style. See the example: https://docs.mapbox.com//mapbox-gl-js/example/setstyle/

by jscastro76

HTML

<script src="https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.js"></script>
<link rel="stylesheet" href="https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.css">



<div id="map"></div>

CSS

body { margin: 0; padding: 0; }
	#map { position: absolute; top: 0; bottom: 0; width: 100%; }

JavaScript

mapboxgl.accessToken = 'PASTE HERE YOUR TOKEN';
		var map = new mapboxgl.Map({
		  container: 'map',
		  style: 'mapbox://styles/mapbox/streets-v11',
		  center: [-122.486052, 37.830348],
		  zoom: 14
		});


		map.on('style.load', function() {

		  map.on('click', function(e) {
		    var coordinates = e.lngLat;

		    new mapboxgl.Popup()
		      .setLngLat(coordinates)
		      .setHTML('you clicked here: <br/>' + coordinates)
		      .addTo(map);
		  });
		});