Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="map"></div>
<div id="search">
  <input type="text" placeholder="keyword (eg: brewery)" id="keyword" />


                body{ margin:0; }

#map {
    margin: 0;
    position: absolute;
    bottom: 0;

#search {
  position: absolute;
  background: rgba(255,255,255,1);
  right: 120px;
  top: 10px;
  padding: 5px;
  font-family: Verdana;
  font-size: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.4);

#search input {
  font-size: 16px;
  width: 100%;
  box-sizing: border-box;

.leaflet-control-layers label span.key {
  display: inline-block;
  background: red;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  margin-left: 0;
  border-radius: 10px;
/* leaflet responsive */
@media screen and (max-width: 375px){
  .leaflet-top.leaflet-left {
    top: 50px;
  #search {
    left: 10px;
/* leaflet markercluster stuff */
.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
	-webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-in;
	-moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in;
	-o-transition: -o-transform 0.3s ease-out, opacity 0.3s ease-in;
	transition: transform 0.3s ease-out, opacity 0.3s ease-in;


                var attribution_nypl = 'Map via <a href="">NYPL</a>';

// manhattan 1857
var ny_1857 = L.tileLayer( '{z}/{x}/{y}.png',{attribution: attribution_nypl});

// brooklyn 1855
var bk_1855 = L.tileLayer( '{z}/{x}/{y}.png',{attribution: attribution_nypl});

var attribution_mapbox = 'Map via <a href="">OpenStreetMap</a>, <a href="">Mapbox</a>';

// present
var ny_2014 = L.tileLayer( 'https://{s}{id}/{z}/{x}/{y}.png',{id: 'nypllabs.7f17c2d1',attribution: attribution_mapbox});

var oldMaps = L.layerGroup([ny_1857, bk_1855]);

// for the toggler
var baseMaps = {
  "Present": ny_2014,
  "1857-9": oldMaps

// the tileset switcher control
var control = L.control.layers(baseMaps,{}, {collapsed:false});
// create map with default tileset
var map ='map', {layers:ny_2014, maxZoom:21, minZoom:12, scrollWheelZoom:true});


// the geojson as it comes from the text document
var jsonurl = '';

var topNames, geodata, geolayer, control;
var words, colors, overlays;
var markers;
var bounds = new L.LatLngBounds();
var searchOverlay;
var overlays = [];
words = ["church","coal","office","house","drug","factory","school","stable","lumber","works","bank"];
colors = ["#1f78b4","#888","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#b15928","#000"];

function showMap(geostring) {
  // parse the geojson string to a proper json structure
  geodata = JSON.parse(geostring);
  console.log("found", geodata.features.length,"places");

  legend = document.getElementById("legend");

  for (var i=0; i<words.length; i++) {
    var c = colors[i];
    var t = words[i];
    var html = '<span class="key" style="background:'+c+'"></span>' + t;
    // overlay
    var places = extractPlaces(geodata, t, i);
    var overlay = overlayForPlaces(places);
  	control.addOverlay(overlay, html);

  geolayer = L.geoJson(topNames);
  // zoom the map to the bounds of the points
  document.getElementById("keyword").onchange = onKeywordSubmitted;

function showPopup(feature, layer) {
    var key, val;
    var content = [];
    for (key in {
        val =[key];
        if (key=="consensus") content.push(val);
    layer.bindPopup(content.join("<br />"));

function extractPlaces(raw, place, index) {
  result = {}
  result.type = raw.type;
  result.features = [];
  for (var i=0; i<raw.features.length; i++) {
    if (raw.features[i].properties.consensus.toLowerCase().indexOf(place) != -1) {
      raw.features[i].properties.index = index;
  return result;

var client = new XMLHttpRequest();'GET', jsonurl);
client.onloadend = function() {

function hidePopular() {
  for (var o in overlays) {
    var layer = overlays[o];
    if(map.hasLayer(layer)) {

function search(keyword) {
  if (searchOverlay) {
  var places = extractPlaces(geodata, keyword, colors.length-1);
  if (places.features.length==0) return;
  searchOverlay = overlayForPlaces(places);

function onKeywordSubmitted(event) {
  var keyword =; = keyword;
  if (keyword != "") search(keyword);

function clearMap() {
  if (searchOverlay) {

function overlayForPlaces(places) {
  return L.geoJson(places, {
    pointToLayer: function (f,latlon) {
      return, 10, {
        color: colors[],
        fillOpacity: 0.1,
        stroke: colors[],
        strokeWidth: 1,
        strokeOpacity: 1
    onEachFeature: showPopup