{% include "header.html" %}

<nav aria-label="breadcrumb">
  <ol class="breadcrumb bg-light">
    <li class="breadcrumb-item"><a href="{{ template.api_root }}?f=html{{ template.extra_params }}">Home</a></li>
    <li class="breadcrumb-item"><a href="{{ template.api_root }}/collections?f=html{{ template.extra_params }}">Collections</a></li>
    <li class="breadcrumb-item"><a href="{{ template.api_root }}/collections/{{ response.collection.id }}?f=html{{ template.extra_params }}">{{ response.collection.title }}</a></li>
    <li class="breadcrumb-item"><a href="{{ template.api_root }}/collections/{{ response.collection.id }}/items?f=html{{ template.extra_params }}">items</a></li>
    <li class="breadcrumb-item active" aria-current="page">{{ response.id }}
    <li class="ms-auto json-link"><a target="_blank" href="{{ template.api_root }}/collections/{{ response.collection.id }}/items/{{ response.id }}?f=json{{ template.extra_params }}">JSON</a></li>
  </ol>
</nav>

<h1>{{ template.title }} - Collection Item: {{ response.collection.title }}</h1>

<div class="row">
  <div class="col-sm">
    <h2>Properties</h2>
    <ul class="list-unstyled">
      <li><strong>ID:</strong> {{ response.id }}</li>
      {% for key, value in response.properties %}
      <li><strong>{{ key }}:</strong> {{ value }}</li>
      {% endfor %}
    </ul>
  </div>
  <div class="col-sm">
    <div id="map" class="rounded" style="width:100%;height:400px;">Loading...</div>
  </div>
</div>

<script>
document.addEventListener("DOMContentLoaded", function () {
  const geojson = {{ response }};
  const 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 &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
    }
  ));
  const features = L.geoJSON(geojson).addTo(map);
    map.fitBounds(features.getBounds());
});
</script>

{% include "footer.html" %}
