Geojson - multipolygons - bring to front

by Leo

HTML

<link rel="stylesheet" href="http://leafletjs.com/dist/leaflet.css">
<script src="http://leafletjs.com/dist/leaflet.js"></script>
<script src="http://leafletjs.com/examples/sample-geojson.js"></script>
<div id="map" style="width: 100%; height: 400px"></div>

JavaScript

var map = L.map('map').setView([39.74739, -105], 13);
L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {
    maxZoom: 18,
    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
        '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
        'Imagery © <a href="http://mapbox.com">Mapbox</a>',
    id: 'examples.map-20v6611k'
}).addTo(map);


var jsonHolder = new L.FeatureGroup().addTo(map);//.bringToFront();
var bikeRental = L.geoJson([bicycleRental, campus], {
    onEachFeature: onEachFeature,
    style: function (feature) {
        return feature.properties && feature.properties.style;
    },
    pointToLayer: function (feature, latlng) {
        return L.circleMarker(latlng, {
            radius: 8,
            fillColor: "#ff7800",
            color: "#000",
            weight: 1,
            opacity: 1,
            fillOpacity: 0.8
        });
    }
}).addTo(jsonHolder);

var markerHolder = new L.FeatureGroup().addTo(map);//.bringToBack();
L.marker([39.74, -105.01]).addTo(markerHolder).bindPopup("I am a green leaf.");
L.marker([39.74, -105]).addTo(markerHolder).bindPopup("I am a red leaf.");
L.marker([39.745, -105.005]).addTo(markerHolder).bindPopup("I am an orange leaf.");




function onEachFeature(feature, layer) {
    var popupContent = "<p>I started out as a GeoJSON " + feature.geometry.type + ", but now I'm a Leaflet vector!</p>";

    if (feature.properties && feature.properties.popupContent) {
        popupContent += feature.properties.popupContent;
    }
    layer.bindPopup(popupContent);
}






var coorsLayer = L.geoJson(coorsField, {
    pointToLayer: function (feature, latlng) {
        return L.marker(latlng);    
    },
    onEachFeature: onEachFeature
}).addTo(jsonHolder);