apply css on polylines in leaflet - Javascript Leaflet

Javascript examples for Leaflet:Configuration

Description

apply css on polylines in leaflet

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>CSS on polylines</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script> 
      <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css"> 
      <style id="compiled-css" type="text/css">

#map { height: 300px; }
.my_polyline {/*from  w ww  . j  av  a2s. co m*/
   stroke: green;
   fill: none;
   stroke-dasharray: 10,10;
   stroke-width: 5;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
var map = L.map('map').setView([48.858190, 2.294470], 16);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <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]
];
var polyline = L.polyline(latlngs, { className: 'my_polyline' }).addTo(map);
map.fitBounds(polyline.getBounds());
    }

      </script> 
   </head> 
   <body> 
      <div id="map"></div>  
   </body>
</html>

Related Tutorials