EDIT:
Nathan's idea is correct in the sense that you have to build a polyline yourself (the lines between your markers).
To be strict, you should use your data when the list of points is still an array (and assuming the order of the array is the order of the lines you want to get). This means that you must work directly with GeoJSON data.
For example, you would do:
function connectDots(data) { var features = data.features, feature, c = [], i; for (i = 0; i < features.length; i += 1) { feature = features[i];
GeoJSON data will be converted via Leaflet into vectors for polylines, polygons, etc. and markers for point functions. Please refer to the Flyer tutorial and reference .
If you want to specify how the Leaflet should style the vectors , you really have to create an object containing the path parameters (for example, your style variable in the first line), but you should specify it as a style variant of your L.geoJson layer, and not inside the icon.
When you want to specify how Leaflet should style markers , you can really set a specific icon that only applies to point elements. You are better off using the pointToLayer parameter, because the code will really only apply to points, instead of trying to apply it to vectors (which for example, is not the setIcon method).
Finally, when you want to perform some action that applies to both vectors and markers, you use the onEachFeature parameter, for example, link your popup.
So, you get something like:
var myIcon = L.icon({ iconUrl: './images/mymarker.png', iconSize: [18, 28] }); var geojson = L.geoJson(data, { style: style,
As stated in the comments, whenever you turn to other people for help, you would facilitate their task (therefore, you will get faster and faster support) if you take the time to correctly indicate your problem, with a description / screenshots about what is going wrong and publish clean code. A very good practice for client code is to reproduce the problem on jsFiddle , for example.