diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-06-01 13:01:15 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:21:00 +0100 |
commit | e435a4929b8d315f13184ea65086fc032c1fbea6 (patch) | |
tree | 2e37cb29bded9271e96b82279ed2fd243cab8aba /ishtar_common/templates/gis/openlayers-osm.html | |
parent | 8470eb0264b1acedee2860d1edfcd1a112529495 (diff) | |
download | Ishtar-e435a4929b8d315f13184ea65086fc032c1fbea6.tar.bz2 Ishtar-e435a4929b8d315f13184ea65086fc032c1fbea6.zip |
Geodata - geo forms: improve OpenLayers widget
Diffstat (limited to 'ishtar_common/templates/gis/openlayers-osm.html')
-rw-r--r-- | ishtar_common/templates/gis/openlayers-osm.html | 23 |
1 files changed, 23 insertions, 0 deletions
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 %} |