From 81def9d8e528728b62b6eec5abd73e06478857e1 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 1 Jun 2022 13:01:15 +0200 Subject: Geodata - geo forms: improve OpenLayers widget --- ishtar_common/templates/gis/openlayers-osm.html | 23 ++++++++++++++ ishtar_common/templates/gis/openlayers.html | 42 +++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 ishtar_common/templates/gis/openlayers-osm.html create mode 100644 ishtar_common/templates/gis/openlayers.html (limited to 'ishtar_common/templates') diff --git a/ishtar_common/templates/gis/openlayers-osm.html b/ishtar_common/templates/gis/openlayers-osm.html new file mode 100644 index 000000000..404ab5708 --- /dev/null +++ b/ishtar_common/templates/gis/openlayers-osm.html @@ -0,0 +1,23 @@ +{% extends "gis/openlayers.html" %} +{% load l10n %} + +{% block options %}{{ block.super }} +options['default_lon'] = {{ default_lon|unlocalize }}; +options['default_lat'] = {{ default_lat|unlocalize }}; +options['default_zoom'] = {{ default_zoom|unlocalize }}; +{% endblock %} + +{% block base_layer %} +var base_layer = new ol.layer.Tile({source: new ol.source.OSM()}); +{% endblock %} + +{% block post_module %} +$(".ol-viewport").parent().width($(".form").width()); +$(document).ready(function() { + {{ module }}.map.updateSize(); + let features = {{ module }}.featureOverlay.getSource().getFeatures(); + let layer_extent = features[0].getGeometry().getExtent().slice(0); + features.forEach(function(feature){ ol.extent.extend(layer_extent, feature.getGeometry().getExtent())}); + {{ module }}.map.getView().fit(layer_extent, {{ module }}.map.getSize()); +}); +{% endblock %} diff --git a/ishtar_common/templates/gis/openlayers.html b/ishtar_common/templates/gis/openlayers.html new file mode 100644 index 000000000..d6d0bf40c --- /dev/null +++ b/ishtar_common/templates/gis/openlayers.html @@ -0,0 +1,42 @@ +{% load i18n l10n %} + + +
+
+ {% if not disabled %}{% trans "Delete all Features" %}{% endif %} + {% if display_raw %}

{% trans "Debugging window (serialized value)" %}

{% endif %} + + +
-- cgit v1.2.3