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

leaflet does not render in admin and form views #40

Open
frague59 opened this issue Sep 22, 2014 · 6 comments
Open

leaflet does not render in admin and form views #40

frague59 opened this issue Sep 22, 2014 · 6 comments

Comments

@frague59
Copy link

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.

@frague59
Copy link
Author

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 :

  • The data does not display in the widget
  • when I save my form, the data is removed

Thanks !

@leplatrem
Copy link
Collaborator

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 ?

@frague59
Copy link
Author

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).

@frague59
Copy link
Author

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 !

@frague59
Copy link
Author

OK, c'était dû à la non installation de GDAL.

Merci !

@leplatrem
Copy link
Collaborator

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...

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

2 participants