summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
blob: b4e669a703319b376c0c8a5188235ac44950dda7 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{% if PROFILE.mapping %}
{% if geo_item.point_2d or geo_item.multi_polygon %}
<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>
<script type="text/javascript">
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 == "operation" or geo_item.SLUG == "contextrecord" %}
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;
    var get_poly = (get_polygons === "polygons");
    if (get_poly) {
        url = "{% url 'api-get-geo-polygons' %}";
    }
    else {
        url = "{% url 'api-get-geo-points' %}";
    }
    disp_geo_items("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", url, "{{geo_item.SLUG}}",
                   "{{geo_item.pk}}", display_both, get_poly);
}

var geo_items_displayed_once = false;
var disp = $("#display-geo-items");
var get_polygons = $("#get-polygons");
disp.change( function () {
    if (geo_items_displayed_once) {
        disp_map();
    }
    if (disp.val() !== "") {
        display_geo_items(disp.val(), get_polygons.val());
        geo_items_displayed_once = true;
    }
})
get_polygons.change( function () {
    disp_map();
    display_geo_items(disp.val(), get_polygons.val());
})
{% endif %}
</script>
{% endif %}
{% endif %}