Open frague59 opened 10 years ago
OK, Leaflet is not rendered in ModelForm 'out of the box', I've set widgets into Meta class in my form to {"geom": LeafletWidget}, it works.
Is it possible to use this widget to save data into the model ? I've manually set a POINT to the geom field :
Thanks !
Ok, for the Meta class, we might have to update the documentation ?
Yes of course, edition works ! I wonder why you faced those problems... did you try in adminsite ?
I've the same issue in adminsite... And now in detail view, a SerializationError :
SerializationError: The field ["geom", "{ "type":"Point", "coordinates":[ 3.172007203102112, 50.709293432461806 ] }"] could not be parsed as a valid geometry
My code :
<script type="text/javascript">
function map_init_basic(map, options) {
var data = eval('{{ object|geojsonfeature|safe }}');
L.marker(data).addTo(map);
}
</script>
{% leaflet_map object.get_map_name callback="window.map_init_basic" %}
The 'get_map_name' method is a models' one that returns the name of the map, as a named url, in my case using a namespaced one (calendrier:admin:lieu_map).
J'ai contourné le problème dans la vue de detail en utilisant l'appel à geoJson via ajax :
{% leaflet_map "lieu_map" callback="window.map_init_basic" %}
<script type="text/javascript">
function map_init_basic(map, options) {
$.getJSON("{% url "calendrier:admin:lieu_map" %}",
function(data) {
L.geoJson(data).addTo(map);
});
}
</script>
Dans la vue de création, via le LeafletWidget, je retrouve l'erreur de déserialisation des données :
ERROR::django.contrib.gis::Error creating geometry from value '{
"type":"Point",
"coordinates":[
3.1719642877578735,
50.709266256082714
]
}' (String or unicode input unrecognized as WKT EWKT, and HEXEWKB.)
Je vais essayer de comprendre ce qui se passe, et peut-être proposer un patch.
Merci de votre aide !
OK, c'était dû à la non installation de GDAL.
Merci !
Est-ce que finalement tout est rentré dans l'ordre ?
Suite aux contributions de @fle, normalement il est possible de mettre tout en marche sans GEOS ni GDAL. Cela vaudrait le coup de comprendre et décortiquer les problèmes que tu as recontrés...
Hi,
Thanks for your great job !
I'm facing a strange problem. I've folowed the doc from the github site, installed both django-leaflet, django-geojson and jsonfield, but form are rendered as "JSONTextField" but not as leaflet field.
I use a django 1.7.