makinacorpus / django-leaflet

Use Leaflet in your Django projects
GNU Lesser General Public License v3.0
717 stars 283 forks source link

Admin Widget don't show draw tools when minimap is active #315

Open cantin-f opened 3 years ago

cantin-f commented 3 years ago

Hi,

I'm playing with django-leaflet and django-geojson. The map is working great on the public website (https://nacros.eu.pythonanywhere.com/map), I'm trying to make it works in the admin. In the admin, the map show for a PointField but it's a normal map without draw tools.

django-leaflet==0.27.1 python==3.7 django==3.1.7

Models :

class POI(models.Model):
    name = models.CharField(max_length=64)
    geom = PointField()

Admin :

admin.site.register(POI, LeafletGeoAdmin)

settings :

LEAFLET_CONFIG = {
    'DEFAULT_CENTER': (-5.0, -57.0),
    'DEFAULT_ZOOM': 6,
    'MIN_ZOOM': 4,
    'MAX_ZOOM': 8,
    'TILES': '/static/map/{z}/{y}/{x}.jpg',
    'ATTRIBUTION_PREFIX': '© Virtys',
    'SCALE': None,
    'MINIMAP': True,
    'PLUGINS': {
        'MousePosition': {
            'css': '/static/assets/mldb/map/L.Control.MousePosition.css',
            'js': 'assets/mldb/map/L.Control.MousePosition.js',
            'auto-include': True,
        },
        'FullScreen': {
            'css': 'https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css',
            'js': 'https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js',
            'auto-include': True,
        },
    }
}

Admin view :

image

I have one javascript error that is related :

leaflet.extras.js:186 Uncaught TypeError: L.Control.MiniMap is not a constructor
    at i.<anonymous> (leaflet.extras.js:186)
    at i.whenReady (leaflet.js:5)
    at i._djSetupControls (leaflet.extras.js:185)
    at initialize (leaflet.extras.js:68)
    at new i (leaflet.js:5)
    at Function.L.Map.djangoMap (leaflet.extras.js:211)
    at loadmap ((index):500)

If I turn off the minimap in settings, draw tools appear. So the problem is the minimap in admin widget.

Thx for your help.