diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js index 29725636a3..2395e4d7dd 100644 --- a/django/contrib/gis/static/gis/js/OLMapWidget.js +++ b/django/contrib/gis/static/gis/js/OLMapWidget.js @@ -107,6 +107,13 @@ ol.inherits(GeometryTypeControl, ol.control.Control); if (initial_value && !this.options.is_collection) { this.disableDrawing(); } + const clearNode = document.getElementById(this.map.getTarget()).nextElementSibling; + if (clearNode.classList.contains('clear_features')) { + clearNode.querySelector('a').addEventListener('click', (ev) => { + ev.preventDefault(); + self.clearFeatures(); + }); + } this.ready = true; } diff --git a/django/contrib/gis/templates/gis/openlayers.html b/django/contrib/gis/templates/gis/openlayers.html index 90ecf1b44b..128654d5aa 100644 --- a/django/contrib/gis/templates/gis/openlayers.html +++ b/django/contrib/gis/templates/gis/openlayers.html @@ -9,7 +9,7 @@
{% translate "Debugging window (serialized value)" %}
{% endif %}