Skip to content

Commit 0626bc5

Browse files
use ogcapi leaflet plugin, instead of wms (#2145)
* use ogcapi leaflet plugin, instead of wms * Refactor map link rendering in collection.html --------- Co-authored-by: Tom Kralidis <tomkralidis@gmail.com>
1 parent e4b5ced commit 0626bc5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pygeoapi/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,7 @@ def describe_collections(api: API, request: APIRequest,
13471347
})
13481348

13491349
if request.format == F_HTML: # render
1350+
fcm['base_url'] = api.base_url
13501351
fcm['collections_path'] = api.get_collections_url()
13511352
if dataset is not None:
13521353
tpl_config = api.get_dataset_templates(dataset)

pygeoapi/templates/collections/collection.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{% block extrahead %}
1111
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"/>
1212
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
13+
<script src='https://unpkg.com/leaflet-imageoverlay-ogcapi@0.1.0/Leaflet.ImageOverlay.OGCAPI.js'></script>
1314
{% endblock %}
1415

1516
{% block body %}
@@ -148,11 +149,10 @@ <h3>{% trans %}Storage CRS{% endtrans %}</h3>
148149

149150
{# if this collection has a map representation, add it to the map #}
150151
{% for link in data['links'] %}
151-
{% if link['rel'] == 'http://www.opengis.net/def/rel/ogc/1.0/map' and link['href'] %}
152-
L.tileLayer.wms("{{ link['href'] }}", {"opacity": .7, "transparent": true, "crs": L.CRS.EPSG4326}).addTo(map);
153-
{% endif %}
154-
{% endfor %}
155-
152+
{% if link['rel'] == 'http://www.opengis.net/def/rel/ogc/1.0/map' and link['href'] %}
153+
L.imageOverlay.ogcapi("{{ data['base_url'] }}", {collection: "{{ data['id'] }}", "opacity": .7, "transparent": true}).addTo(map);
154+
{% endif %}
155+
{% endfor %}
156156

157157
var bbox_layer = L.polygon([
158158
['{{ data['extent']['spatial']['bbox'][0][1] }}', '{{ data['extent']['spatial']['bbox'][0][0] }}'],

0 commit comments

Comments
 (0)