Leaflet Multiple Geojson with time slider

created for this stackoverflow question http://stackoverflow.com/q/40832849/3067143

by Muhammad Muzaffar

HTML

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.0/dist/leaflet.css">
<link rel="stylesheet" href="https://ismyrnow.github.io/Leaflet.groupedlayercontrol/src/leaflet.groupedlayercontrol.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script src="https://unpkg.com/leaflet@1.0.0/dist/leaflet-src.js"></script>
<script src="https://rawgit.com/dwilhelm89/LeafletSlider/master/SliderControl.js"></script>
<script src="https://ismyrnow.github.io/Leaflet.groupedlayercontrol/src/leaflet.groupedlayercontrol.js"></script>
<div id='map'></div>

CSS

#map {
      width:600px;
      height:400px;
    }

JavaScript

var blocks1995 =
    {
    "type": "FeatureCollection",
    "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
    "features": [
    { "type": "Feature", "properties": { "time": 1995, "density": 3, "nameB": "BlockA"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 50.0, 29.0 ], [ 50.0, 29.99], 
                                                                                                                                              [50.51, 29.99], [ 50.0, 29.0 ] ] ] } },
    { "type": "Feature", "properties": { "time": 1995, "density": 2, "nameB": "BlockB"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 50.01, 30.0 ], [ 50.52, 30.0],[50.52, 30.5] ] ] } }
    ]
    };

    
    
    var blocks1996 =
    {
    "type": "FeatureCollection",
    "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
    "features": [
    { "type": "Feature", "properties": { "time": 1996, "density": 2, "name": "BlockA"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 50.0, 29.0 ], [ 50.0, 29.99], [50.51, 29.99] ] ]  } },
    { "type": "Feature", "properties": { "time": 1996, "density": 1, "name": "BlockB"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 50.01, 30.0 ], [ 50.52, 30.0],[50.52, 30.5] ] ] } }
    ]
    };
    
    var blocks1997 =
    {
    "type": "FeatureCollection",
    "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
    "features": [
    { "type": "Feature", "properties": { "time": 1997, "density": 4, "name": "BlockA"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 50.0, 29.0 ], [ 50.0, 29.99], [50.51, 29.99] ] ]  } },
    { "type": "Feature", "properties": { "time": 1997, "density": 3, "name": "BlockB"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 50.01, 30.0 ], [ 50.52, 30.0],[50.52, 30.5] ] ] } }
    ]
    };
    
    
    
    var blocks1998 =
    {
    "type": "FeatureCollection",
    "crs": { "type": "name",...