summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/gis/openlayers-osm.html
blob: a6797a5807606c27b02cfd71464015e04896726c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{% 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());
    let current_zoom = {{ module }}.map.getView().getZoom();
    if ({{ module }}.map.getView().getZoom() > 18) {{ module }}.map.getView().setZoom(18);
});
{% endblock %}