diff --git a/CHANGES.md b/CHANGES.md
index 80034604..f764efac 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
Note: Minor version `0.X.0` update might break the API, It's recommended to pin `tipg` to minor version: `tipg>=0.1,<0.2`
+## [unreleased]
+
+- hide map element in HTML pages when collections/items do not have spatial component
+
## [0.4.4] - 2023-10-03
### fixed
diff --git a/tipg/templates/collection.html b/tipg/templates/collection.html
index 1d5d58d6..5ebc1740 100644
--- a/tipg/templates/collection.html
+++ b/tipg/templates/collection.html
@@ -47,24 +47,30 @@
Links
diff --git a/tipg/templates/item.html b/tipg/templates/item.html
index 49f4aca4..e8654220 100644
--- a/tipg/templates/item.html
+++ b/tipg/templates/item.html
@@ -32,60 +32,65 @@ Properties
{% include "footer.html" %}
diff --git a/tipg/templates/items.html b/tipg/templates/items.html
index fb7c4bf5..ad66ed23 100644
--- a/tipg/templates/items.html
+++ b/tipg/templates/items.html
@@ -84,32 +84,38 @@ Collection Items: {{ response.title or response.id }}
window.location.href = url;
}
$(function() {
-
//
// mapping
//
var geojson = {{ response|tojson }};
- var map = L.map('map').setView([0, 0], 1);
- map.addLayer(new L.TileLayer(
- 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
- maxZoom: 18,
- attribution: 'Map data © OpenStreetMap contributors'
+
+ var features = (geojson.features) ? geojson.features : [];
+ var hasGeom = features.some(feat => feat.geometry);
+ if (hasGeom) {
+ var map = L.map('map').setView([0, 0], 1);
+ map.addLayer(new L.TileLayer(
+ 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
+ maxZoom: 18,
+ attribution: 'Map data © OpenStreetMap contributors'
+ }
+ ));
+
+ function addPopup(feature, layer) {
+ var aElm = document.createElement('a');
+ aElm.setAttribute('href', `${currentURL}/${feature.id}`);
+ aElm.setAttribute('target', '_blank');
+ aElm.innerText = feature.id;
+ layer.bindPopup(aElm);
}
- ));
-
- function addPopup(feature, layer) {
- var aElm = document.createElement('a');
- aElm.setAttribute('href', `${currentURL}/${feature.id}`);
- aElm.setAttribute('target', '_blank');
- aElm.innerText = feature.id;
- layer.bindPopup(aElm);
- }
- var features = L.geoJSON(geojson, {
- onEachFeature: addPopup
- }).addTo(map);
+ var features = L.geoJSON(geojson, {
+ onEachFeature: addPopup
+ }).addTo(map);
- map.fitBounds(features.getBounds());
+ map.fitBounds(features.getBounds());
+ } else {
+ document.getElementById("map").style.display = "none";
+ }
//
// paging