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

LeafletWidget not displaying tile layer #360

Open
yagueto opened this issue Jan 1, 2023 · 3 comments
Open

LeafletWidget not displaying tile layer #360

yagueto opened this issue Jan 1, 2023 · 3 comments

Comments

@yagueto
Copy link

yagueto commented Jan 1, 2023

I'm trying to create a form using the code in the docs:

Code:
from django import forms

from leaflet.forms.widgets import LeafletWidget


class WeatherStationForm(forms.ModelForm):

    class Meta:
        model = WeatherStation
        fields = ('name', 'geom')
        widgets = {'geom': LeafletWidget()}

... and in my HTML template

{% load leaflet_tags %}
<html>
  <head>
   {% leaflet_js plugins="forms" %}
   {% leaflet_css plugins="forms" %}
   {{ form.media }}  <!-- Even though this line does not appear in the docs,  it showed an error without it, as issue #343 -->

  </head>
  <body>
    <h1>Edit {{ object }}</h1>
    <form method="POST">
        {{ form }}
        <input type="submit"/>
    </form>
  </body>
</html>

However, the LeafletWidget always appears in black (no tile layer). There doesn't seem to be any reference to the OpenStreetMap layer anywhere either. Does that mean that I have to add it manually with javascript?

Also, it seems to ignore the settings defined in the settings.py file, i.e. the ATTRIBUTION_PREFIX parameter.

Resulting map

@camillemonchicourt
Copy link

camillemonchicourt commented Jan 2, 2023

From what I understand, it is supposed to have OSM as default tile: https://github.com/makinacorpus/django-leaflet/blob/master/leaflet/__init__.py#L11

The documentation also explains how to manage map layers: https://django-leaflet.readthedocs.io/en/latest/templates.html#default-tiles-layer

Do you have any errors in the browser console?

@yagueto
Copy link
Author

yagueto commented Jan 4, 2023

I have no errors in my console. Strangely, both the admin and the widget in template works, but the form doesn't render or use the settings defined in the settings file

@Gagaro
Copy link
Member

Gagaro commented Jan 9, 2023

What do you mean by the widget in template works but not the form?

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