summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/static/js/ishtar-map.js23
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_geo_items.html12
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_simple_map.html61
-rw-r--r--ishtar_common/urls.py1
4 files changed, 53 insertions, 44 deletions
diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js
index b22467668..c78da1098 100644
--- a/ishtar_common/static/js/ishtar-map.js
+++ b/ishtar_common/static/js/ishtar-map.js
@@ -645,7 +645,8 @@ var display_lines_and_polys = function(map_id, lines_and_polys){
}
};
-var disp_geo_items = function(map_id, base_url, slug, pk, display_both) {
+var disp_geo_items = function(map_id, base_url, slug, pk,
+ display_both, get_poly) {
var url = base_url;
if (slug === "operation") {
url += "?operation_pk=";
@@ -662,10 +663,18 @@ var disp_geo_items = function(map_id, base_url, slug, pk, display_both) {
if (httpRequest.status === 200) {
geo_items = to_geo_items(JSON.parse(httpRequest.responseText), slug, display_both)
for (geo_item of geo_items['base-finds']) {
- display_associated_polys(map_id, geo_item, 'basefind');
+ if (get_poly) {
+ display_associated_polys(map_id, geo_item, 'basefind');
+ } else {
+ display_associated_points(map_id, geo_item, 'basefind');
+ }
}
for (geo_item of geo_items['context-records']) {
- display_associated_polys(map_id, geo_item, 'contextrecord');
+ if (get_poly) {
+ display_associated_polys(map_id, geo_item, 'contextrecord');
+ } else {
+ display_associated_points(map_id, geo_item, 'contextrecord');
+ }
}
} else { return; }
}
@@ -727,16 +736,20 @@ var get_associated_context_record_style = function (feature) {
}),
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.2)'
- })
+ }),
+ radius: 10
});
};
var display_associated_points = function (map_id, points, slug) {
+ console.log(points);
_point_features = geojson_format.readFeatures(points);
+ console.log(_point_features[0].getGeometry().getType())
_cluster_source = new ol.source.Cluster({
distance: 40,
source: new ol.source.Vector()
});
+ _cluster_source.getSource().addFeatures(_point_features);
style = get_associated_base_find_style;
if (slug === 'contextrecord') {
style = get_associated_context_record_style;
@@ -747,5 +760,5 @@ var display_associated_points = function (map_id, points, slug) {
style: style
});
map[map_id].addLayer(_cluster_layer);
- _cluster_source.getSource().addFeatures(_point_features);
+
} \ No newline at end of file
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html
index 451453d59..9b485de15 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html
@@ -6,8 +6,12 @@
<label for="display-geo-items">{% trans "Display associated features: " %}</label>
<select name="display-geo-items" id="display-geo-items">
<option value="" selected="selected">{% trans "None" %}</option>
+ {% if geo_item.SLUG == "operation" %}
<option id="disp-context-records" value="contextrecords">{% trans "Context records" %}</option>
+ <option value="basefinds">{% trans "Everything" %}</option>
+ {% else %}
<option value="basefinds">{% trans "Base finds" %}</option>
+ {% endif %}
</select>
</dd>
<dd>
@@ -19,14 +23,6 @@
</dd>
</dl>
<script>
-var hide_context_records = function() {
- if ("{{geo_item.SLUG}}" === "contextrecord") {
- const disp_cr = $("#disp-context-records")[0];
- disp_cr.hidden = true;
- }
-}
-hide_context_records();
-
var hide_get_polygons = function() {
const disp = $("#display-geo-items")[0];
const get_poly = $("#get-polygons")[0];
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
index b475e7343..2c9d49be2 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
@@ -19,40 +19,41 @@ var disp_map = function() {
}
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);
+{% 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")[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) => {
+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 !== "") {
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);
+})
+{% endif %}
</script>
{% endif %}
{% endif %}
diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py
index 76346ddf1..9e120a945 100644
--- a/ishtar_common/urls.py
+++ b/ishtar_common/urls.py
@@ -559,7 +559,6 @@ urlpatterns += [
views.QANotAvailable.as_view(),
name="qa-not-available",
),
- url(r"^", include("archaeological_finds.urls", namespace="archaeological_finds")),
]
urlpatterns += get_urls_for_model(models.Document, views, own=True)