Linking separate JSON objects together to create a GeoJSON Feature Collection in Leaflet
HTML
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css">
<div id="map"></div>
CSS
html, body, #map {
height: 100%;
width:100%;
padding:0px;
margin:0px;
background: white;
}
JavaScript
var map = L.map('map').setView([39.74739, -105], 13);
// set source for map tiles
ATTR = '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a> | ' +
'© <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);
var freeBusGeom = {
"type": "FeatureCollection",
"features": [{
"id": 1,
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-105.00341892242432, 39.75383843460583],
[-105.0008225440979, 39.751891803969535]
]
}
}, {
"id": 2,
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-105.0008225440979, 39.751891803969535],
[-104.99820470809937, 39.74979664004068]
]
}
}, {
"id": 3,
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-104.99820470809937, 39.74979664004068],
[-104.98689651489258, 39.741052354709055]
]
}
}]
};
var lightRailStopGeom = {
"type": "FeatureCollection",
"features": [{
"id": 11,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-104.98999178409576, 39.74683938093904]
}
}, {
"id": 12,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-104.98689115047453, 39.747924136466565]
}
}]
};
var bicycleRentalGeom = {
"type": "FeatureCollection",
"features": [{
"id": 51,
...