I'm just getting to grips with the amazing MapBox.
On my map I have a dropdown that loads new markers and removes the old ones, that is all working fine (code is below).
var pin_layer = L.mapbox.featureLayer().addTo(map);
$('select.traveller').on('change',function(){
map.removeLayer(pin_layer);
pin_layer = L.mapbox.featureLayer().addTo(map);
var markers = '[';
$.post('_posts/get-pins.php', {traveller: $(this).val()}, function(data){
$.each( data, function(k, item) {
markers += '{ "type": "Feature",' +
'"geometry": { ' +
'"type": "Point", ' +
'"coordinates": ['+item.long+', '+item.lat+']},' +
'"properties": {' +
'"id": "'+item.id+'",' +
'"image": "'+item.image+'",' +
'"marker-symbol": "star",' +
'"marker-color": "#ff8888",' +
'"marker-size": "large",' +
'"title": "'+item.title+'", ' +
'"description": "'+item.description+'"' +
'}' +
'},';
});
markers = markers.substring(0, markers.length - 1);
markers += ']';
pin_layer.setGeoJSON(JSON.parse(markers));
},'json');
})
I'm now looking to draw lines between the markers in the order that they are added. i.e. Marker 1 to marker 2, marker 2 to marker 3 etc. I've tried using the code at the below link but it's not drawing any of the lines, its also not throwing any errors.
https://www.mapbox.com/mapbox.js/example/v1.0.0/line-marker/
Has anyone successfully done this or know of any example code for drawing the lines?