Custom map panes in Leaflet 1.0.0beta1

by Alex Azuero

HTML

<script src="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.css">
<div id="map"></div>

CSS

html, body, #map {
    height: 100%;
    width:100%;
    padding:0px;
    margin:0px;
}
.dotLegend {
    border-radius: 50%;
    width: 10px;
    height: 10px;
    display:inline-block;
}
.bdotColor {
    background: #20a0ff;
}
.gdotColor {
    background: #40b060;
}
.rdotColor {
    background: #b04040;
}

JavaScript

////////////////////////////////////////////////////////////////////////////////////////////
//setting up the map//
////////////////////////////////////////////////////////////////////////////////////////////

// set center coordinates
var centerlat = 34.05;
var centerlon = -118.25;

// set default zoom level
var zoomLevel = 10;

// initialize map
var map = L.map('map').setView([centerlat, centerlon], zoomLevel);

// set source for map tiles
ATTR = '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a> | ' +
'&copy; <a href="http://cartodb.com/attributions">CartoDB</a>';

CDB_URL = 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png';

// add tiles to map
L.tileLayer(CDB_URL, {attribution: ATTR}).addTo(map);

////////////////////////////////////////////////////////////////////////////////////////////
//creating some synthetic GeoJSON data//
////////////////////////////////////////////////////////////////////////////////////////////

//initialize
var bdotlayer;
var bdots;
var bdotcount = 200;

var gdotlayer;
var gdots;
var gdotcount = 75;

var rdotlayer;
var rdots;
var rdotcount = 100;

//cheapo normrand function
function normish(mean, range) {
    var num_out = ((Math.random() + Math.random() + Math.random() + Math.random() - 2) / 2) * range + mean;
    return num_out;
}

//create geojson data with random ~normal distribution
function make_bdots() {

    bdots = {
        type: "FeatureCollection",
        features: []
    };

    for (var i = 0; i < bdotcount; ++i) {

        //set up random variables
        x = normish(0, 3);
        y = normish(0, 3);

        //create points randomly distributed about center coordinates
        var g = {
            "type": "Point",
                "coordinates": [((x * 0.1) + centerlon), ((y * 0.1) + centerlat)]
        };

        //create feature properties, with year roughly proportional to distance from center...