From d86abf7eb1d5a7ea8c8c0ecfde24680d3a5d7094 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 23 Feb 2023 13:23:32 +0100 Subject: Geo: create/edit form - new openlayers version - add default IGN tiles --- ishtar_common/widgets.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'ishtar_common/widgets.py') diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 57dc1a730..2bcc598bf 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -24,6 +24,7 @@ import logging from django import forms from django.conf import settings from django.contrib.gis import forms as gis_forms +from django.contrib.gis.db import models as gis_models from django.core.exceptions import ValidationError from django.core.files import File from django.db.models import fields @@ -1333,7 +1334,26 @@ class RangeInput(NumberInput): input_type = "range" -class ReversedOSMWidget(gis_forms.OSMWidget): +class OSMWidget(gis_forms.OSMWidget): + """ + Replace Media with local ressource + """ + class Media: + extend = False + css = { + 'all': ( + "ol/ol.css", + 'gis/css/ol3.css', + ) + } + js = ( + "ol/ol.js", + "ol-layerswitcher/ol-layerswitcher.js", + "gis/js/OLMapWidget.js", + ) + + +class ReversedOSMWidget(OSMWidget): def get_context(self, name, value, attrs): if value: if not isinstance(value, str): # should be geo -- cgit v1.2.3