summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/gis/openlayers-osm.html
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/templates/gis/openlayers-osm.html')
-rw-r--r--ishtar_common/templates/gis/openlayers-osm.html59
1 files changed, 42 insertions, 17 deletions
diff --git a/ishtar_common/templates/gis/openlayers-osm.html b/ishtar_common/templates/gis/openlayers-osm.html
index a6797a580..0c4391a0f 100644
--- a/ishtar_common/templates/gis/openlayers-osm.html
+++ b/ishtar_common/templates/gis/openlayers-osm.html
@@ -1,25 +1,50 @@
{% 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()});
+ var base_layer;{% endblock %}
+
+{% block options %}{{ block.super }}
+ options['default_lon'] = {{ default_lon|unlocalize }};
+ options['default_lat'] = {{ default_lat|unlocalize }};
+ options['default_zoom'] = {{ default_zoom|unlocalize }};
+ var map_layers_edit = [
+ new ol.layer.Group({
+ title: base_maps_msg,
+ visible: true,
+ layers: get_layers()
+ })
+ ];
+ options["layers"] = map_layers_edit;
+ delete options.base_layer;
+ var map_controls = ol.control.defaults().extend([
+ new ol.control.FullScreen(),
+ new ol.control.ScaleLine()
+ ]);
+ if (location.protocol == 'https:'){
+ map_controls.push(
+ new TrackPositionControl({map_id: map_id})
+ );
+ }
+ options["controls"] = map_controls;
{% 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);
-});
+ var layer_switcher = new ol.control.LayerSwitcher({
+ tipLabel: 'Légende',
+ groupSelectStyle: 'children'
+ });
+ {{ module }}.map.addControl(layer_switcher);
+ $(".ol-viewport").parent().width($(".form").width());
+ $(document).ready(function() {
+ {{ module }}.map.updateSize();
+ let features = {{ module }}.featureOverlay.getSource().getFeatures();
+ if (features.length){
+ 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 %}