Trans Siberian Leaflet

This was a great learning experience. Same as the GitHub example, but now with Leaflet.

Leaflet code:

<script type="text/javascript">
var map = L.map('map').setView([45,77], 4);

L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
    attribution: 'Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">',
maxZoom: 18,
    subdomains: '1234',
    }).addTo(map);

function style(feature) {
    return {
        weight: 3,
        opacity: 0.6,
        color: 'red',
    };
}
	
var route = new L.geoJson(route, {
		style: style,
    }).addTo(map);


</script>

In addition we have the following in the header:

<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"> </script>
<script src="route.js"></script>

So the route is being read directly from a .geojson file. Although it has been renamed to route.js, and “var route = [” has been added to the beginning of the file and “]” to the end.

Leave a Reply

Your email address will not be published. Required fields are marked *