summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/templates/ishtar/blocks/sheet_simple_map.html')
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_simple_map.html56
1 files changed, 47 insertions, 9 deletions
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
index d755fe531..b475e7343 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
@@ -6,15 +6,53 @@
<div id="map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}"></div>
</div>
<script type="text/javascript">
-var 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);
-{% if geo_item.most_precise_geo == 'point' %}
-var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.point_2d_geojson|safe}};
-display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}});
-{% else %}
-var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.multi_polygon_geojson|safe}};
-display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", null, {{geo_item.SLUG}}{{geo_item.pk}});
-{% endif %}
+var disp_map = function() {
+ var 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);
+ {% if geo_item.most_precise_geo == 'point' %}
+ var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.point_2d_geojson|safe}};
+ display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}});
+ {% else %}
+ var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.multi_polygon_geojson|safe}};
+ display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", null, {{geo_item.SLUG}}{{geo_item.pk}});
+ {% endif %}
+}
+disp_map();
+
+if ("{{geo_item.SLUG}}" === 'contextrecord' || "{{geo_item.SLUG}}" === 'operation') {
+ var display_geo_items = function(disp, get_polygons) {
+ var display_both = false;
+ if ((disp === "basefinds") && ("{{geo_item.SLUG}}" === "operation")) {
+ display_both = true;
+ }
+ var url = null;
+ if (get_polygons === "Points") {
+ url = "{% url 'archaeological_finds:api-get-geo-points' %}";
+ }
+ else {
+ url = "{% url 'archaeological_finds:api-get-geo-polygons' %}";
+ }
+ disp_geo_items("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", url, "{{geo_item.SLUG}}", "{{geo_item.pk}}", display_both);
+ }
+
+ var geo_items_displayed_once = false;
+ var disp = $("#display-geo-items")[0];
+ var get_polygons = $("#get-polygons")[0];
+ disp.addEventListener('change', (event) => {
+ if (geo_items_displayed_once) {
+ disp_map();
+ }
+ if (disp.value !== "") {
+ console.log("geo items");
+ display_geo_items(disp.value, get_polygons.value);
+ geo_items_displayed_once = true;
+ }
+ })
+ get_polygons.addEventListener('change', (event) => {
+ disp_map();
+ display_geo_items(disp.value, get_polygons.value);
+ })
+}
</script>
{% endif %}
{% endif %}