diff --git a/ckanext/rvr/assets/js/rvrDatasetMapGenerator.js b/ckanext/rvr/assets/js/rvrDatasetMapGenerator.js
new file mode 100644
index 0000000..c01c95d
--- /dev/null
+++ b/ckanext/rvr/assets/js/rvrDatasetMapGenerator.js
@@ -0,0 +1,96 @@
+// Dataset map module
+this.ckan.module('rvr-dataset-map', function (jQuery, _) {
+
+ return {
+ options: {
+ i18n: {
+ },
+ styles: {
+ point:{
+ iconUrl: '/img/marker.png',
+ iconSize: [14, 25],
+ iconAnchor: [7, 25]
+ },
+ default_:{
+ color: '#B52',
+ weight: 2,
+ opacity: 1,
+ fillColor: '#FCF6CF',
+ fillOpacity: 0.4
+ }
+ }
+ },
+
+ initialize: function () {
+
+ this.extent = this.el.data('extent');
+
+ // fix bbox when w-long is positive while e-long is negative.
+ // assuming coordinate sequence is west to east (left to right)
+ if (this.extent.type == 'Polygon'
+ && this.extent.coordinates[0].length == 5) {
+ _coordinates = this.extent.coordinates[0]
+ w = _coordinates[0][0];
+ e = _coordinates[2][0];
+ if (w >= 0 && e < 0) {
+ w_new = w
+ while (w_new > e) w_new -=360
+ for (var i = 0; i < _coordinates.length; i++) {
+ if (_coordinates[i][0] == w) {
+ _coordinates[i][0] = w_new
+ };
+ };
+ this.extent.coordinates[0] = _coordinates
+ };
+ };
+
+ // hack to make leaflet use a particular location to look for images
+ L.Icon.Default.imagePath = this.options.site_url + 'js/vendor/leaflet/images';
+
+ jQuery.proxyAll(this, /_on/);
+ this.el.ready(this._onReady);
+
+ },
+
+ _onReady: function(){
+
+ var map, backgroundLayer, extentLayer, ckanIcon;
+
+ if (!this.extent) {
+ return false;
+ }
+ // OK map time
+ const mapConfig = {
+ 'type': 'wms',
+ 'wms.url': 'https://geodaten.metropoleruhr.de/spw2',
+ 'wms.layers': 'spw2_light',
+ 'wms.version': '1.3.0'
+ }
+ const leafletMapOptions = {
+ attributionControl: false,
+ drawControlTooltips: true,
+ maxBoundsViscosity: 1,
+ minZoom: 8
+ }
+ map = ckan.rvrWebMap(
+ 'dataset-map-container',
+ mapConfig,
+ leafletMapOptions
+ );
+ var ckanIcon = L.Icon.extend({options: this.options.styles.point});
+
+ var extentLayer = L.geoJson(this.extent, {
+ style: this.options.styles.default_,
+ pointToLayer: function (feature, latLng) {
+ return new L.Marker(latLng, {icon: new ckanIcon})
+ }});
+ extentLayer.addTo(map);
+
+ if (this.extent.type == 'Point'){
+ map.setView(L.latLng(this.extent.coordinates[1], this.extent.coordinates[0]), 9);
+ } else {
+ map.fitBounds(extentLayer.getBounds());
+ }
+ }
+ }
+});
\ No newline at end of file
diff --git a/ckanext/rvr/assets/webassets.yml b/ckanext/rvr/assets/webassets.yml
index bc4dd56..b4f9f1a 100644
--- a/ckanext/rvr/assets/webassets.yml
+++ b/ckanext/rvr/assets/webassets.yml
@@ -56,3 +56,12 @@ bbox_generator_js:
- js/vendors/leaflet.draw/leaflet.draw.js
- js/rvrMap.js
- js/rvrBBOXGenerator.js
+
+rvr_dataset_map_generator_js:
+ output: rvr/%(version)s_rvr_dataset_map_generator.js
+ extra:
+ preload:
+ - vendor/jquery
+ contents:
+ - js/rvrMap.js
+ - js/rvrDatasetMapGenerator.js
diff --git a/ckanext/rvr/templates/package/read_base.html b/ckanext/rvr/templates/package/read_base.html
index ad47683..69a154e 100644
--- a/ckanext/rvr/templates/package/read_base.html
+++ b/ckanext/rvr/templates/package/read_base.html
@@ -37,13 +37,10 @@
{% endif %}
{% endblock %}
- {{ _('Karte') }}
- {% set dataset_extent = h.get_pkg_dict_extra(c.pkg_dict, 'spatial', '') %}
- {% if dataset_extent %}
- {% snippet "spatial/snippets/dataset_map_base.html", extent=dataset_extent %}
- {% endif %}
-