Вопрос

I'm new to mapping services and am experimenting with Mapbox and some open transit data.

I have a simple .CSV file with a transit route broken down into a series of coordinates (points along a line). The file looks like this:

point_id, latitude, longitude

1, 43.775969, -79.346054

I wanted to know how to convert these points into a line in Mapbox. I've tried converting the CSV file into various formats (.GPX, etc) but can't figure out how to get anything but a huge series of point markers.

Это было полезно?

Решение

This isn't specific to Mapbox. What you want to do is convert a series of points into a line feature.

GeoJSON is probably the easiest format to tinker with for this, so try converting your CSV to that.

Then, read up on the format:

http://geojson.org/geojson-spec.html

And play around with it here to see it visually:

http://geojson.io

Basically you are most of the way there already, you just need to define things as a line.

Другие советы

for each line in the csv you could do this:

var coords = line.split(",");
polyline.addLatLng( L.latLng(coords[1],coords[2]));

now that will join your bunch of points into a polyline in mapbox, assuming you've previously declared it as:

polyline = L.polyline([]).addTo(map);

it will now be a line (instead of loads of markers)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top