I have the following code to plot markers and polylines between points. It runs this script when a user changes a selection on the page.
$.post('_posts/get-pins.php', {traveller: $(this).val()}, function(data){
// Create empty featureLayer
var featureLayer = L.mapbox.featureLayer().addTo(map);
// Create empty featureCollection
var featureCollection = {
"type": "FeatureCollection",
"features": []
};
var lineArray = [];
$.each(data, function (k, item) {
// Create new feature object and push to featureCollection
featureCollection.features.push({
"type": "Feature",
"properties": {
"id": item.id,
"title": item.title,
"description": item.description,
"image": item.image,
"marker-symbol": "star",
"marker-color": "#ff8888",
"marker-size": "large"
},
"geometry": {
"type": "Point",
"coordinates": [
item.long,
item.lat
]
}
});
lineArray[item.id] = [item.lat, item.long];
});
featureLayer.setGeoJSON(featureCollection);
lineArray = lineArray.filter(function(){return true});
var polyline = L.polyline(lineArray).addTo(map);
},'json');
I have found the following example on the mapbox examples. https://www.mapbox.com/mapbox.js/example/v1.0.0/dynamically-drawing-a-line/ I was wondering if this kind of animation is possible on drawing simple lines, and if so how to do it.