cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

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

<p>Draw GeoJSON Features and make them 3D.
  Use the toolbar on the map to draw a polygon or a rectangle.<br>
Enter a height value to change object's extrusion at any time.</p>

<p>Height: <input type="text" value="100" maxlength="4" size="4" onkeyup="setHeight(this)"></p>
            
          
!
            
              body {
  font-family: sans-serif;
  padding: 5px;
  margin: 0;
}

#map {
  width: 300px;
  height: 300px;
  float: left;
  margin: 0 15px 0 0;
}

            
          
!
            
              var map = new L.Map('map');
map.setView([52.52111, 13.40988], 16, false);

new L.TileLayer('http://{s}.tiles.mapbox.com/v3/osmbuildings.kbpalbpk/{z}/{x}/{y}.png', {
  attribution: 'Map tiles &copy; <a href="http://mapbox.com">MapBox</a>',
  maxZoom: 18,
  maxNativeZoom: 20
}).addTo(map);

var osmb = new OSMBuildings(map).date(new Date('2015-07-15 10:00:00'));

//********************************************************

var color = '#ffcc00',
  height = 100,
  feature;

function setHeight(el) {
  height = parseInt(el.value);
  setGeoJson();
}

function setGeoJson() {
  if (!feature) {
    return;
  }
  feature.properties = {
    color: color,
    height: height
  };
  var geoJson = {
    type: 'FeatureCollection',
    features: [feature]
  };
  osmb.set(geoJson);
}

document.addEventListener('DOMContentLoaded', function() {
  var drawControl = new L.Control.Draw({
    draw: {
      polyline: false,
      polygon: {
        allowIntersection: false,
        shapeOptions: { color:color }
      },
      rectangle: {
        shapeOptions: { color:color }
      },
      circle: false,
      marker: false
    }
  });
  map.addControl(drawControl);

  map.on('draw:created', function (e) {
    feature = e.layer.toGeoJSON();
    setGeoJson();
  });
});


            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console