Skip to content

LeafletWidget not displaying tile layer #360

@yagueto

Description

@yagueto

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions