CSS on polylines
HTML
<script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css">
<div id="map"></div>
CSS
#map { height: 300px; }
.my_polyline {
stroke: green;
fill: none;
stroke-dasharray: 5,5;
stroke-width: 10;
}
JavaScript
// create a map in the "map" div, set the view to a given place and zoom
var map = L.map('map').setView([48.858190, 2.294470], 16);
// add an OpenStreetMap tile layer
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var latlngs = [
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047],
[51.509, -0.08]
];
// create a red polyline from an array of LatLng points
var polyline = L.polyline(latlngs, { className: 'my_polyline' }).addTo(map);
// zoom the map to the polyline
map.fitBounds(polyline.getBounds());