diff options
Diffstat (limited to 'ishtar_common/templates/gis')
-rw-r--r-- | ishtar_common/templates/gis/openlayers-osm.html | 23 | ||||
-rw-r--r-- | ishtar_common/templates/gis/openlayers.html | 42 |
2 files changed, 65 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 %} 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 %} +<style type="text/css">{% block map_css %}{% get_current_language_bidi as LANGUAGE_BIDI %} + #{{ id }}_map { width: {{ map_width }}px; height: {{ map_height }}px; } + #{{ id }}_map .aligned label { float: inherit; } + #{{ id }}_div_map { position: relative; vertical-align: top; float: {{ LANGUAGE_BIDI|yesno:"right,left" }}; } + {% if not display_raw %}#{{ id }} { display: none; }{% endif %} + {% endblock %} +</style> + +<div id="{{ id }}_div_map"> + <div id="{{ id }}_map"></div> + {% if not disabled %}<span class="clear_features"><a href="javascript:{{ module }}.clearFeatures()">{% trans "Delete all Features" %}</a></span>{% endif %} + {% if display_raw %}<p>{% trans "Debugging window (serialized value)" %}</p>{% endif %} + <textarea id="{{ id }}" class="vSerializedField required" cols="150" rows="10" name="{{ name }}">{{ serialized }}</textarea> + <script type="text/javascript"> + {% block map_options %}var map_options = {};{% endblock %} + {% block base_layer %} + var base_layer = new ol.layer.Tile({ + source: new ol.source.XYZ({ + attributions: "NASA Worldview", + maxZoom: 8, + url: "https://map1{a-c}.vis.earthdata.nasa.gov/wmts-webmerc/" + + "BlueMarble_ShadedRelief_Bathymetry/default/%7BTime%7D/" + + "GoogleMapsCompatible_Level8/{z}/{y}/{x}.jpg" + }) + }); + {% endblock %} + {% block options %}var options = { + base_layer: base_layer, + geom_name: '{{ geom_type }}', + id: '{{ id }}', + map_id: '{{ id }}_map', + map_options: map_options, + map_srid: {{ map_srid|unlocalize }}, + name: '{{ name }}' + }; + {% endblock %} + var {{ module }} = new MapWidget(options); + {% block post_module %} + {% endblock %} + </script> +</div> |