Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dude: Save & Redraw #349

Closed
marcoas opened this issue Dec 12, 2014 · 2 comments
Closed

Dude: Save & Redraw #349

marcoas opened this issue Dec 12, 2014 · 2 comments

Comments

@marcoas
Copy link

marcoas commented Dec 12, 2014

(Tanslated By Google)
In my project, I need only would use "polylines".
How I can get all the points of the polyline to save (in a database)?
And How I can redraw a polyline, knowing the points that compose?

(Spanish)
En mi proyecto, solamente necesito usaría "polylines".
¿Como puedo obtener todos los puntos del polyline para poder guardarlos (en una base de datos)?
Y ¿Como puedo volver a dibujar un polyline, sabiendo los puntos que lo componen?

@morganherlocker
Copy link

@marcoas If you have leaflet polylines on your map, you can convert them to geojson with the built-in Leaflet method.

Here is the documentation:

http://leafletjs.com/reference.html#polyline

line = lineLayer.toGeoJSON();
var coordinates = line.geometry.coordinates;

// do something with coordinates

If you have a list of coordinates, you can do the following:

http://leafletjs.com/examples/geojson.html

var coordinates = [] // get these from your database

// create a geojson object
var line = {
  type: 'Feature',
  geometry: {
    type: 'LineString',
    coordinates: coordinates
  },
  properties: {}
};

L.geoJson(line).addTo(map);

@jacobtoye
Copy link
Member

Thanks @morganherlocker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants