Simple Polylines
by agraebe
HTML
<div id="map"></div>
CSS
<style type='text/css'>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.2.0/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.2.0/mapbox.css' rel='stylesheet' />
<style>
</style>
JavaScript
L.mapbox.accessToken = 'pk.eyJ1IjoiYWdyYWViZSIsImEiOiJjand2MmNtc2wwcGR6M3lxejk1aDd0amo3In0.LneM6wuauNA7ArbZVn__2w';
var map = L.mapbox.map('map')
.setView([38.89399, -77.03659], 16)
.addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));
// Create array of lat,lon points.
var line_points = [
[38.893596444352134, -77.0381498336792],
[38.89337933372204, -77.03792452812195],
[38.89316222242831, -77.03761339187622],
[38.893028615148424, -77.03731298446655],
[38.892920059048464, -77.03691601753235],
[38.892903358095296, -77.03637957572937],
[38.89301191422077, -77.03592896461487],
[38.89316222242831, -77.03549981117249],
[38.89340438498248, -77.03514575958252],
[38.893596444352134, -77.0349633693695]
];
// Define polyline options
// http://leafletjs.com/reference.html#polyline
var polyline_options = {
color: '#FF0000'
};
// Defining a polygon here instead of a polyline will connect the
// endpoints and fill the path.
// http://leafletjs.com/reference.html#polygon
var polyline = L.polyline(line_points, polyline_options).addTo(map);