presented by:
Email us at: Alicia.Cowart@Colorado.EDU & Philip.White@Colorado.EDU
All of the following should be inserted within the <script> tag. See comments in the mapbox_starter.html document for where to place each snippet.
mapboxgl.accessToken = 'TOKEN GOES HERE';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/your_style',
zoom: 6.75,
center: [-105.547222, 39.0]
});
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
map.on('load', function () {
map.addSource('CO_Ski_Areas', {
type: 'geojson',
data: 'https://raw.githubusercontent.com/outpw/workshopdata/master/Colorado_Ski_Areas.geojson'
});
map.addLayer({
'id': 'Ski Areas',
'type': 'circle',
'source': 'CO_Ski_Areas',
'paint': {
'circle-radius': 6,
'circle-color': '#B42222'
},
});
});
map.addLayer({
'id': 'Ski Areas',
'type': 'symbol',
'source': 'CO_Ski_Areas',
'layout': {
'icon-image': 'ski-bum',
},
map.on('mousemove', 'Ski Areas', function () {
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', 'Ski Areas', function () {
map.getCanvas().style.cursor = '';
});
map.on('click', 'Ski Areas', function (e) {
new mapboxgl.Popup()
.setLngLat(e.lngLat)
.setHTML('<h3>' + e.features[0].properties.Name + '</h3><p>' + e.features[0].properties.description +'</p>')
.addTo(map);
});