gtfs distance calculation
by andi_lo
HTML
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css">
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://api.mapbox.com/mapbox.js/plugins/leaflet-geodesy/v0.1.0/leaflet-geodesy.js"></script>
<script src=" https://npmcdn.com/@turf/turf/turf.min.js"></script>
<script src="https://cdn.jsdelivr.net/lodash/4.17.4/lodash.min.js"></script>
<div id="map"></div>
CSS
#map {
height: 500px;
}
JavaScript
var map = L.map("map").setView([ 42.382618,-70.97362
], 12);
L.tileLayer('https://stamen-tiles.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// add a marker to the map
var geojson = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"name": "shape",
"route_color": "#FFFF7C"
},
"geometry": {
"type": "LineString",
"coordinates": [
[-70.97167,
42.372665
],
[-70.97447,
42.376347
],
[-70.97464,
42.37667
],
[-70.9758,
42.37868
],
[-70.97588,
42.378918
],
[-70.976,
42.37937
],
[-70.97602,
42.379604
],
[-70.976036,
42.379868
],
[-70.976,
42.38025
],
[-70.975945,
42.380463
],
[-70.97584,
42.380753
],
[-70.97571,
42.380993
],
[-70.97513,
42.381744
],
[-70.97489,
42.38193
],
[-70.974014,
42.38254
],
[-70.97377,
42.382664
],
[-70.97362,
42.382618
],
[-70.97355,
42.382675
],
[-70.973145,
42.38293
],
[-70.97291,
42.383102
],
[-70.97283,
42.383144
],
[-70.97273,
42.383244
],
[-70.9726,
42.383465
],
[-70.97266,
42.383663
],
[-70.97282,
42.384094
],
[-70.972885,
42.384212
],
[-70.97301,
42.38434
],
[-70.973404,
42.384617
],
[-70.97409,
42.38516
],
...