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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'">
  <div id="header" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
    <span>Draw:<br /></span>
    <button data-dojo-type="dijit/form/Button">Point</button>
    <button data-dojo-type="dijit/form/Button">Multi Point</button>
    <button data-dojo-type="dijit/form/Button">Line</button>
    <button data-dojo-type="dijit/form/Button">Polyline</button>
    <button data-dojo-type="dijit/form/Button">Polygon</button>
    <button data-dojo-type="dijit/form/Button">Free Polyline</button>
    <button data-dojo-type="dijit/form/Button">Free Polygon</button>
    <!--The Arrow,Triangle,Circle and Ellipse types all draw with the polygon symbol-->
    <button data-dojo-type="dijit/form/Button">Arrow</button>
    <button data-dojo-type="dijit/form/Button">Triangle</button>
    <button data-dojo-type="dijit/form/Button">Circle</button>
    <button data-dojo-type="dijit/form/Button">Ellipse</button>
  <div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
#mainWindow {
  font-family: sans-serif;
  height: 100%;
  width: 100%;

body {
  margin: 0;
  padding: 0;

#header {
  height: 80px;
  overflow: auto;
  padding: 0.5em;
              var map, toolbar, symbol, geomTask, onDrawBegin;



  "dojo/parser", "dijit/registry", "dojo/on", "dojo/_base/array",

  "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
  "dijit/form/Button", "dijit/WidgetSet", "dojo/domReady!"
], function(
  Map, Draw, Graphic, esriColor,
  SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol,
  parser, registry, dojoOn, arrayUtils
) {

  map = new Map("map", {
    basemap: "streets",
    center: [-15.469, 36.428],
    zoom: 3

  map.on("load", createToolbar);

  // loop through all dijits, connect onClick event
  // listeners for buttons to activate drawing tools
  registry.forEach(function(d) {
    // d is a reference to a dijit
    // could be a layout container or a button
    if (d.declaredClass === "dijit.form.Button") {
      d.on("click", activateTool);

  function activateTool() {
    var tool = this.label.toUpperCase().replace(/ /g, "_");

  function createToolbar(themap) {
    toolbar = new Draw(map);
    toolbar.on("draw-begin", function() {
      try {
        arrayUtils.forEach(map.graphics.graphics, function(graphic) {
          if (graphic.symbol != null) {
            graphic.symbol.setColor(new esriColor([parseInt(Math.random() * 255, 10), parseInt(Math.random() * 255, 10), parseInt(Math.random() * 255, 10), 0.5]));
      } catch (err) {
    toolbar.on("draw-end", addToMap);

    // set up event listener to trigger the "draw-begin" event
    onDrawBegin = dojoOn.pausable(map, "mouse-down", function() {
      // test if you can pause the onDrawBegin after the event is called.
      if (onDrawBegin && typeof onDrawBegin.pause === "function") {
    // pause it for now

    // set up the draw-end event to reactivate onDrawBegin
    toolbar.on("draw-end, activate", function(evt) {
      // resume the onDrawBegin when you touch the map to draw again.

    /*toolbar.on("activate", function (evt) {
			  // resume the onDrawBegin when you touch the map to draw again.

    toolbar.on("deactivate", function(evt) {
      // pause draw event if the draw toolbar is deactivated

  function addToMap(evt) {
    var symbol;
    switch (evt.geometry.type) {
      case "point":
      case "multipoint":
        symbol = new SimpleMarkerSymbol();
      case "polyline":
        symbol = new SimpleLineSymbol();
        symbol = new SimpleFillSymbol();
    var graphic = new Graphic(evt.geometry, symbol);
    console.log("Symbol:", symbol);
    console.log("Graphic:", graphic);
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.