Open udos opened 8 years ago
i think leaflet-draw does not support MultiLine.
Do you really need to have a multiLine or can you try to make an array of polyLine instead (or something else) ?
I prefer to use GeoJson objects. as a workaround I will try to do something you suggested. maybe a FeatureCollection of LineString...
instead of using a GeoJSON Feature Object in which the geometry is of type MultiLineString as in
a GeoJSON Feature Collection Object in which the single geometries are of type LineString as in
will not cause the error I reported
The docs should be clearer on not supporting multigeometries. Although it's not hard to cast from multigeometry to feature collection, there's no reason that a user should assume that the control doesn't support specific features covered by the spec.
submitted a PR: https://github.com/Leaflet/Leaflet.draw/pull/569
@jameslaneconkling can you please explain me how exactly its possible to cast multigeometry to feature collection? Is something like this possible to do using jquery and leaflet?
@dkarakostis because geoJSON is just an object literal, you shouldn't need a library to do the conversion. See the geoJSON docs. Something like this should work:
function multiGeometry2FeatureCollection(multigeometry) {
return {
type: 'FeatureCollection'
features: multigeometry.coordinates.map(function(coordinates) {
return {type: multigeometry.type.replace('Multi', ''), coordinates: coordinates};
})
};
}
Thanks. Double checking my response from the ajax request, I see that the returned geoJSON is already a FeatureColletction:
Object {type: "FeatureCollection", totalFeatures: 1, features: Array[1], crs: Object}
On Thu, Jul 28, 2016 at 1:29 AM, James Conkling notifications@github.com wrote:
@dkarakostis https://github.com/dkarakostis because geoJSON is just an object literal, you shouldn't need a library to do the conversion. See the geoJSON docs http://geojson.org/geojson-spec.html. Something like this should work:
function multiGeometry2FeatureCollection(multigeometry) { return { type: 'FeatureCollection' features: multigeometry.coordinates.map(function(coordinates) { return {type: multigeometry.type.replace('Multi', ''), coordinates: coordinates}; }) }; }
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Leaflet/Leaflet.draw/issues/560#issuecomment-235752593, or mute the thread https://github.com/notifications/unsubscribe-auth/APfg_2tb9nuVhDyTLACLUO_7W7eUNMXtks5qZ-nxgaJpZM4JDKg9 .
hi,
when I am executing code locally (see https://jsfiddle.net/udos/1035sp5x/) everything loads normally. when I click the leaflet.draw "edit layers" icon, I get error
after this also "Save" or "cancel" does not work anymore.
maybe it is due to geometry type MultiLineString.
note: on jsfiddle the error is
I'm not sure if it is a bug or I am using it the wrong way...
thanks, udo