You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And I'm using a generic UpdateView and a ModelForm (specifying the LeafletWidget() for the point_locations field). This works beautifully for points and multipolygons, but multipoints gives me the "invalid geometry value" error.
Something seems to be going wrong in leaflet.forms.js in the _serialize function. Changing line 37: var geojson = geom.toGeoJSON(); console.log(geojson); gives something like this:
which looks promising, but the next few lines seem to lose this info. Going on in the code, is_generic is false for multipoints, which means that the else is triggered here:
and there is no geometry in the geojson object, which causes this function to return 'undefined'. So I have fixed this for myself by adding the following:
if(is_multi&&is_generic){varflat={type: 'GeometryCollection',geometries: []};for(vari=0;i<geojson.features.length;i++){flat.geometries.push(geojson.features[i].geometry);}geojson=flat;}// My additionelseif(this.options.geom_type=='MULTIPOINT'){varflat={type: 'MultiPoint',coordinates: []};for(vari=0;i<geojson.features.length;i++){flat.coordinates.push(geojson.features[i].geometry.coordinates);}geojson=flat;}// End my additionelse{geojson=geojson.geometry;}returnJSON.stringify(geojson);
I don't know if what I've done here is correct. This doesn't seem to be an issue anyone else has encountered, perhaps I am doing something wrong somewhere else? My forms work fine for multipolygons and points though, which makes me think this is a bug that's cropped up.
The text was updated successfully, but these errors were encountered:
@PetrDlouhy committed a fix for geometrycollections in current master. It might be related to your problem.
Could you please a pull-request with the changes you suggest so that we can comment/review/merge?
Thanks a lot!
We would welcome any help for maintaining this library. If you use it and find it useful, please Watch it on Github, help us review contributions or comment issues :) Thousand thanks in advance.
I get an error "invalid geometry value" when I try to add points to a multipoint field. I have a model like this :
And I'm using a generic UpdateView and a ModelForm (specifying the LeafletWidget() for the point_locations field). This works beautifully for points and multipolygons, but multipoints gives me the "invalid geometry value" error.
Something seems to be going wrong in leaflet.forms.js in the _serialize function. Changing line 37: var geojson = geom.toGeoJSON(); console.log(geojson); gives something like this:
which looks promising, but the next few lines seem to lose this info. Going on in the code, is_generic is false for multipoints, which means that the else is triggered here:
and there is no geometry in the geojson object, which causes this function to return 'undefined'. So I have fixed this for myself by adding the following:
I don't know if what I've done here is correct. This doesn't seem to be an issue anyone else has encountered, perhaps I am doing something wrong somewhere else? My forms work fine for multipolygons and points though, which makes me think this is a bug that's cropped up.
The text was updated successfully, but these errors were encountered: