cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title>Display a map</title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.js'></script>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.css' rel='stylesheet' />
    <style>
        body { margin:0; padding:0; }
        #map { position:absolute; top:0; bottom:0; width:100%; }
    </style>
</head>
<body>

<div id='map'></div>
</body>
</html>

            
          
!
            
              body {
  margin: 0;
  padding: 0;
}

#map {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}
            
          
!
            
              mapboxgl.accessToken = 'pk.eyJ1Ijoid29yYWNlIiwiYSI6ImNpeWMxOW1jcjAwYWUyd294ZzQ0YnMyZ3QifQ.ZaWekMcNTGFN-TmpPkf9AA';

var map = new mapboxgl.Map({
    container: 'map', // container id
    style: 'mapbox://styles/mapbox/streets-v9', // stylesheet location
    center: [-118.4184041619301, 34.05771049652868], // starting position [lng, lat]
    zoom: 17 // starting zoom
});

var data = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "point_source": "user_upload"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -118.4184041619301,
          34.05771049652868
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "point_source": "admin_upload"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -118.4185041619301,
          34.05771249652868
        ]
      }
    }
  ]
};

// Wait for map to fully load before trying to add data
map.on('load', function() {
  map.addSource('some-points', {type: 'geojson', data: data});
  map.addLayer({
    'id': 'point-circles',
    'type': 'circle',
    'source': 'some-points', // Matched ID we gave to our source above
    'paint': {
      'circle-color': [
        'match',
        ['get', 'point_source'],
        'user_upload', '#ff0000',
        '#0000ff'
      ]
    }
  });
});

            
          
!
999px
Loading ..................

Console