diff --git a/resources/assets/es6/mapbox-utils.js b/resources/assets/es6/mapbox-utils.js index d700da96..b7340915 100644 --- a/resources/assets/es6/mapbox-utils.js +++ b/resources/assets/es6/mapbox-utils.js @@ -20,7 +20,23 @@ const addMapTypeOption = (map, menu, option, checked = false) => { input.setAttribute('checked', 'checked'); } input.addEventListener('click', function () { + let source = map.getSource('points'); map.setStyle('mapbox://styles/mapbox/' + option + '-v9'); + map.on('style.load', function () { + map.addLayer({ + 'id': 'points', + 'type': 'symbol', + 'source': { + 'type': 'geojson', + 'data': source._data + }, + 'layout': { + 'icon-image': '{icon}-15', + 'text-field': '{title}', + 'text-offset': [0, 1] + } + }); + }); }); let label = document.createElement('label'); label.setAttribute('for', option);