diff options
Diffstat (limited to 'ishtar_common/templates/ishtar/blocks/sheet_map.html')
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_map.html | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_map.html b/ishtar_common/templates/ishtar/blocks/sheet_map.html index e0278b8c7..16e014b49 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_map.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_map.html @@ -1,22 +1,60 @@ -{% if PROFILE.mapping and geo_item.main_geodata %} +{% load i18n window_field %}{% if PROFILE.mapping and geo_item.main_geodata %} +{% with geodata_list=geo_item.geodata_list %} <div class="col-12 col-lg-6 flex-wrap"> <div class="window-map" id="map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}"> </div> <div id="map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}"></div> </div> +<div class="col-12 col-lg-6 flex-wrap"> + <h4>{% trans "Geographic data" %}</h4> + <ul>{% for geodata in geodata_list %} + <li> + <input type="checkbox" name="map-ol-{{item.SLUG}}-{{item.pk}}-{{geodata.pk}}" + id="map-ol-{{item.SLUG}}-{{item.pk}}-{{geodata.pk}}" + {% if not forloop.counter0 %}checked{% endif %} + > + <label for="map-ol-{{item.SLUG}}-{{item.pk}}-{{geodata.pk}}"> + <strong>{{geodata.data_type}}</strong></label><br/> + {{geodata.name}} + </li>{% endfor %} + </ul> +</div> <script type="text/javascript"> -const disp_map = function() { +const refresh_map_{{item.SLUG}}_{{item.pk}} = function(first_init) { + var {{geo_item.SLUG}}{{geo_item.pk}}_point = {"type": "FeatureCollection", "features": []}; + var {{geo_item.SLUG}}{{geo_item.pk}}_other = {"type": "FeatureCollection", "features": []}; + {% for geodata in geodata_list %} + if ($("#map-ol-{{item.SLUG}}-{{item.pk}}-{{geodata.pk}}").prop('checked')){ + let geojson = {{geodata.geojson|safe}}; + {% if geodata.geometry_type == 'POINT' %} + Array.prototype.push.apply({{geo_item.SLUG}}{{geo_item.pk}}_point["features"], + geojson["features"]); + {% else %} + Array.prototype.push.apply({{geo_item.SLUG}}{{geo_item.pk}}_other["features"], + geojson["features"]); + {% endif %} + }{% endfor %} + display_lines_and_polys("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}}_other, first_init); + display_points("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}}_point, first_init); +} + +const display_map_{{item.SLUG}}_{{item.pk}} = function() { const html = render_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", false, true); $("#map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}").html(html); - const {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.main_geodata.geojson|safe}}; - {% if geo_item.main_geodata.geometry_type == 'POINT' %} - display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}}); - {% else %} - display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", null, {{geo_item.SLUG}}{{geo_item.pk}}); - {% endif %} + display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", null, null); + {% for geodata in geodata_list %} + $("#map-ol-{{item.SLUG}}-{{item.pk}}-{{geodata.pk}}").change( + function(){ + refresh_map_{{item.SLUG}}_{{item.pk}}(false); + } + ); + {% endfor %} } -disp_map(); + +display_map_{{item.SLUG}}_{{item.pk}}(); +refresh_map_{{item.SLUG}}_{{item.pk}}(true); + {% if geo_item.SLUG == "operation" or geo_item.SLUG == "contextrecord" %} const disp_geo_items = function(disp_cr, disp_bf, get_polygons) { @@ -69,4 +107,5 @@ get_polygons.change( function () { {% endif %} </script> +{% endwith %} {% endif %} |