JSFiddle - React, Tailwind, and code Playground

by denvut

HTML

<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css">
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<script src="http://kiro.me/javascript/projects/fuse.min.js"></script>


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

CSS

#map {
    width:500px;
    height:400px;
}
body, html {
    font-family:Helvetica, Arial, sans-serif;
    padding:20px;
}
h1 {
  font-size:18px;
}
h2 {
    font-size:14px;
}
p{
    font-weight:bold;
}
p,li {
    font-size:12px;
    margin:5px 0;
}
ol {
    margin-left:25px;
    list-style-type:decimal;
}
.leaflet-fusesearch-control {
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    background: #fff;
    border-radius: 5px;
}

.leaflet-fusesearch-control .button {
    background-position: 50% 50%;
    background-repeat: no-repeat;
    background-image: url(../images/search.png);
    display: block;
    width: 36px;
    height: 36px;
}
.leaflet-touch .leaflet-fusesearch-control .button {
    width: 44px;
    height: 44px;
}

.leaflet-fusesearch-panel {
    position: absolute;
    height: 100%;
    width: 350px;
    
    z-index: -1;
    opacity: 0;
    -webkit-transition: opacity 0.3s linear;
    -moz-transition: opacity 0.3s linear;
    -o-transition: opacity 0.3s linear;
    transition: opacity 0.3s linear;

    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    padding: 10px;
}

.leaflet-fusesearch-panel .content {
    height: 100%;
    width: 100%;
    
    overflow: auto;
    -webkit-overflow-scrolling: touch;

    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    padding: 8px 20px;

    background: white;
    box-shadow: 0 1px 7px rgba(0,0,0,0.65);
    -webkit-border-radius: 6px;
    border-radius: 6px;

    color: black;
    font-size: 1.1em;
}

.leaflet-fusesearch-panel.left {
    left: 0;
}

.leaflet-fusesearch-panel.right {
    right: 0;
}

.leaflet-fusesearch-panel.visible {
    opacity: 1;
    z-index: 2000;
}


.leaflet-fusesearch-panel .close {
    position: absolute;
    right: 25px;
    top: 15px;
    width: 30px;
    height: 30px;
    color: #333;
    font-size: 25pt;
    line-height: 1em;
    text-align: center;
    background: white;
   ...

JavaScript

// From http://www.tutorialspoint.com/javascript/array_map.htm
if (!Array.prototype.map)
{
  Array.prototype.map = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun !== "function")
      throw new TypeError();

    var res = new Array(len);
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        res[i] = fun.call(thisp, this[i], i, this);
    }

    return res;
  };
}

L.Control.FuseSearch = L.Control.extend({
    
    includes: L.Mixin.Events,
    
    options: {
        position: 'topright',
        title: 'Search',
        panelTitle: '',
        placeholder: 'Search',
        caseSensitive: false,
        threshold: 0.5,
        maxResultLength: null,
        showResultFct: null,
        showInvisibleFeatures: true
    },
    
    initialize: function(options) {
        L.setOptions(this, options);
        this._panelOnLeftSide = (this.options.position.indexOf("left") !== -1);
    },
    
    onAdd: function(map) {
        
        var ctrl = this._createControl();
        this._createPanel(map);
        this._setEventListeners();
        map.invalidateSize();
        
        return ctrl;
    },
    
    onRemove: function(map) {
        
        this.hidePanel(map);
        this._clearEventListeners();
        this._clearPanel(map);
        this._clearControl();
        
        return this;
    },
    
    _createControl: function() {

        var className = 'leaflet-fusesearch-control',
            container = L.DomUtil.create('div', className);

        // Control to open the search panel
        var butt = this._openButton = L.DomUtil.create('a', 'button', container);
        butt.href = '#';
        butt.title = this.options.title;
        var stop = L.DomEvent.stopPropagation;
        L.DomEvent.on(butt, 'click', stop)
                  .on(butt, 'mousedown', stop)
                  .on(butt, 'touchstart', stop)
                  .on(butt, 'mousewheel', stop)
                 ...