From f1d4e55fbe8e566708fadc9e23fe599b88827591 Mon Sep 17 00:00:00 2001 From: Atle Frenvik Sveen Date: Thu, 12 Nov 2015 15:58:36 +0100 Subject: [PATCH] refactor code, trying to solve not show marker issue (ref #132) --- common/js/KulturminneFunctions.js | 370 ++++++++++++----------------- dist/scripts.js | 371 ++++++++++++------------------ dist/scripts.min.js | 2 +- dist/scripts3d.js | 371 ++++++++++++------------------ dist/scripts3d.min.js | 4 +- 5 files changed, 461 insertions(+), 657 deletions(-) diff --git a/common/js/KulturminneFunctions.js b/common/js/KulturminneFunctions.js index db25a603..c6cc327b 100644 --- a/common/js/KulturminneFunctions.js +++ b/common/js/KulturminneFunctions.js @@ -6,212 +6,74 @@ KR.Config = KR.Config || {}; 'use strict'; ns.getKulturminneFunctions = function (api) { -/* - var _vectorLayer; - var loadedIds = []; - - - - function findLayer(lok) { - if (!_vectorLayer) { - return null; - } - - return _.find(_vectorLayer.getLayers(), function (layer) { - return (layer.feature.properties.id === lok); - }); - } - var loadKulturminnePoly = function (map, dataset, features) { - if (features) { - var ids = _.map(features, function (feature) { - return feature.properties.id; - }); - - var idsToLoad = _.filter(ids, function (id) { - return loadedIds.indexOf(id) === -1; - }); - - loadedIds = loadedIds.concat(idsToLoad); + var _vectorLayer; + var _map; + var _polygonLayer; + var _loadEnkeltminner; + var _enkeltMinneLayer; + var _loadedIds = []; + var _hideMarker = false; + var _showEnkeltminner = true; - if (idsToLoad.length) { - var q = { - api: 'kulturminnedataSparql', - type: 'lokalitetpoly', - lokalitet: idsToLoad - }; - api.getData(q, function (geoJson) { - dataset.extraFeatures.addData(geoJson); - if (!geoJson.features) { - return - } - _.chain(geoJson.features) - .map(function (f) { - return f.properties.lok; - }) - .uniq() - .each(function (lok) { - var l = findLayer(lok); - if (l) { - l.setOpacity(0); - } - }); - }); - } - } + var _hidePolygonLayer = function () { + map.removeLayer(_polygonLayer); }; - var initKulturminnePoly = function (map, dataset, vectorLayer) { - console.log(vectorLayer); - _vectorLayer = vectorLayer; - var showEnkeltminner = true; - if (_.has(dataset, 'showEnkeltminner')) { - showEnkeltminner = dataset.showEnkeltminner; - } - var enkeltMinneLayer; - var loadEnkeltminner; - if (showEnkeltminner) { + var _showPolygonLayer = function () { + map.addLayer(_polygonLayer); + }; - if (!_.has(dataset, 'enkeltminner')) { - dataset.enkeltminner = {}; + var _checkRemove = function (direction) { + var shouldShow = (direction === 'down'); + if (shouldShow) { + _map.addLayer(_polygonLayer); + if (_enkeltMinneLayer) { + _map.addLayer(_enkeltMinneLayer); } - - var enkeltminneStyle = dataset.enkeltminner.style || { - color: '#fff', - weight: 1, - fillColor: '#B942D0' - }; - - enkeltMinneLayer = L.geoJson(null, { - onEachFeature: function (feature, layer) { - feature.properties.provider = dataset.enkeltminner.provider || 'Enkeltminne'; - feature.properties.color = dataset.enkeltminner.sidebarColor || '#B942D0'; - layer.on('click', function () { - if (map.sidebar) { - map.sidebar.showFeature( - feature, - dataset.enkeltminner.template || KR.Util.getDatasetTemplate('ra_enkeltminne') - ); - } - }); - }, - style: function () { - return enkeltminneStyle; - } - }).addTo(map); - loadEnkeltminner = function (feature) { - var q = { - api: 'kulturminnedataSparql', - type: 'enkeltminner', - lokalitet: feature.properties.lok - }; - api.getData(q, function (geoJson) { - enkeltMinneLayer.clearLayers(); - enkeltMinneLayer.addData(geoJson); - }); - }; - } - - var highlightPolygons = true; - var onPolyClick; - if (highlightPolygons) { - - var deselectPolys = function () { - _.each(dataset.extraFeatures.getLayers(), function (l) { - l.setStyle(KR.Style.getPathStyle(l.feature, true)); - }); - }; - - onPolyClick = function (e) { - deselectPolys(); - var lok = e.layer.feature.properties.id; - var poly = _.find(dataset.extraFeatures.getLayers(), function (l) { - return (l.feature.properties.lok === lok); - }); - console.log(poly); - if (! poly) { - return; - } - poly.setStyle({ - weight: 1, - color: '#436978', - fillColor: '#72B026', - clickable: true, - opacity: 0.8, - fillOpacity: 0.4 - }); + } else { + _map.removeLayer(_polygonLayer); + if (_enkeltMinneLayer) { + _map.removeLayer(_enkeltMinneLayer); } - - vectorLayer.on('click', onPolyClick); - - map.on('layerDeselect', function (e) { - deselectPolys(); - }); } + }; - dataset.extraFeatures = L.geoJson(null, { - onEachFeature: function (feature, layer) { - if (dataset.extras && dataset.extras.groupId) { - layer.setStyle(KR.Style.getPathStyleForGroup(dataset.extras.groupId)); - } else { - feature.properties.datasetId = dataset.id; - layer.setStyle(KR.Style.getPathStyle(feature, true)); - } - - layer.on('click', function () { - - if (loadEnkeltminner) { - loadEnkeltminner(feature); - } - - var parent = _.find(dataset.geoJSONLayer.getLayers(), function (parentLayer) { - return (parentLayer.feature.properties.id === feature.properties.lok); - }); - - if (parent) { - parent.fire('click'); - if (onPolyClick) { - onPolyClick({layer: parent}) - } - } - }); + var _checkThresholdPassed = function (map, threshold, callback) { + var prevZoom; + map.on('zoomstart', function (e) { + prevZoom = map.getZoom(); + }); + map.on('zoomend', function (e) { + var currentZoom = map.getZoom(); + if (prevZoom > threshold && currentZoom <= threshold) { + callback('up'); } - }).addTo(map); - - - map.on('zoomend', function () { - var shouldShow = !(map.getZoom() < 13); - if (shouldShow) { - if (!map.hasLayer(dataset.extraFeatures)) { - map.addLayer(dataset.extraFeatures); - } - } else { - if (map.hasLayer(dataset.extraFeatures)) { - map.removeLayer(dataset.extraFeatures); - } + if (prevZoom <= threshold && currentZoom > threshold) { + callback('down'); } }); + } - vectorLayer.on('hide', function () { - map.removeLayer(dataset.extraFeatures); - if (enkeltMinneLayer) { - map.removeLayer(enkeltMinneLayer) - } + var _getMarkerForId = function (id) { + return _.find(_vectorLayer.getLayers(), function (layer) { + return (layer.feature.properties.id === id); }); + }; - vectorLayer.on('show', function () { - map.addLayer(dataset.extraFeatures); - if (enkeltMinneLayer) { - map.addLayer(enkeltMinneLayer) - } + var _getPolygonForId = function (id) { + return _.find(_polygonLayer.getLayers(), function (layer) { + return (layer.feature.properties.lok === id); }); }; - */ - var _vectorLayer; - var _map; - var _polygonLayer; - var _loadedIds = []; + var _polygonClicked = function (feature, layer) { + var parent = _getMarkerForId(feature.properties.lok); + if (parent) { + parent.fire('click'); + } + }; + var _createPolygonLayer = function (dataset) { return L.geoJson(null, { onEachFeature: function (feature, layer) { @@ -221,50 +83,117 @@ KR.Config = KR.Config || {}; feature.properties.datasetId = dataset.id; layer.setStyle(KR.Style.getPathStyle(feature, true)); } + layer.on('click', function () { + _polygonClicked(feature, layer); + }); } }).addTo(_map); }; - var _hidePolygonLayer = function () { - map.removeLayer(_polygonLayer); + var _checkCluster = function () { + /* + if (!_loadedIds.length) { + return; + } + _.each(_loadedIds, function (loadedId) { + var marker = _getMarkerForId(loadedId); + var visibleOne = _vectorLayer.getVisibleParent(marker); + //console.log(visibleOne._leaflet_id, marker._leaflet_id); + //console.log(marker, visibleOne); + }); + */ }; - var _showPolygonLayer = function () { - map.addLayer(_polygonLayer); + var _deselectPolygons = function () { + _.each(_polygonLayer.getLayers(), function (l) { + l.setStyle(KR.Style.getPathStyle(l.feature, true)); + }); }; - var _checkRemove = function () { - var shouldShow = !(_map.getZoom() < 13); - if (shouldShow) { - if (!map.hasLayer(dataset.extraFeatures)) { - map.addLayer(dataset.extraFeatures); - } - } else { - if (map.hasLayer(dataset.extraFeatures)) { - map.removeLayer(dataset.extraFeatures); - } + var _markerClicked = function (e) { + _deselectPolygons(); + var id = e.layer.feature.properties.id; + var poly = _getPolygonForId(id); + if (!poly) { + return; + } + poly.setStyle({ + weight: 1, + color: '#436978', + fillColor: '#72B026', + clickable: true, + opacity: 0.8, + fillOpacity: 0.4 + }); + if (_loadEnkeltminner) { + _loadEnkeltminner(e.layer.feature); + } + } + + var _enkeltminneClick = function (feature, dataset) { + if (_map.sidebar) { + _map.sidebar.showFeature( + feature, + dataset.enkeltminner.template || KR.Util.getDatasetTemplate('ra_enkeltminne') + ); } }; - var _checkThresholdPassed = function (map, threshold, callback) { - var prevZoom; - map.on('zoomstart', function (e) { - prevZoom = map.getZoom(); - }); - map.on('zoomend', function (e) { - var currentZoom = map.getZoom(); - console.log('end:', prevZoom, currentZoom); - }); + var _setupEnkeltminner = function (dataset) { + if (!_.has(dataset, 'enkeltminner')) { + dataset.enkeltminner = {}; + } + + var enkeltminneStyle = dataset.enkeltminner.style || { + color: '#fff', + weight: 1, + fillColor: '#B942D0' + }; + + _enkeltMinneLayer = L.geoJson(null, { + onEachFeature: function (feature, layer) { + feature.properties.provider = dataset.enkeltminner.provider || 'Enkeltminne'; + feature.properties.color = dataset.enkeltminner.sidebarColor || '#B942D0'; + layer.on('click', function () { _enkeltminneClick(feature, dataset)}); + }, + style: function () { + return enkeltminneStyle; + } + }).addTo(_map); + + _loadEnkeltminner = function (feature) { + var q = { + api: 'kulturminnedataSparql', + type: 'enkeltminner', + lokalitet: feature.properties.id + }; + api.getData(q, function (geoJson) { + _enkeltMinneLayer.clearLayers(); + _enkeltMinneLayer.addData(geoJson); + }); + }; } + var initKulturminnePoly = function (map, dataset, vectorLayer) { _vectorLayer = vectorLayer; _map = map; - vectorLayer.on('hide', _hidePolygonLayer); - vectorLayer.on('show', _showPolygonLayer); + _vectorLayer.on('hide', _hidePolygonLayer); + _vectorLayer.on('show', _showPolygonLayer); _polygonLayer = _createPolygonLayer(dataset) - _checkThresholdPassed(_map, 13); + _checkThresholdPassed(_map, 13, _checkRemove); + _map.on('zoomend', _checkCluster); + _map.on('layerDeselect', _deselectPolygons); + _vectorLayer.on('click', _markerClicked); + + if (_.has(dataset, 'showEnkeltminner')) { + _showEnkeltminner = dataset.showEnkeltminner; + } + + if (_showEnkeltminner) { + _setupEnkeltminner(dataset); + } }; var _dataLoaded = function (geoJson) { @@ -275,14 +204,20 @@ KR.Config = KR.Config || {}; }) .uniq() .value(); - _loadedIds = _loadedIds.concat(newIds); - console.log("new ids", newIds); + if (_hideMarker) { + _.each(newIds, function (newId) { + var marker = _getMarkerForId(newId); + if (marker) { + //marker.setOpacity(0); + } + }) + } + _loadedIds = _loadedIds.concat(newIds); } var loadKulturminnePoly = function (map, dataset, features) { if (!features) { - console.log('no features to show for'); return; } @@ -296,7 +231,6 @@ KR.Config = KR.Config || {}; .value() if (!idsToLoad.length) { - console.log("no new features to load"); return; } var q = { diff --git a/dist/scripts.js b/dist/scripts.js index cf0647ec..ef838246 100644 --- a/dist/scripts.js +++ b/dist/scripts.js @@ -3153,212 +3153,74 @@ KR.Config = KR.Config || {}; 'use strict'; ns.getKulturminneFunctions = function (api) { -/* - var _vectorLayer; - var loadedIds = []; - - - - function findLayer(lok) { - if (!_vectorLayer) { - return null; - } - - return _.find(_vectorLayer.getLayers(), function (layer) { - return (layer.feature.properties.id === lok); - }); - } - var loadKulturminnePoly = function (map, dataset, features) { - if (features) { - var ids = _.map(features, function (feature) { - return feature.properties.id; - }); - - var idsToLoad = _.filter(ids, function (id) { - return loadedIds.indexOf(id) === -1; - }); + var _vectorLayer; + var _map; + var _polygonLayer; + var _loadEnkeltminner; + var _enkeltMinneLayer; + var _loadedIds = []; + var _hideMarker = false; + var _showEnkeltminner = true; - loadedIds = loadedIds.concat(idsToLoad); - - if (idsToLoad.length) { - var q = { - api: 'kulturminnedataSparql', - type: 'lokalitetpoly', - lokalitet: idsToLoad - }; - api.getData(q, function (geoJson) { - dataset.extraFeatures.addData(geoJson); - if (!geoJson.features) { - return - } - _.chain(geoJson.features) - .map(function (f) { - return f.properties.lok; - }) - .uniq() - .each(function (lok) { - var l = findLayer(lok); - if (l) { - l.setOpacity(0); - } - }); - }); - } - } + var _hidePolygonLayer = function () { + map.removeLayer(_polygonLayer); }; - var initKulturminnePoly = function (map, dataset, vectorLayer) { - console.log(vectorLayer); - _vectorLayer = vectorLayer; - var showEnkeltminner = true; - if (_.has(dataset, 'showEnkeltminner')) { - showEnkeltminner = dataset.showEnkeltminner; - } - var enkeltMinneLayer; - var loadEnkeltminner; - if (showEnkeltminner) { + var _showPolygonLayer = function () { + map.addLayer(_polygonLayer); + }; - if (!_.has(dataset, 'enkeltminner')) { - dataset.enkeltminner = {}; + var _checkRemove = function (direction) { + var shouldShow = (direction === 'down'); + if (shouldShow) { + _map.addLayer(_polygonLayer); + if (_enkeltMinneLayer) { + _map.addLayer(_enkeltMinneLayer); } - - var enkeltminneStyle = dataset.enkeltminner.style || { - color: '#fff', - weight: 1, - fillColor: '#B942D0' - }; - - enkeltMinneLayer = L.geoJson(null, { - onEachFeature: function (feature, layer) { - feature.properties.provider = dataset.enkeltminner.provider || 'Enkeltminne'; - feature.properties.color = dataset.enkeltminner.sidebarColor || '#B942D0'; - layer.on('click', function () { - if (map.sidebar) { - map.sidebar.showFeature( - feature, - dataset.enkeltminner.template || KR.Util.getDatasetTemplate('ra_enkeltminne') - ); - } - }); - }, - style: function () { - return enkeltminneStyle; - } - }).addTo(map); - loadEnkeltminner = function (feature) { - var q = { - api: 'kulturminnedataSparql', - type: 'enkeltminner', - lokalitet: feature.properties.lok - }; - api.getData(q, function (geoJson) { - enkeltMinneLayer.clearLayers(); - enkeltMinneLayer.addData(geoJson); - }); - }; - } - - var highlightPolygons = true; - var onPolyClick; - if (highlightPolygons) { - - var deselectPolys = function () { - _.each(dataset.extraFeatures.getLayers(), function (l) { - l.setStyle(KR.Style.getPathStyle(l.feature, true)); - }); - }; - - onPolyClick = function (e) { - deselectPolys(); - var lok = e.layer.feature.properties.id; - var poly = _.find(dataset.extraFeatures.getLayers(), function (l) { - return (l.feature.properties.lok === lok); - }); - console.log(poly); - if (! poly) { - return; - } - poly.setStyle({ - weight: 1, - color: '#436978', - fillColor: '#72B026', - clickable: true, - opacity: 0.8, - fillOpacity: 0.4 - }); + } else { + _map.removeLayer(_polygonLayer); + if (_enkeltMinneLayer) { + _map.removeLayer(_enkeltMinneLayer); } - - vectorLayer.on('click', onPolyClick); - - map.on('layerDeselect', function (e) { - deselectPolys(); - }); } + }; - dataset.extraFeatures = L.geoJson(null, { - onEachFeature: function (feature, layer) { - if (dataset.extras && dataset.extras.groupId) { - layer.setStyle(KR.Style.getPathStyleForGroup(dataset.extras.groupId)); - } else { - feature.properties.datasetId = dataset.id; - layer.setStyle(KR.Style.getPathStyle(feature, true)); - } - - layer.on('click', function () { - - if (loadEnkeltminner) { - loadEnkeltminner(feature); - } - - var parent = _.find(dataset.geoJSONLayer.getLayers(), function (parentLayer) { - return (parentLayer.feature.properties.id === feature.properties.lok); - }); - - if (parent) { - parent.fire('click'); - if (onPolyClick) { - onPolyClick({layer: parent}) - } - } - }); + var _checkThresholdPassed = function (map, threshold, callback) { + var prevZoom; + map.on('zoomstart', function (e) { + prevZoom = map.getZoom(); + }); + map.on('zoomend', function (e) { + var currentZoom = map.getZoom(); + if (prevZoom > threshold && currentZoom <= threshold) { + callback('up'); } - }).addTo(map); - - - map.on('zoomend', function () { - var shouldShow = !(map.getZoom() < 13); - if (shouldShow) { - if (!map.hasLayer(dataset.extraFeatures)) { - map.addLayer(dataset.extraFeatures); - } - } else { - if (map.hasLayer(dataset.extraFeatures)) { - map.removeLayer(dataset.extraFeatures); - } + if (prevZoom <= threshold && currentZoom > threshold) { + callback('down'); } }); + } - vectorLayer.on('hide', function () { - map.removeLayer(dataset.extraFeatures); - if (enkeltMinneLayer) { - map.removeLayer(enkeltMinneLayer) - } + var _getMarkerForId = function (id) { + return _.find(_vectorLayer.getLayers(), function (layer) { + return (layer.feature.properties.id === id); }); + }; - vectorLayer.on('show', function () { - map.addLayer(dataset.extraFeatures); - if (enkeltMinneLayer) { - map.addLayer(enkeltMinneLayer) - } + var _getPolygonForId = function (id) { + return _.find(_polygonLayer.getLayers(), function (layer) { + return (layer.feature.properties.lok === id); }); }; - */ - var _vectorLayer; - var _map; - var _polygonLayer; - var _loadedIds = []; + var _polygonClicked = function (feature, layer) { + var parent = _getMarkerForId(feature.properties.lok); + if (parent) { + parent.fire('click'); + } + }; + var _createPolygonLayer = function (dataset) { return L.geoJson(null, { onEachFeature: function (feature, layer) { @@ -3368,50 +3230,118 @@ KR.Config = KR.Config || {}; feature.properties.datasetId = dataset.id; layer.setStyle(KR.Style.getPathStyle(feature, true)); } + layer.on('click', function () { + _polygonClicked(feature, layer); + }); } }).addTo(_map); }; - var _hidePolygonLayer = function () { - map.removeLayer(_polygonLayer); + var _checkCluster = function () { + /* + if (!_loadedIds.length) { + return; + } + _.each(_loadedIds, function (loadedId) { + var marker = _getMarkerForId(loadedId); + var visibleOne = _vectorLayer.getVisibleParent(marker); + //console.log(visibleOne._leaflet_id, marker._leaflet_id); + //console.log(marker, visibleOne); + }); + */ }; - var _showPolygonLayer = function () { - map.addLayer(_polygonLayer); + var _deselectPolygons = function () { + _.each(_polygonLayer.getLayers(), function (l) { + l.setStyle(KR.Style.getPathStyle(l.feature, true)); + }); }; - var _checkRemove = function () { - var shouldShow = !(_map.getZoom() < 13); - if (shouldShow) { - if (!map.hasLayer(dataset.extraFeatures)) { - map.addLayer(dataset.extraFeatures); - } - } else { - if (map.hasLayer(dataset.extraFeatures)) { - map.removeLayer(dataset.extraFeatures); - } + var _markerClicked = function (e) { + _deselectPolygons(); + var id = e.layer.feature.properties.id; + var poly = _getPolygonForId(id); + if (!poly) { + return; + } + poly.setStyle({ + weight: 1, + color: '#436978', + fillColor: '#72B026', + clickable: true, + opacity: 0.8, + fillOpacity: 0.4 + }); + if (_loadEnkeltminner) { + console.log("loadEnkeltminner") + _loadEnkeltminner(e.layer.feature); + } + } + + var _enkeltminneClick = function (feature, dataset) { + if (_map.sidebar) { + _map.sidebar.showFeature( + feature, + dataset.enkeltminner.template || KR.Util.getDatasetTemplate('ra_enkeltminne') + ); } }; - var _checkThresholdPassed = function (map, threshold, callback) { - var prevZoom; - map.on('zoomstart', function (e) { - prevZoom = map.getZoom(); - }); - map.on('zoomend', function (e) { - var currentZoom = map.getZoom(); - console.log('end:', prevZoom, currentZoom); - }); + var _setupEnkeltminner = function (dataset) { + if (!_.has(dataset, 'enkeltminner')) { + dataset.enkeltminner = {}; + } + + var enkeltminneStyle = dataset.enkeltminner.style || { + color: '#fff', + weight: 1, + fillColor: '#B942D0' + }; + + _enkeltMinneLayer = L.geoJson(null, { + onEachFeature: function (feature, layer) { + feature.properties.provider = dataset.enkeltminner.provider || 'Enkeltminne'; + feature.properties.color = dataset.enkeltminner.sidebarColor || '#B942D0'; + layer.on('click', function () { _enkeltminneClick(feature, dataset)}); + }, + style: function () { + return enkeltminneStyle; + } + }).addTo(_map); + + _loadEnkeltminner = function (feature) { + var q = { + api: 'kulturminnedataSparql', + type: 'enkeltminner', + lokalitet: feature.properties.id + }; + api.getData(q, function (geoJson) { + _enkeltMinneLayer.clearLayers(); + _enkeltMinneLayer.addData(geoJson); + }); + }; } + var initKulturminnePoly = function (map, dataset, vectorLayer) { _vectorLayer = vectorLayer; _map = map; - vectorLayer.on('hide', _hidePolygonLayer); - vectorLayer.on('show', _showPolygonLayer); + _vectorLayer.on('hide', _hidePolygonLayer); + _vectorLayer.on('show', _showPolygonLayer); _polygonLayer = _createPolygonLayer(dataset) - _checkThresholdPassed(_map, 13); + _checkThresholdPassed(_map, 13, _checkRemove); + _map.on('zoomend', _checkCluster); + _map.on('layerDeselect', _deselectPolygons); + _vectorLayer.on('click', _markerClicked); + + if (_.has(dataset, 'showEnkeltminner')) { + _showEnkeltminner = dataset.showEnkeltminner; + } + + if (_showEnkeltminner) { + _setupEnkeltminner(dataset); + } }; var _dataLoaded = function (geoJson) { @@ -3422,14 +3352,20 @@ KR.Config = KR.Config || {}; }) .uniq() .value(); - _loadedIds = _loadedIds.concat(newIds); - console.log("new ids", newIds); + if (_hideMarker) { + _.each(newIds, function (newId) { + var marker = _getMarkerForId(newId); + if (marker) { + //marker.setOpacity(0); + } + }) + } + _loadedIds = _loadedIds.concat(newIds); } var loadKulturminnePoly = function (map, dataset, features) { if (!features) { - console.log('no features to show for'); return; } @@ -3443,7 +3379,6 @@ KR.Config = KR.Config || {}; .value() if (!idsToLoad.length) { - console.log("no new features to load"); return; } var q = { diff --git a/dist/scripts.min.js b/dist/scripts.min.js index 949a6d59..a2994f9b 100644 --- a/dist/scripts.min.js +++ b/dist/scripts.min.js @@ -1,2 +1,2 @@ var KR=this.KR||{};!function(a){"use strict";a.parseError=function(a){if(a.responseJSON){if(a.responseJSON.error)return a.responseJSON.error.join(", ");if(a.responseJSON.status)return a.responseJSON.status}return a.statusText?a.statusText:a.error?a.error.info?a.error.info:a.error.error?a.error.error:a.error:"Unknown error"},a.errorHandler=function(b){var c=$(b);c.find(".close").on("click",function(){c.find(".content").html(""),c.remove()});var d=_.template("
<%= dataset %>: <%= error %>
");return function(b){var e=d({dataset:b.dataset,error:a.parseError(b.error)});c.parent()?c.find(".content").append(e):c.find(".content").html(e),$("body").append(c)}}}(KR);var KR=this.KR||{};KR.Config={contentIcons:{IMAGE:"camera-retro",VIDEO:"file-video-o",SOUND:"music",TEXT:"file-text","default":"file-o"},templates:{}},KR.Config.ImageCaheUrl="http://egbtmre.cloudimg.io",KR.Util=KR.Util||{},function(a){"use strict";function b(a,b){var c=a.lastIndexOf(b);return-1!==c&&c+b.length===a.length}function c(a){return 1e3>a?"0"+a:a}a.iconForContentType=function(a){var b=a.properties.contentType;return _.has(KR.Config.contentIcons,b)?KR.Config.contentIcons[b]:KR.Config.contentIcons["default"]},a.getDatasetTemplate=function(a){var b=$("#"+a+"_template").html();return b?_.template(b):void 0},a.templateForDataset=function(a){return _.has(KR.Config.templates,a)?KR.Config.templates[a]:void 0},a.createStyleString=function(a){return _.map(a,function(a,b){return b+": "+a}).join(";")},a.colorForProvider=function(a,b){var c=!0;"hex"!==b&&(c=!1);var d={properties:{datasetId:a}};return KR.Style.colorForFeature(d,c,!0)},a.featureClick=function(a){return function(b,c,d){c.on("click",function(c){d&&d.toPoint&&d.toPoint.stopPolyClick&&!c.parent||(d?a.showFeature(b,d.template,d.getFeatureData):a.showFeature(b))})}},a.getTemplateForFeature=function(a,b){if(b){if(b.datasets){var c=_.find(b.datasets,function(b){return b._knreise_id===a.properties.datasetID});return c.template}return b.template}},a.clusterClick=function(b){return function(c,d){c.on("clusterclick",function(c){var e=_.map(c.layer.getAllChildMarkers(),function(b){var c=b.feature;return d&&!c.template&&(c.template=a.getTemplateForFeature(c,d)),c}),f=_.extend({},{template:null,getFeatureData:null,noListThreshold:null},d);b.showFeatures(e,f.template,f.getFeatureData,f.noListThreshold)})}},a.hexToRgba=function(a,b){b=b||1;var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);if(!c)return 0;var d={r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)};return"rgba("+d.r+","+d.g+","+d.b+","+b+")"},a.filterByBbox=function(a,b){var c=turf.featurecollection([turf.bboxPolygon(KR.Util.splitBbox(b))]);return turf.within(a,c)},a.getDatasetId=function(a){return"norvegiana"===a.dataset.api?a.dataset.dataset:"wikipedia"===a.dataset.api?"wikipedia":a.id?a.id:KR.Util.stamp(a)},"undefined"!=typeof L&&(L.latLngBounds.fromBBoxArray=function(a){return new L.LatLngBounds(new L.LatLng(a[1],a[0]),new L.LatLng(a[3],a[2]))},L.latLngBounds.fromBBoxString=function(a){return L.latLngBounds.fromBBoxArray(KR.Util.splitBbox(a))},L.rectangle.fromBounds=function(a){return L.rectangle([a.getSouthWest(),a.getNorthEast()])}),a.parseQueryString=function(a){var b=decodeURIComponent(a);if(""!==b)return _.reduce(b.replace("?","").split("&"),function(a,b){b=b.split("=");var c=b[1];return"true"===c?c=!0:"false"===c&&(c=!1),a[b[0]]=c,a},{})};var d=_.template("<%= totalt %> (<%= menn %> menn, <%= kvinner %> kvinner)");a.formatPersons=function(a){var b=a.split("-");return b.length<2?a:d({totalt:b[0],menn:b[1],kvinner:b[2]})},a.getBaseLayer=function(a,b){var c={nib:KR.getNibLayer,hist:function(a){a(L.tileLayer.wms("http://wms.geonorge.no/skwms1/wms.historiskekart",{layers:"historiskekart",format:"image/png",attribution:"Kartverket"}))}};if(_.has(c,a))c[a](b);else{var d=navigator.userAgent.indexOf("Safari")>-1,e=!d;b(L.tileLayer.kartverket(a,{useCache:e}))}},a.getLine=function(a,c,d){if(_.isFunction(c))return void c(function(a){d(a)});var e;if(0===c.indexOf("utno/")){var f=c.replace("utno/","");e={api:"utno",id:f,type:"gpx"}}else 0===c.indexOf("http")&&(b(c,"kml")?e={api:"kml",url:c}:b(c,"gpx")||-1!==c.indexOf("http://ut.no/tur/")?e={api:"gpx",url:c}:b(c,"geojson")&&(e={api:"geojson",url:c}));e?a.getData(e,function(a){d(a)}):alert("Kunne ikke laste linjegeometri")},a.messageDisplayer=function(a){return function(b,c){var d=$(a);d.find(".close").on("click",function(){d.find(".content").html(""),d.remove()}),d.addClass("alert-"+b),d.find(".content").html(c),$("body").append(d)}},a.mostlyCoveringMunicipality=function(a,b,c){var d="ST_MakeEnvelope("+b+", 4326)",e="SELECT komm FROM kommuner WHERE ST_Intersects(the_geom, "+d+")ORDER BY st_area(st_intersection(the_geom, "+d+")) DESC LIMIT 1",f={api:"cartodb",query:e,mapper:function(a){return a.rows[0].komm}};a.getData(f,c)},a.sparqlBbox=function(a,b,d,e,f){KR.Util.mostlyCoveringMunicipality(a,d,function(d){b.kommune=c(d),a.getData(b,e,f)})},a.distanceAndSort=function(a,b){var c=_.map(a.features,function(a){return a.properties.distance=turf.distance(b,a),a});return turf.featurecollection(c.sort(function(a,b){return a.properties.distanceb.properties.distance?1:0}))},a.round=function(a,b){_.isUndefined(b)&&(b=2);var c=Math.pow(10,b);return Math.round(a*c)/c};var e=_.template("#<%= zoom %>/<%= lat %>/<%= lon %>");a.getPositionHash=function(b,c,d){return e({zoom:d,lat:a.round(b,4),lon:a.round(c,4)})},a.WORLD={type:"Feature",geometry:{type:"Polygon",coordinates:[[[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]]}},a.createMap=function(b,c){c=c||{};var d=L.map(b,{minZoom:c.minZoom||3,maxZoom:c.maxZoom||18,maxBounds:L.geoJson(a.WORLD).getBounds()}),e=c.layer||"norges_grunnkart_graatone";return _.isString(e)?KR.Util.getBaseLayer(e,function(a){a.addTo(d)}):e.addTo(d),d},a.setupSidebar=function(a,b){b=b||{};var c=KR.Util.getDatasetTemplate("popup"),d=_.template($("#list_item_template").html()),e=_.template($("#marker_template").html()),f=_.template($("#thumbnail_template").html()),g=_.template($("#footer_template").html()),h=_.extend({},{position:"left",template:c,listElementTemplate:d,markerTemplate:e,thumbnailTemplate:f,footerTemplate:g},b),i=L.Knreise.Control.sidebar("sidebar",h);return a.addControl(i),i},a.distanceAndBearing=function(a,b){return{distance:1e3*turf.distance(a,b,"kilometers"),bearing:turf.bearing(a,b)}};var f=_.template("<%= service %>/s/crop/<%= width %>x<%= height %>/<%= image %>");a.getImageCache=function(a,b,c){return KR.Config.ImageCaheUrl?f({service:KR.Config.ImageCaheUrl,width:b,height:c,image:a}):a},a.isInIframe=function(){try{return window.self!==window.top}catch(a){return!0}}}(KR.Util);var KR=this.KR||{};KR.Style={},function(a){"use strict";function b(a){var b=a.properties.vernef_id;return _.find(p,function(a){return-1!==a.ids.indexOf(b)})}function c(a){return u[a]||"blue"}function d(a,b,c,d){return _.isFunction(a[b])?d?a[b]():a[b](c):a[b]}function e(a,b,c){return c?d(a,"fillcolor",b,!0):d(a,"fillcolor",b)}function f(a,b){return a.bordercolor?d(a,"bordercolor",b):e(a,b)}function g(b){return a.groups[b]}function h(b){var c;return b.properties&&b.properties.groupId?g(b.properties.groupId):(b.properties&&b.properties.datasetId&&(c=a.getDatasetStyle(b.properties.datasetId)),c?c:_.extend({},s))}function i(a,b,c){return c=c||9,{radius:c,weight:1,opacity:1,color:a,fillColor:b,fillOpacity:.4}}function j(a,b,c){return L.circleMarker(a,i(b,c))}function k(a){return L.Knreise.icon({markerColor:a})}function l(a,b,c){var d="";return a.properties&&a.properties.title&&(d=a.properties.title),L.marker(b,{icon:c,title:d})}function m(a,b,c){if(a.properties&&a.properties.thumbnail){var d={"border-color":b,"background-image":"url("+a.properties.thumbnail+")"};c&&(d["border-width"]="3px");var e=KR.Util.getImageCache(a.properties.thumbnail,50,50),f='
';return new L.DivIcon({className:"leaflet-marker-circle",html:f,iconSize:[50,50],iconAnchor:[25,25]})}}function n(a,b,c){var d=_.filter(a,function(a){return a.feature.properties.thumbnail});if(d.length){var e;_.isArray(b)&&(e=_.rest(b),b=b[0]);var f=KR.Util.getImageCache(d[0].feature.properties.thumbnail,50,50),g={"border-color":b,"background-image":"url("+f+");"};e&&(g["box-shadow"]=_.map(e,function(a,b){var c=2*(b+1);return"0 0 0 "+c+"px "+a}).join(",")+";"),c&&(g["border-width"]="3px");var h='
'+a.length+"";return new L.DivIcon({className:"leaflet-marker-photo",html:h,iconSize:[60,60],iconAnchor:[30,30]})}}function o(a,b){var c=KR.Util.hexToRgba(b,.4);return new L.DivIcon({className:"leaflet-marker-circle",html:'
'+a.length+"",iconSize:[20,20],iconAnchor:[10,10]})}var p={landskapsvern:{ids:["LVO","LVOD","LVOP","LVOPD","BV","MAV","P","GVS","MIV","NM","BVV","PO","DO","D"],style:{fillColor:"#d8cb7a",color:"#9c8f1b"}},nasjonalpark:{ids:["NP","NPS"],style:{fillColor:"#7f9aac",color:"#b3a721"}},naturreservat:{ids:["NR","NRS"],style:{fillColor:"#ef9874",color:"#ef9873"}}},q="#72B026",r="#38A9DC",s={fillcolor:r,circle:!1,thumbnail:!0},t={difo:"Digitalt fortalt",Kulturminnesok:"Kulturminnesok",DiMu:"DigitaltMuseum",MUSIT:"Musit",Artsdatabanken:"Artsdatabanken",wikipedia:"wikipedia",riksantikvaren:"riksantikvaren"};a.datasets={"Digitalt fortalt":{fillcolor:"#F69730",circle:!1,thumbnail:!0},Kulturminnesok:{fillcolor:"#436978",circle:!1,thumbnail:!1},DigitaltMuseum:{fillcolor:"#436978",circle:!1,thumbnail:!1},Musit:{fillcolor:"#436978",circle:!1,thumbnail:!1},Artsdatabanken:{fillcolor:"#5B396B",thumbnail:!1,circle:!0},riksantikvaren:{fillcolor:"#436978",circle:!1,thumbnail:!0},verneomraader:{fillcolor:function(a){if(a){var c=b(a);if(c)return c.style.fillColor}return"#009300"},bordercolor:function(a){if(a){var c=b(a);if(c)return c.style.color}return"#009300"},thumbnail:!1,circle:!0},wikipedia:{fillcolor:"#D14020",thumbnail:!0}},a.groups={},a.getDatasetStyle=function(b){var c=a.datasets[t[b]];return c||(c=a.datasets[b]),c},a.setDatasetStyle=function(b,c){_.has(t,b)||(t[b]=b);var d=a.getDatasetStyle(b);d||(d=s),a.datasets[t[b]]=_.extend({},d,c)};var u={"#F69730":"orange","#38A9DC":"blue","#A23336":"darkred","#72B026":"green","#436978":"cadetblue","#5B396B":"darkpurple","#728224":"darkgreen","#D252B9":"purple","#D14020":"red"};a.getClusterIcon=function(a,b){var c,d=a.getAllChildMarkers(),f=_.uniq(_.map(d,function(a){return a.feature.properties.groupId})),i=h(d[0].feature);if(_.compact(f).length>1){var j=_.compact(f);j.length>1&&(c=_.map(j,_.compose(e,g)))}else c=e(i,d[0].feature);if(b&&(c=q),i.thumbnail){var k=n(d,c,b);if(k)return k}return o(d,c)},a.getIcon=function(a,b){var c=h(a),d=b?q:e(c,a),g=b?q:f(c,a);if(c.thumbnail){var j=m(a,g,b);if(j)return j}return c.circle?i(g,d,c.radius):k(d)},a.getMarker=function(b,c){var d=h(b);if(d.thumbnail){var g=m(b,f(d,b),!1);if(g)return l(b,c,g)}return d.circle?j(c,f(d,b),e(d,b)):l(b,c,a.getIcon(b,!1))},a.colorForFeature=function(a,b,d){var f=h(a);return f?b?e(f,a,d):c(e(f,a)):void 0},a.colorForDataset=function(b,d,f){var g,i;return b.grouped?(g=a.groups[KR.Util.stamp(b)],g||(i=b.datasets[0].extras.datasetId)):(i||(i=b.extras.datasetId),g=h({properties:{datasetId:i}})),g?d?e(g,null,f):c(e(g,null)):void 0},a.getPathStyle=function(a,b){b=b||!1;var c=h(a),d=e(c,a),g=f(c,a);return{weight:1,color:g,fillColor:d,clickable:b,opacity:.8,fillOpacity:.4}},a.getPathStyleForGroup=function(b,c){var d={properties:{groupId:b}};return a.getPathStyle(d,c)}}(KR.Style),L.Knreise=L.Knreise||{},L.Knreise.MarkerClusterGroup=L.MarkerClusterGroup.extend({options:{zoomToBoundsOnClick:!1,spiderfyOnMaxZoom:!1,polygonOptions:{fillColor:"#ddd",weight:2,color:"#999",fillOpacity:.6}},initialize:function(a){L.Util.setOptions(this,a),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._iconCreator.bind(this)),this._featureGroup=L.featureGroup(),this._featureGroup.on(L.FeatureGroup.EVENTS,this._propagateEvent,this),this._nonPointGroup=L.featureGroup(),this._nonPointGroup.on(L.FeatureGroup.EVENTS,this._propagateEvent,this),this._inZoomAnimation=0,this._needsClustering=[],this._needsRemoving=[],this._currentShownBounds=null,this._queue=[],this.on("clusterclick",this._clusterClicked,this)},onAdd:function(a){L.MarkerClusterGroup.prototype.onAdd.apply(this,arguments),a.on("layerSelected",this._deselectAll,this)},_deselectAll:function(){_.each(this._gridClusters,function(a){_.each(a._grid,function(a){_.each(a,function(a){_.each(a,function(a){a.selected&&(a.createIcon=_.bind(L.MarkerCluster.prototype.createIcon,a),a._updateIcon(),a.selected=!1)})})})}),this.eachLayer(function(a){a.selected&&(a.createIcon=_.bind(L.MarkerCluster.prototype.createIcon,a),a.setIcon(_.bind(L.Knreise.GeoJSON.prototype._createFeatureIcon,this)(a.feature)),a.selected=!1)},this)},_clusterClicked:function(a){this._map.fire("layerSelected");var b=a.layer,c=_.bind(this._iconCreator,this);b.createIcon=function(){return c(this,!0).createIcon()},b.selected=!0,b._updateIcon()},_iconCreator:function(a,b){return KR.Style.getClusterIcon(a,b)}}),L.Knreise.markerClusterGroup=function(a){return new L.Knreise.MarkerClusterGroup(a)},L.Knreise=L.Knreise||{},L.Knreise.GeoJSON=L.GeoJSON.extend({initialize:function(a,b){L.setOptions(this,b),this._layers={},this.options.pointToLayer=this._pointToLayer.bind(this),a&&this.addData(a),this.on("click",this._featureClicked,this),this.on("dblclick",this._featureDblClicked,this),this._selectedLayer=null},removedPaths:[],isCollapsed:function(a,b){var c=this.options.dataset.toPoint.minSize||20,d=a.getBounds(),e=this._map.project(d.getNorthEast(),b),f=this._map.project(d.getSouthWest(),b),g=e.x-f.x,h=f.y-e.y;return c>h||c>g},_deselectAll:function(){if(this._selectedLayer){var a=this._selectedLayer;if(a.setIcon&&(a.setIcon(this._createFeatureIcon(a.feature,!1)),a.setZIndexOffset(0)),a.setStyle){var b=a.feature;if(!b){var c=this.getParentLayer(a._leaflet_id);b=c.feature}if(a.setStyle(this._createFeatureIcon(b,!1)),a.getParent){var d=a.getParent();d.setStyle(this._createFeatureIcon(b,!1))}}this._selectedLayer=null}},deselectAllNew:function(){_.each(this.getLayers(),function(a){if(a.setIcon&&(a.setIcon(this._createFeatureIcon(a.feature,!1)),a.setZIndexOffset(0)),a.setStyle){var b=a.feature;if(!b){var c=this.getParentLayer(a._leaflet_id);b=c.feature}if(a.setStyle(this._createFeatureIcon(b,!1)),a.getParent){var d=a.getParent();d.setStyle(this._createFeatureIcon(b,!1))}}},this)},setLayerSelected:function(a){if(a.setIcon&&(a.setIcon(this._createFeatureIcon(a.feature,!0)),a.setZIndexOffset(1e3)),a.setStyle){var b=a.feature;if(!b){var c=this.getParentLayer(a._leaflet_id);b=c.feature}if(b&&(a.setStyle(this._createFeatureIcon(b,!0)),a.bringToFront()),a.getParent){var d=a.getParent();d.setStyle(this._createFeatureIcon(b,!0))}}this._selectedLayer=a},_featureClicked:function(a){if(!(this.options.dataset&&this.options.dataset.toPoint&&this.options.dataset.toPoint.stopPolyClick&&"Point"!==a.layer.toGeoJSON().geometry.type)){a.layer._map&&a.layer._map.fire("layerSelected");var b=a.layer;this.setLayerSelected(b)}},_featureDblClicked:function(a){this.options.dataset&&this.options.dataset.toPoint&&this.options.dataset.toPoint.stopPolyClick&&"Point"!==a.layer.toGeoJSON().geometry.type&&a.layer._map&&a.layer._map.zoomIn()},getParentLayer:function(a){var b=this._layers[a];if(b)return b;var c,d,e;for(c in this._layers)if(this._layers.hasOwnProperty(c)&&(d=this._layers[c],d.getLayer&&(e=d.getLayer(a))))return d},getZoomThreshold:function(a){var b=null,c=this._map.getZoom();if(this.isCollapsed(a,this._map.getZoom()))for(;!b;)c+=1,this.isCollapsed(a,c)||(b=c-1);else for(;!b;)c-=1,this.isCollapsed(a,c)&&(b=c);return b},_zoomend:function(){if(this.options.dataset.toPoint&&this.shouldLoad){var a,b,c=[];for(this.eachLayer(function(a){this._map.getZoom()<=a.zoomThreshold&&(this.removeLayer(a),this.options.dataset.toPoint.showAlways||this.addLayer(a.marker),c.push(a))},this),b=0;ba.zoomThreshold&&(this.options.dataset.toPoint.showAlways||this.removeLayer(a.marker),this.addLayer(a),this.removedPaths.splice(b,1),b-=1);this.removedPaths=this.removedPaths.concat(c)}},_getCenter:function(a){if("undefined"!=typeof turf){var b=turf.pointOnSurface(a.toGeoJSON());return L.latLng(b.geometry.coordinates.reverse())}return a.getBounds().getCenter()},_layeradd:function(a){var b=a.layer;if("Point"===b.feature.geometry.type||b.isMarker||(b.setStyle(KR.Style.getPathStyle(b.feature)),b.bringToBack()),this.options.dataset.toPoint){if(b.isMarker)return;if(b.getBounds&&!b.zoomThreshold&&!b.marker){var c=this.getZoomThreshold(b),d=this._pointToLayer(b.feature,this._getCenter(b));d.feature=b.feature,d.on("click",function(a){b.fire("click",{containerPoint:a.containerPoint,latlng:a.latlng,layerPoint:a.layerPoint,originalEvent:a.originalEvent,target:a.target,type:a.type,parent:!0})}),b.zoomThreshold=c,this.removedPaths.push(b),b.marker=d,b.marker.isMarker=!0,b.marker.getParent=function(){return b},this._map.getZoom()<=c&&(this.removeLayer(b),this.options.dataset.toPoint.showAlways||this.addLayer(b.marker)),this.options.dataset.toPoint.showAlways&&this.addLayer(b.marker)}}},setMap:function(a){a.on("layerSelected",this._deselectAll,this)},onAdd:function(a){L.GeoJSON.prototype.onAdd.apply(this,arguments),this.options.dataset&&this.options.dataset.toPoint&&(this._zoomend(),a.on("zoomend",this._zoomend,this),this.on("layeradd",this._layeradd,this)),this.setMap(a)},_createFeatureIcon:function(a,b){return KR.Style.getIcon(a,b)},_pointToLayer:function(a,b){return KR.Style.getMarker(a,b)}}),L.Knreise.geoJson=function(a,b){return new L.Knreise.GeoJSON(a,b)},L.Knreise=L.Knreise||{},L.Knreise.Control=L.Knreise.Control||{},L.Knreise.Control.Sidebar=L.Control.Sidebar.extend({initialize:function(a,b){b=b||{},b.autoPan=!1,L.setOptions(this,b);var c=L.DomUtil.get(a);L.DomEvent.on(c,"click",function(a){L.DomEvent.stopPropagation(a)}),c.parentNode.removeChild(c);var d=L.DomUtil.create("div","top-menu",c);this._contentContainer=L.DomUtil.create("div","sidebar-content",c),this.on("hide",this._removeContent,this);var e="leaflet-",f=this._container=L.DomUtil.create("div",e+"sidebar knreise-sidebar "+this.options.position);if(this.options.closeButton){var g=this._closeButton=L.DomUtil.create("a","close pull-right",d);g.innerHTML="×"}this._top=L.DomUtil.create("span","",d),L.DomUtil.addClass(c,e+"control"),f.appendChild(c),this.on("hide",function(){this._map&&(this._map.fire("layerSelected"),this._map.fire("layerDeselect"))},this),this.sidebar=new KR.SidebarContent(this._container,this._contentContainer,this._top,this.options,this._map)},addTo:function(a){return this.sidebar.setMap(a),L.Control.Sidebar.prototype.addTo.apply(this,arguments)},showFeature:function(a,b,c,d,e,f){if(this.show(),this.sidebar.showFeature(a,b,c,d,e,f),KR.UrlFunctions){var g=$("
"),h={id:a.id,url:KR.UrlFunctions.getFeatureLink(a),provider:a.properties.provider};a.properties.feedbackForm&&($(this._contentContainer).append(g),KR.ResponseForm(g,h)),a.id&&this.options.featureHash&&KR.UrlFunctions.setFeatureHash(a.id)}},showFeatures:function(a,b,c,d,e){this.show(),this.sidebar.showFeatures(a,b,c,d,e)},_removeContent:function(){$(this.getContainer()).html(""),KR.UrlFunctions&&KR.UrlFunctions.setFeatureHash()}}),L.Knreise.Control.sidebar=function(a,b){return new L.Knreise.Control.Sidebar(a,b)};var KR=this.KR||{};KR.UrlFunctions={},function(a){"use strict";a.setupLocationUrl=function(a){var b=function(){var b=a.getCenter(),c=KR.Util.getPositionHash(b.lat,b.lng,a.getZoom()),d=window.location.hash.split(":");if(d.length>1){var e=_.rest(d).join(":");c+=":"+e}window.location.hash=c};a.on("moveend",b),b()},a.getLocationUrl=function(){var a=window.location.hash;if(a&&""!==a&&1!==a.indexOf(":")){var b=a.replace("#","").split("/"),c=parseInt(b[0],10),d=parseFloat(b[1]),e=parseFloat(b[2]);return{lat:d,lon:e,zoom:c}}},a.getHashFeature=function(){var a=window.location.hash.split(":");return a.length>1?_.rest(a).join(":"):void 0},a.setFeatureHash=function(a){var b=window.location.hash.split(":")[0];a?window.location.hash=b+":"+encodeURIComponent(a):window.location.hash=b},a.getFeatureLink=function(a){var b=window.location.href.replace(window.location.hash,""),c=a.geometry.coordinates,d=KR.Util.getPositionHash(c[1],c[0],16),e=b+d;return a.id&&(e=e+":"+encodeURIComponent(a.id)),e}}(KR.UrlFunctions);var KR=this.KR||{};KR.MediaCarousel={},function(a){"use strict";function b(a,b){b=b||0;var c=function(){return a-1>b},d=function(){return b>0};return{prev:function(){return d()?--b:b},next:function(){return c()?++b:b},hasNext:c,hasPrev:d}}function c(a){return $('')}function d(a){return-1!==a.indexOf("mp4")?$(''):$('')}function e(a){return $('')}function f(a){if(_.has(h,a.type)){var b=h[a.type](a.url);return b.attr("data-type",a.type),b.attr("data-created",!0),b}}function g(a,b){return $('').attr("data-src",a).attr("data-type",b)}var h={image:c,video:d,sound:e};a.SetupMediaCarousel=function(a){function c(b){d=a.find(".media-list").children();var c=$(d[b]);if(d.addClass("hidden"),c.attr("data-created")||c.hasClass("audiojs"))c.removeClass("hidden");else{var g={type:c.attr("data-type"),url:c.attr("data-src")},h=f(g);c.replaceWith(h),h.is("audio")&&audiojs.create(h)}e.hasPrev()?a.find(".prev").addClass("active"):a.find(".prev").removeClass("active"),e.hasNext()?a.find(".next").addClass("active"):a.find(".next").removeClass("active")}var d=a.find(".media-list").children(),e=new b(d.length);a.find(".next").on("click",function(){e.hasNext()&&c(e.next())}),a.find(".prev").on("click",function(){e.hasPrev()&&c(e.prev())})},a.CreateMediaListMarkup=function(a){var b=$('
'),c=$('
');return c.append(_.map(a,function(a,b){var c=0===b;return c?f(a):g(a.url,a.type)})),b.append(c),a.length>1&&b.append($('
')),b[0].outerHTML}}(KR.MediaCarousel);var KR=this.KR||{};!function(){"use strict";function a(){function a(a){if(d&&d.userPosition){var b=turf.point([d.userPosition.lng,d.userPosition.lat]),c=KR.Util.distanceAndBearing(b,a),e=c.distance;return e=1e3>e?KR.Util.round(e,0)+" Meter":KR.Util.round(e/1e3,2)+" Kilometer",{dist:e,rot:c.bearing-45}}}function b(){if(e&&d&&d.userPosition&&f){g&&g.remove();var b=e.find("h3").eq(0),c=a(f);g=$(h({distanceBearing:c})),b.length?b.after(g):e.prepend(g)}}function c(a,c){e=c,f=a,b()}var d,e,f,g,h=_.template($("#user_position_template").html());return{setMap:function(a){d=a,d.on("locationChange",b)},selectFeature:c}}KR.SidebarContent=function(b,c,d,e){function f(a){c.html(a)}function g(a){a&&c.swipe({swipe:function(){},allowPageScroll:"vertical"}).off("swipeLeft").on("swipeLeft",function(){a.next&&a.next()}).off("swipeRight").on("swipeRight",function(){a.prev&&a.prev()})}function h(a,b,c,d,f,g){var i;b>0&&(i=function(e){e&&e.preventDefault(),b-=1,a=f[b];var i=h(a,b,c,d,f,g);j(a,c,d,i,b,f.length)});var l;return b"),p+='',f(p),void i(a,function(b){b.properties=_.extend(a.properties,b.properties),j(b,h,null,k,n,o)})}h=h||a.template||KR.Util.templateForDataset(a.properties.dataset)||l;var q=a.properties.images;_.isArray(q)&&(q=q[0]),a.properties.images||(a.properties.images=null),a.properties.allProps&&a.properties.allProps.europeana_rights?a.properties.license=a.properties.allProps.europeana_rights[0]:a.properties.license=null;var r=a.properties.color||KR.Style.colorForFeature(a,!0,!0),p=''+a.properties.provider+"";if(p+=h(_.extend({image:null},a.properties)),e.footerTemplate&&a.properties.link&&(p+=e.footerTemplate(a.properties)),p=$(["
",p,"
"].join(" ")),KR.Util.isInIframe()&&p.find("a").attr("target","_blank"),m.selectFeature(a,p),f(p),g(k),b.find(".prev-next-arrows").remove(),d.html(""),k){var s=$('');d.append(s),s.click(k.close);var t=n+1;d.append($('
'+t+" av "+o+"
"));var u=$('');b.append(u),k.prev&&u.click(k.prev).addClass("active");var v=$('');b.append(v),k.next&&v.click(k.next).addClass("active")}var w=c.find(".media-container");w.length&&KR.MediaCarousel.SetupMediaCarousel(w),"undefined"!=typeof audiojs&&audiojs.createAll(),c.scrollTop(0)}function k(a,b,f,g,j){g=void 0===g?e.noListThreshold:g;var k=a.length<=g;if(k&&j!==!0){var l=a[0];c.html("");var m=h(l,0,b,f,a);return void this.showFeature(l,b,f,m,0,a.length)}var n=$(''+a.length+"");d.html(n);var o=_.chain(a).groupBy(function(a){return a.properties.provider}).map(function(c,d){var e=$("
"),g=$('
'),h=_.map(c,function(c){var d=_.findIndex(a,function(a){return a===c});return i(c,d,b,f,a)},this);return g.append(h),e.append('
'+d+"
"),e.append(g),e}).value();c.html(o),c.scrollTop(0)}var l=KR.Util.getDatasetTemplate("popup"),m=new a;return c=$(c),b=$(b),d=$(d),{showFeature:j,showFeatures:k,setMap:function(a){m.setMap(a)}}}}(),function(){"use strict";L.Knreise=L.Knreise||{},L.Knreise.Control=L.Knreise.Control||{};var a=function(a,b){function c(c){var d=document.createElement("i");return d.className="layericon fa",a.visible?d.className+=" fa-check-square-o":d.className+=" fa-square-o",c&&(d.className+=" "+c),b.isLoading&&(d.className="layericon fa fa-spinner fa-pulse"),b.enabled?d.style.color=KR.Style.colorForDataset(a,!0,!0):d.style.color="#ddd",d}function d(){var a=c();j.replaceChild(a,k),k=a}function e(){a.visible=!a.visible,d(),a.visible?b.fire("show"):b.fire("hide")}function f(a){m?m.setAttribute("title",m.getAttribute("title")+", "+KR.parseError(a)):(m=L.DomUtil.create("i","error-icon fa fa-exclamation-triangle"),m.setAttribute("title",KR.parseError(a)),j.insertBefore(m,j.childNodes[0]))}function g(){j=document.createElement("label"),_.isUndefined(a.visible)&&(a.visible=!0);var d=document.createElement("span");d.innerHTML=" "+a.name,k=c(),j.appendChild(k),j.appendChild(d),b.error&&f(b.error),b.enabled||(j.className="disabled"),L.DomEvent.on(j,"click",function(){var a=b.enabled&&!b.isLoading;a&&e()})}function h(){b.enabled!==l&&(l=b.enabled,d(),l?j.className=j.className.replace("disabled",""):j.className+="disabled")}function i(){return j}var j,k,l=b.enabled,m=null;return g(),b.on("changeEnabled",h),b.on("dataloadstart",function(){m&&(j.removeChild(m),m=null),d()}),b.on("dataloadend",d),b.on("error",f),{getLabel:i,hasError:function(){return!!b.error}}};L.Control.Datasets=L.Control.extend({initialize:function(a,b){L.setOptions(this,b),this._labels=[],this._handlingClick=!1,this.expanded=!1,this.numLoading=0;var c;for(c in a)a.hasOwnProperty(c)&&this._addLayer(a[c])},_addLayer:function(a){var b,c=a.options.dataset;if(c.datasets)if(c.grouped)this._addDataset(c,a);else for(b=0;b0?this._btnIcon=L.DomUtil.create("i","fa fa-spinner fa-pulse",b):this._btnIcon=L.DomUtil.create("i","fa fa-bars",b),this._container.appendChild(this._closeDiv),this._listContainer=L.DomUtil.create("div",a+" hidden"),this._listContainer.appendChild(this._form),this._container.appendChild(this._listContainer)},_toggle:function(){this.expanded?this._collapse():this._expand()},_expand:function(){L.DomUtil.addClass(this._listContainer,"leaflet-control-layers-expanded"),this.expanded=!0,this._listContainer.className=this._listContainer.className.replace(" hidden","")},_collapse:function(){this._listContainer.className=this._listContainer.className.replace(" leaflet-control-layers-expanded",""),L.DomUtil.addClass(this._listContainer,"hidden"),this.expanded=!1}}),L.control.datasets=function(a,b){return new L.Control.Datasets(a,b)}}(),L.Knreise=L.Knreise||{},L.Knreise.Icon=L.KNreiseMarkers.Icon.extend({options:{icon:null}}),L.Knreise.icon=function(a){return new L.Knreise.Icon(a)};var KR=this.KR||{};KR.DatasetLoader=function(a,b,c,d,e,f){ -"use strict";function g(a){var b=KR.Util.stamp(a);return function(c){return c&&c.features.length?(_.each(c.features,function(c){c.properties.datasetID=b,_.has(a,"circle")&&(c.properties.circle=a.circle),_.has(a,"provider")&&(c.properties.provider=a.provider),_.has(a,"extras")&&(c.properties=_.extend(c.properties,a.extras)),c.properties.feedbackForm=a.feedbackForm,_.has(a,"mappings")&&_.each(a.mappings,function(a,b){c.properties[b]=c.properties[a]}),c.template=KR.Util.getTemplateForFeature(c,a)}),c):c}}function h(a){var b=_.reduce(_.without(_.keys(a),"datasets"),function(b,c){return"style"!==c&&(b[c]=a[c]),b},{});if(a.style){b.extras=b.extras||{};var c=KR.Util.stamp(a);b.extras.groupId=c,KR.Style.groups[c]=a.style}return a.datasets=_.map(a.datasets,function(a){return _.extend({},b,a)}),a}function i(a,b){var c={dataset:b,onEachFeature:function(a,c){A&&A(a,c,b)}};return b.style&&(c.style=b.style),L.Knreise.geoJson(a,c)}function j(a,b){a.clearLayers();var c=_.reduce(b,function(a,b){return a.concat(b.toGeoJSON().features)},[]);a.addData(KR.Util.createFeatureCollection(c)),a.fire("dataAdded")}function k(a,c){a.clearLayers();var d=_.reduce(c,function(a,c){return c.setMap(b),a.concat(c.getLayers())},[]);a.addLayers(d)}function l(a,b){a.on("hide",function(){b(!0)}),a.on("show",function(){b(!0)})}function m(a,b){var c;e?c=i(null,a):a.cluster?(c=new L.Knreise.MarkerClusterGroup({dataset:a,maxClusterRadius:f}).addTo(b),z&&z(c,a)):c=i(null,a).addTo(b);var d=!0;return a.minFeatures&&(d=!1),c.enabled=d,c}function n(a,b){a.enabled!==b&&(a.enabled=b,a.fire("changeEnabled"))}function o(a){if(a.datasets&&!a.grouped){var b=_.filter(a.datasets,function(a){return a.visible}).length;return b>0}return a.visible}function p(a){return a.minZoom&&b.getZoom()b;b++)a[b]={identifier:""+b,topLeftCorner:new L.LatLng(20037508.3428,-20037508.3428)};return a}}),L.tileLayer.wmts=function(a,b){return new L.TileLayer.WMTS(a,b)},function(a){"use strict";function b(a){var b,c=new Array(30);for(b=0;22>b;b++)c[b]={identifier:a+":"+b,topLeftCorner:new L.LatLng(20037508,-20037508.34)};return c}a.SKTokenUrl="http://localhost:8001/html/baat/?type=token",a.getNibLayer=function(c,d){a.Util.sendRequest(KR.SKTokenUrl,null,function(a){var e;if(d)e=L.tileLayer.wms("http://gatekeeper2.geonorge.no/BaatGatekeeper/gk/gk.nibcache",{layers:"NiB",format:"image/jpeg",transparent:!1,attribution:"Kartverket"});else{var f="http://gatekeeper1.geonorge.no/BaatGatekeeper/gk/gk.nibcache_wmts",g="EPSG:900913";e=new L.TileLayer.WMTS(f,{layer:"NiB",style:"normal",tilematrixSet:g,matrixIds:b(g),format:"image/jpeg",attribution:"Kartverket"})}e.setParams({GKT:a}),c(e)})}}(KR);var KR=this.KR||{};KR.Config=KR.Config||{},function(a){"use strict";a.getKulturminneFunctions=function(a){var b,c,d,e=[],f=function(a){return L.geoJson(null,{onEachFeature:function(b,c){a.extras&&a.extras.groupId?c.setStyle(KR.Style.getPathStyleForGroup(a.extras.groupId)):(b.properties.datasetId=a.id,c.setStyle(KR.Style.getPathStyle(b,!0)))}}).addTo(c)},g=function(){map.removeLayer(d)},h=function(){map.addLayer(d)},i=function(a,b,c){var d;a.on("zoomstart",function(b){d=a.getZoom()}),a.on("zoomend",function(b){var c=a.getZoom();console.log("end:",d,c)})},j=function(a,e,j){b=j,c=a,j.on("hide",g),j.on("show",h),d=f(e),i(c,13)},k=function(a){d.addData(a);var b=_.chain(a.features).map(function(a){return a.properties.lok}).uniq().value();e=e.concat(b),console.log("new ids",b)},l=function(b,c,d){if(!d)return void console.log("no features to show for");var f=_.chain(d).map(function(a){return a.properties.id}).filter(function(a){return-1===e.indexOf(a)}).value();if(!f.length)return void console.log("no new features to load");var g={api:"kulturminnedataSparql",type:"lokalitetpoly",lokalitet:f};a.getData(g,k)};return{loadKulturminnePoly:l,initKulturminnePoly:j}}}(KR.Config);var KR=this.KR||{};KR.Config=KR.Config||{},function(a){"use strict";a.getDatasetList=function(b,c,d){var e=a.getKulturminneFunctions(b);c&&3===c.length&&(c="0"+c);var f={difo:{name:"Digitalt fortalt",dataset:{dataset:"difo",api:"norvegiana"},cluster:!0,template:KR.Util.getDatasetTemplate("digitalt_fortalt"),noListThreshold:1/0,description:"Kulturrådets tjeneste for personlige fortellinger fra kulturinstitusjoner og privatpersoner.",allowTopic:!0,feedbackForm:!0,isStatic:!1},verneomr:{id:"verneomraader",dataset:{api:"cartodb",table:"naturvernomrader_utm33_2",columns:["iid","omradenavn","vernef_id","verneform"]},provider:"Naturbase",name:"Verneområder",template:KR.Util.getDatasetTemplate("verneomraader"),getFeatureData:function(a,c){b.getItem({api:"norvegiana",id:"kulturnett_Naturbase_"+a.properties.iid},c)},toPoint:{showAlways:!0,stopPolyClick:!0,minSize:20},minZoom:10,cluster:!1,description:"Nasjonalparker og andre naturvernområder - ca. 2700 i hele landet."},artobs:{name:"Artsobservasjoner",hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"Artsdatabanken"},cluster:!1,description:"Artsobservasjoner fra Artsdatabanken",template:KR.Util.getDatasetTemplate("popup")},folketelling:{name:"Folketelling 1910",provider:"Folketelling 1910",dataset:{api:"folketelling",dataset:"property"},isStatic:!1,minZoom:14,template:KR.Util.getDatasetTemplate("folketelling"),getFeatureData:function(a,c){b.getData({api:"folketelling",type:"propertyData",propertyId:a.properties.efid},function(b){a.properties=b.properties,a.properties.provider="Folketelling 1910",c(a)})},mappings:{title:"gaardsnavn_gateadr"},noListThreshold:0,description:"Personer og eiendommer fra folketellingen 1910"},ark_hist:{grouped:!0,name:"Arkeologi og historie",datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}}],description:"Data fra Universitetsmuseene, Digitalt museum og Riksantikvaren"},jernbane:{id:"jernbane",dataset:{api:"jernbanemuseet"},provider:"Jernbanemuseet",name:"Jernbanemuseet",hideFromGenerator:!0,template:KR.Util.getDatasetTemplate("jernbanemuseet"),getFeatureData:function(a,c){b.getItem({api:"jernbanemuseet",id:a.properties.id},c)},isStatic:!0,bbox:!1,description:"Jernbanemuseet"},arkeologi:{grouped:!0,name:"Arkeologi",style:{fillcolor:"#436978",circle:!1,thumbnail:!0},datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER regex(?loccatlabel, "^Arkeologisk", "i") .',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}}],description:"Arkeologidata fra Universitetsmuseene og Riksantikvaren"},historie:{grouped:!0,name:"Historie",style:{fillcolor:"#D252B9",circle:!1,thumbnail:!0},datasets:[{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER (!regex(?loccatlabel, "^Arkeologisk", "i"))',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"-dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Industrimuseum"},isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Foto-SF"},isStatic:!1,bbox:!1,template:KR.Util.getDatasetTemplate("foto_sf")},{dataset:{api:"norvegiana",dataset:"Kystreise"},isStatic:!0,bbox:!1}],description:"Historie og kulturminner fra Riksantikvaren og Digitalt museum "},kunst:{grouped:!0,name:"Kunst",style:{fillcolor:"#72B026",circle:!1,thumbnail:!0},datasets:[{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1}],description:"Kunstdata fra Digitalt museum "},wikipedia:{name:"Wikipedia",provider:"Wikipedia",dataset:{api:"wikipedia"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra bokmålswikipedia"},wikipediaNN:{name:"Wikipedia Nynorsk",provider:"Wikipedia Nynorsk",dataset:{api:"wikipediaNN"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra nynorskwikipedia"},lokalwiki:{id:"lokalwiki",name:"Lokalhistoriewiki",hideFromGenerator:!1,provider:"Lokalhistoriewiki",dataset:{api:"lokalhistoriewiki"},style:{thumbnail:!0},minZoom:13,bbox:!0,isStatic:!1,description:"Stedfestede artikler fra lokalhistoriewiki.no"},riksantikvaren:{id:"riksantikvaren",name:"Kulturminnesøk",hideFromGenerator:!1,provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:10,callback:e.loadKulturminnePoly},description:"Data fra Riksantikvarens kulturminnesøk"},brukerminner:{name:"Kulturminnesøk - brukerregistreringer",hideFromGenerator:!1,provider:"riksantikvaren",dataset:{api:"kulturminnedata",layer:2,getExtraData:!0,extraDataLayer:6,matchId:"KulturminnesokID"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Brukerregistrerte data fra Riksantikvarens kulturminnesøk",template:KR.Util.getDatasetTemplate("brukerminne")},groruddalen:{name:"Byantikvaren Oslo - Groruddalen",hideFromGenerator:!0,provider:"Byantikvaren i Oslo",dataset:{api:"cartodb",table:"byantikvaren_oslo_groruddalen"},bbox:!1,isStatic:!1,style:{thumbnail:!0},template:KR.Util.getDatasetTemplate("byantikvaren_oslo"),description:"Byantikvarens Groruddalsatlas"},norgerundt:{name:"Norge Rundt",hideFromGenerator:!0,provider:"NRK",dataset:{api:"cartodb",table:"nrk_norge_rundt"},bbox:!1,isStatic:!1,style:{thumbnail:!0},description:"Stedfestede innslag fra Norge Rundt"},dimu:{name:"Digitalt Museum",hideFromGenerator:!1,provider:"dimu",dataset:{dataset:"DiMu",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Digitalt Museum",allowTopic:!0,feedbackForm:!0},musit:{name:"Universitetsmuseene",hideFromGenerator:!1,provider:"Universitetsmuseene",dataset:{dataset:"MUSIT",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Universitetsmuseene",allowTopic:!0,feedbackForm:!0},industrimuseum:{name:"Industrimuseum",hideFromGenerator:!1,provider:"Industrimuseum",dataset:{dataset:"Industrimuseum",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Industrimuseum",allowTopic:!0,feedbackForm:!0},kystreise:{name:"Kystreise",hideFromGenerator:!1,provider:"Kystreise",dataset:{dataset:"Kystreise",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Kystreise",allowTopic:!0,feedbackForm:!0},dimufoto:{hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"DiMu",query:"europeana_type_facet:IMAGE"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,style:{thumbnail:!0},noListThreshold:1/0},kulturminnesok_flickr:{name:"Kulturminnesøk",dataset_name_override:"Kulturminnesøk",provider:"Kulturminnesøk Flickr",hideFromGenerator:!0,dataset:{api:"flickr",group_id:"1426230@N24"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!0,style:{thumbnail:!0},description:"Bilder fra Kulturminnesøks Flickr-gruppe"},riksarkivet:{name:"Riksarkivet",dataset_name_override:"Riksarkivet",provider:"riksarkivet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_archives_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Riksarkivets Flickr-konto"},nasjonalbiblioteket:{name:"Nasjonalbiblioteket",dataset_name_override:"Nasjonalbiblioteket",provider:"nasjonalbiblioteket",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_library_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalbibliotekets Flickr-konto"},oslobyarkiv:{name:"Oslo Byarkiv",dataset_name_override:"Oslo Byarkiv",provider:"oslobyarkiv",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"byarkiv"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Oslo byarkiv sin Flickr-konto"},nasjonalmuseet:{name:"Nasjonalmuseet",dataset_name_override:"Nasjonalmuseet",provider:"nasjonalmuseet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nasjonalmuseet"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalmuseet sin Flickr-konto"},nve:{name:"NVE",dataset_name_override:"NVE",provider:"nve",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nve",accuracy:"6"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra NVE Flickr-konto"},vestfoldmuseene:{name:"Vestfoldmuseene",dataset_name_override:"Vestfoldmuseene",provider:"Vestfoldmuseene",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"vestfoldmuseene",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Vestfoldmuseene sin Flickr-konto"},perspektivet:{name:"Perspektivet Museum",dataset_name_override:"Perspektivet Museum",provider:"Perspektivet Museum",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"perspektivetmuseum",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Perspektivet Museum sin Flickr-konto"}};if(!c&&!d){var g={bbox:!0,minZoom:12,isStatic:!1,bboxFunc:KR.Util.sparqlBbox};_.extend(f.riksantikvaren,g),_.extend(f.ark_hist.datasets[2],g),_.extend(f.arkeologi.datasets[1],g),_.extend(f.historie.datasets[0],g)}return f},a.getDatasets=function(b,c,d,e){var f=a.getDatasetList(c,d,e);return _.chain(b).map(function(a){var b;if(a.indexOf(":")>-1){var c=a.split(":");a=c[0],b=c[1]}if(_.has(f,a)){var d=f[a];return b&&"norvegiana"===d.dataset.api&&(d.dataset.query="dc_subject_text:"+b),d}}).compact().value()}}(KR.Config);var KR=this.KR||{};KR.SplashScreen=function(a,b,c,d,e,f){"use strict";function g(){return window.location.href.replace(window.location.hash,"")}function h(){var a=g(),b="remember_"+a+"=",c=document.cookie.split("; "),d=_.find(c,function(a){return 0===a.indexOf(b)});return d?"true"===d.substring(b.length,d.length):void 0}function i(a){document.cookie="remember_"+g()+"="+a}function j(){this._gray&&this._container.removeChild(this._gray),L.Control.Sidebar.prototype.hide.apply(this,arguments)}function k(){this._gray=L.DomUtil.create("div","gray",this._container),L.Control.Sidebar.prototype.show.apply(this,arguments)}function l(){var g=L.DomUtil.create("div","",document.body);g.id="splashscreen";var h=L.control.sidebar("splashscreen",{position:"center",autoPan:!1});h.hide=_.bind(j,h),h.show=_.bind(k,h),a.addControl(h);var i=_.template($("#splashscreen_template").html()),l=$("
"+i({title:b,image:d,description:c,creator:e,spinner:!!f})+"
");return KR.Util.isInIframe()&&l.find("a").attr("target","_blank"),h.setContent(l.html()),h}function m(a){function b(){i(c.prop("checked"))}var c=$(a.getContainer()).find("#persist_splash_cb");c.prop("checked",h()),c.on("change",b),b()}function n(b){return L.easyButton(a,b,{position:"topright",icon:"fa-info-circle",title:"Om"})}var o=l();n(function(){o.isVisible()?o.hide():o.show()});var p=h();return p||(_.isUndefined(p)&&i(!0),o.show()),m(o),{finishedLoading:function(){var a=$(o.getContainer()).find("#splash_spinner");a&&a.remove()}}};var KR=this.KR||{};KR.ResponseForm=function(a,b){function c(a,b){var c=_.reduce(a,function(a,b,c){return a[g[c]]=b,a},{});$.ajax({url:h,data:c,type:"POST",dataType:"xml",success:b,error:b})}function d(b){a.find("form").addClass("hidden"),a.find("#form-success").removeClass("hidden").find(".media-body").text("Din melding er sendt til "+b+". De vil ta kontakt hvis de har behov for ytterligere informasjon")}function e(e){e.preventDefault();var f=a.find("#form_email").val(),g=a.find("#form_message").val();if(""===f||""===g)return!1;var h=_.extend({},b,{email:f,message:g});return c(h,function(){d(h.provider)}),!1}function f(){a.find("#form_email").val(""),a.find("#form_message").val(""),a.find("#form-success").addClass("hidden"),a.find("form").addClass("hidden"),a.find(".show-more").removeClass("hidden")}var g={message:"entry.126368279",email:"entry.748218122",id:"entry.2043404140",url:"entry.243673559",provider:"entry.826324496"},h="https://docs.google.com/forms/d/1ah66lattC8it7OTIM6de20NSNkBeiQ0vabpsHSaPU7s/formResponse",i=$("#response_form_template").html();a.append(i),a.find("form").on("submit",e),a.find(".show-more").click(function(){a.find(".show-more").addClass("hidden"),a.find("form").removeClass("hidden")}),a.find(".close ").click(f)};var KR=this.KR||{};!function(a){"use strict";function b(a){return function(b){if(!b||!b.features.length)return b;if(-1===b.features[0].geometry.type.indexOf("Polygon"))return turf.within(b,a);var c=_.filter(b.features,function(b){var c=turf.extent(b),d=turf.bboxPolygon(c);return!!turf.intersect(d,a.features[0])});return KR.Util.createFeatureCollection(c)}}function c(a,b,c,d,e){return c&&(b=KR.Config.getDatasets(b,a,d,e)),b}function d(a,b){var c={stroke:!1,fillColor:"#ddd",fillOpacity:.8},d=_.reduce(b.features,function(a,b){return turf.erase(a,b)},KR.Util.WORLD);L.geoJson(d,c).addTo(a)}function e(a,c,e,f,g,h,i,j){if(a.geomFilter){var k={api:"cartodb"};k[h]=g,c.getData(k,function(c){a.showGeom&&d(a.map,c);var f=L.geoJson(c),g=b(c);i(f.getBounds(),e,g,null,j)})}else f(g,function(a){var b=L.latLngBounds.fromBBoxString(a);i(b,e,null,null,j)})}function f(a,b,d,f,g,h){d=c(b,d,f,a.komm),_.isString(a.komm)&&(a.komm=a.komm.split(",")),e(a,b,d,b.getMunicipalityBounds,a.komm,"municipality",g,h)}function g(a,b,d,f,g,h){d=c(b,d,f,null,a.fylke),_.isString(a.fylke)&&(a.fylke=a.fylke.split(",")),e(a,b,d,b.getCountyBounds,a.fylke,"county",g,h)}function h(a,b,d,e,f,g){d=c(b,d,e);var h=L.latLngBounds.fromBBoxString(a.bbox);f(h,d,null,null,g)}function i(a){var b=[];return _.each(a.features,function(a){"GeometryCollection"===a.geometry.type?_.each(a.geometry.geometries,function(c){b.push(KR.Util.createGeoJSONFeatureFromGeom(c,a.properties))}):b.push(a)}),KR.Util.createFeatureCollection(b)}function j(a){var b=_.map(a.features,function(a){return turf.simplify(a,.01,!1)});return KR.Util.createFeatureCollection(b)}function k(a,d,e,f,g,h,k){var l={};e.linecolor&&(l.color=e.linecolor);var m=L.geoJson(a,l),n=m.getBounds();f=c(d,f,g);var o;if(a&&e.buffer){a=i(a),a.features.length>5&&(a=j(a));var p=turf.buffer(a,e.buffer,"kilometers");o=b(p)}h(n,f,o,m,k)}function l(a,b,c,d,e,f){KR.Util.getLine(b,a.line,function(g){k(g,b,a,c,d,e,f)})}function m(a){var b=KR.UrlFunctions.getHashFeature();if(b){var c=function(a){return decodeURIComponent(a.feature.id)===decodeURIComponent(b)||a.feature.id===decodeURIComponent(b)},d=_.find(_.flatten(a),function(a){return _.find(a.getLayers(),c)});if(d){var e=_.find(d.getLayers(),c);e.fire("click"),d.setLayerSelected(e)}}}function n(a,b){return _.map(a,function(a){return a.isStatic&&(a.fixedBbox=b),a.datasets&&(a.datasets=_.map(a.datasets,function(a){return a.isStatic&&(a.fixedBbox=b),a})),a})}function o(a){return _.map(a,function(a){return a.isStatic=!0,a.datasets&&(a.datasets=_.map(a.datasets,function(a){return a.isStatic=!0,a})),a})}var p={geomFilter:!1,showGeom:!1,loactionHash:!0,featureHash:!0};a.setupMap=function(a,b,c,d){function e(a,b,d,e,f){c.allstatic&&(b=o(b)),b=n(b,a.toBBoxString());var g=L.Knreise.LocateButton(null,null,{bounds:a});g.addTo(i);var h=function(f){f?(i.setView([f.lat,f.lon],f.zoom),a=i.getBounds()):i.fitBounds(a),c.loactionHash&&KR.UrlFunctions.setupLocationUrl(i);var g,h=function(a){m(a),q&&q.finishedLoading()};c.geomFilter&&a&&(g=a.toBBoxString());var j=k.loadDatasets(b,a.toBBoxString(),d,h,g);e&&e.addTo(i),b.length>1&&L.control.datasets(j).addTo(i)};c.initUserPos?(i.addOneTimeEventListener("locationChange",function(){var a={lat:i.userPosition.lat,lon:i.userPosition.lng,zoom:16};h(a)}),i.addOneTimeEventListener("locationError",function(){h(f)}),g.getLocation()):h(f)}c=c||{},c=_.extend({},p,c);var i=KR.Util.createMap("map",c),j=KR.Util.setupSidebar(i,{featureHash:c.featureHash}),k=new KR.DatasetLoader(a,i,j,null,c.cluster,c.clusterRadius);i.sidebar=j;var q;c.title&&(q=KR.SplashScreen(i,c.title,c.description,c.image,null,!1));var r,s=KR.UrlFunctions.getLocationUrl(i);return c.initUserPos||(r=s),c.map=i,c.komm?f(c,a,b,d,e,r):c.fylke?g(c,a,b,d,e,r):c.line?l(c,a,b,d,e,r):c.bbox?h(c,a,b,d,e,r):alert("Missing parameters!"),i},a.setupMapFromUrl=function(b,c,d){a.setupMap(b,c,d,!0)}}(KR);var KR=this.KR||{};KR.setupCollectionMap=function(a,b,c){"use strict";function d(a){var b=KR.Util.createMap("map",{layer:c});KR.SplashScreen(b,a.title,a.description,a.image,a.creator),$("title").append(a.title);var d=L.latLngBounds.fromBBoxArray(turf.extent(a.geo_json));_.each(a.geo_json.features,function(a){a.properties.datasetId=a.properties.provider,_.has(e,a.properties.provider)&&(a.template=e[a.properties.provider])});var f=KR.Util.setupSidebar(b),g=KR.Util.clusterClick(f),h=KR.Util.featureClick(f);L.Knreise.LocateButton(null,null,{bounds:d}).addTo(b),b.fitBounds(d);var i=L.Knreise.geoJson(a.geo_json,{onEachFeature:function(a,b){h(a,b)}}),j=(new L.Knreise.MarkerClusterGroup).addTo(b);j.addLayers(i.getLayers()),g(j)}var e={"Digitalt fortalt":KR.Util.getDatasetTemplate("digitalt_fortalt"),DigitaltMuseum:KR.Util.getDatasetTemplate("digitalt_museum"),Musit:KR.Util.getDatasetTemplate("musit"),Artsdatabanken:KR.Util.getDatasetTemplate("popup")};a.getCollection(b,d)}; \ No newline at end of file +"use strict";function g(a){var b=KR.Util.stamp(a);return function(c){return c&&c.features.length?(_.each(c.features,function(c){c.properties.datasetID=b,_.has(a,"circle")&&(c.properties.circle=a.circle),_.has(a,"provider")&&(c.properties.provider=a.provider),_.has(a,"extras")&&(c.properties=_.extend(c.properties,a.extras)),c.properties.feedbackForm=a.feedbackForm,_.has(a,"mappings")&&_.each(a.mappings,function(a,b){c.properties[b]=c.properties[a]}),c.template=KR.Util.getTemplateForFeature(c,a)}),c):c}}function h(a){var b=_.reduce(_.without(_.keys(a),"datasets"),function(b,c){return"style"!==c&&(b[c]=a[c]),b},{});if(a.style){b.extras=b.extras||{};var c=KR.Util.stamp(a);b.extras.groupId=c,KR.Style.groups[c]=a.style}return a.datasets=_.map(a.datasets,function(a){return _.extend({},b,a)}),a}function i(a,b){var c={dataset:b,onEachFeature:function(a,c){A&&A(a,c,b)}};return b.style&&(c.style=b.style),L.Knreise.geoJson(a,c)}function j(a,b){a.clearLayers();var c=_.reduce(b,function(a,b){return a.concat(b.toGeoJSON().features)},[]);a.addData(KR.Util.createFeatureCollection(c)),a.fire("dataAdded")}function k(a,c){a.clearLayers();var d=_.reduce(c,function(a,c){return c.setMap(b),a.concat(c.getLayers())},[]);a.addLayers(d)}function l(a,b){a.on("hide",function(){b(!0)}),a.on("show",function(){b(!0)})}function m(a,b){var c;e?c=i(null,a):a.cluster?(c=new L.Knreise.MarkerClusterGroup({dataset:a,maxClusterRadius:f}).addTo(b),z&&z(c,a)):c=i(null,a).addTo(b);var d=!0;return a.minFeatures&&(d=!1),c.enabled=d,c}function n(a,b){a.enabled!==b&&(a.enabled=b,a.fire("changeEnabled"))}function o(a){if(a.datasets&&!a.grouped){var b=_.filter(a.datasets,function(a){return a.visible}).length;return b>0}return a.visible}function p(a){return a.minZoom&&b.getZoom()b;b++)a[b]={identifier:""+b,topLeftCorner:new L.LatLng(20037508.3428,-20037508.3428)};return a}}),L.tileLayer.wmts=function(a,b){return new L.TileLayer.WMTS(a,b)},function(a){"use strict";function b(a){var b,c=new Array(30);for(b=0;22>b;b++)c[b]={identifier:a+":"+b,topLeftCorner:new L.LatLng(20037508,-20037508.34)};return c}a.SKTokenUrl="http://localhost:8001/html/baat/?type=token",a.getNibLayer=function(c,d){a.Util.sendRequest(KR.SKTokenUrl,null,function(a){var e;if(d)e=L.tileLayer.wms("http://gatekeeper2.geonorge.no/BaatGatekeeper/gk/gk.nibcache",{layers:"NiB",format:"image/jpeg",transparent:!1,attribution:"Kartverket"});else{var f="http://gatekeeper1.geonorge.no/BaatGatekeeper/gk/gk.nibcache_wmts",g="EPSG:900913";e=new L.TileLayer.WMTS(f,{layer:"NiB",style:"normal",tilematrixSet:g,matrixIds:b(g),format:"image/jpeg",attribution:"Kartverket"})}e.setParams({GKT:a}),c(e)})}}(KR);var KR=this.KR||{};KR.Config=KR.Config||{},function(a){"use strict";a.getKulturminneFunctions=function(a){var b,c,d,e,f,g=[],h=!1,i=!0,j=function(){map.removeLayer(d)},k=function(){map.addLayer(d)},l=function(a){var b="down"===a;b?(c.addLayer(d),f&&c.addLayer(f)):(c.removeLayer(d),f&&c.removeLayer(f))},m=function(a,b,c){var d;a.on("zoomstart",function(b){d=a.getZoom()}),a.on("zoomend",function(e){var f=a.getZoom();d>b&&b>=f&&c("up"),b>=d&&f>b&&c("down")})},n=function(a){return _.find(b.getLayers(),function(b){return b.feature.properties.id===a})},o=function(a){return _.find(d.getLayers(),function(b){return b.feature.properties.lok===a})},p=function(a,b){var c=n(a.properties.lok);c&&c.fire("click")},q=function(a){return L.geoJson(null,{onEachFeature:function(b,c){a.extras&&a.extras.groupId?c.setStyle(KR.Style.getPathStyleForGroup(a.extras.groupId)):(b.properties.datasetId=a.id,c.setStyle(KR.Style.getPathStyle(b,!0))),c.on("click",function(){p(b,c)})}}).addTo(c)},r=function(){},s=function(){_.each(d.getLayers(),function(a){a.setStyle(KR.Style.getPathStyle(a.feature,!0))})},t=function(a){s();var b=a.layer.feature.properties.id,c=o(b);c&&(c.setStyle({weight:1,color:"#436978",fillColor:"#72B026",clickable:!0,opacity:.8,fillOpacity:.4}),e&&(console.log("loadEnkeltminner"),e(a.layer.feature)))},u=function(a,b){c.sidebar&&c.sidebar.showFeature(a,b.enkeltminner.template||KR.Util.getDatasetTemplate("ra_enkeltminne"))},v=function(b){_.has(b,"enkeltminner")||(b.enkeltminner={});var d=b.enkeltminner.style||{color:"#fff",weight:1,fillColor:"#B942D0"};f=L.geoJson(null,{onEachFeature:function(a,c){a.properties.provider=b.enkeltminner.provider||"Enkeltminne",a.properties.color=b.enkeltminner.sidebarColor||"#B942D0",c.on("click",function(){u(a,b)})},style:function(){return d}}).addTo(c),e=function(b){var c={api:"kulturminnedataSparql",type:"enkeltminner",lokalitet:b.properties.id};a.getData(c,function(a){f.clearLayers(),f.addData(a)})}},w=function(a,e,f){b=f,c=a,b.on("hide",j),b.on("show",k),d=q(e),m(c,13,l),c.on("zoomend",r),c.on("layerDeselect",s),b.on("click",t),_.has(e,"showEnkeltminner")&&(i=e.showEnkeltminner),i&&v(e)},x=function(a){d.addData(a);var b=_.chain(a.features).map(function(a){return a.properties.lok}).uniq().value();h&&_.each(b,function(a){n(a)}),g=g.concat(b)},y=function(b,c,d){if(d){var e=_.chain(d).map(function(a){return a.properties.id}).filter(function(a){return-1===g.indexOf(a)}).value();if(e.length){var f={api:"kulturminnedataSparql",type:"lokalitetpoly",lokalitet:e};a.getData(f,x)}}};return{loadKulturminnePoly:y,initKulturminnePoly:w}}}(KR.Config);var KR=this.KR||{};KR.Config=KR.Config||{},function(a){"use strict";a.getDatasetList=function(b,c,d){var e=a.getKulturminneFunctions(b);c&&3===c.length&&(c="0"+c);var f={difo:{name:"Digitalt fortalt",dataset:{dataset:"difo",api:"norvegiana"},cluster:!0,template:KR.Util.getDatasetTemplate("digitalt_fortalt"),noListThreshold:1/0,description:"Kulturrådets tjeneste for personlige fortellinger fra kulturinstitusjoner og privatpersoner.",allowTopic:!0,feedbackForm:!0,isStatic:!1},verneomr:{id:"verneomraader",dataset:{api:"cartodb",table:"naturvernomrader_utm33_2",columns:["iid","omradenavn","vernef_id","verneform"]},provider:"Naturbase",name:"Verneområder",template:KR.Util.getDatasetTemplate("verneomraader"),getFeatureData:function(a,c){b.getItem({api:"norvegiana",id:"kulturnett_Naturbase_"+a.properties.iid},c)},toPoint:{showAlways:!0,stopPolyClick:!0,minSize:20},minZoom:10,cluster:!1,description:"Nasjonalparker og andre naturvernområder - ca. 2700 i hele landet."},artobs:{name:"Artsobservasjoner",hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"Artsdatabanken"},cluster:!1,description:"Artsobservasjoner fra Artsdatabanken",template:KR.Util.getDatasetTemplate("popup")},folketelling:{name:"Folketelling 1910",provider:"Folketelling 1910",dataset:{api:"folketelling",dataset:"property"},isStatic:!1,minZoom:14,template:KR.Util.getDatasetTemplate("folketelling"),getFeatureData:function(a,c){b.getData({api:"folketelling",type:"propertyData",propertyId:a.properties.efid},function(b){a.properties=b.properties,a.properties.provider="Folketelling 1910",c(a)})},mappings:{title:"gaardsnavn_gateadr"},noListThreshold:0,description:"Personer og eiendommer fra folketellingen 1910"},ark_hist:{grouped:!0,name:"Arkeologi og historie",datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}}],description:"Data fra Universitetsmuseene, Digitalt museum og Riksantikvaren"},jernbane:{id:"jernbane",dataset:{api:"jernbanemuseet"},provider:"Jernbanemuseet",name:"Jernbanemuseet",hideFromGenerator:!0,template:KR.Util.getDatasetTemplate("jernbanemuseet"),getFeatureData:function(a,c){b.getItem({api:"jernbanemuseet",id:a.properties.id},c)},isStatic:!0,bbox:!1,description:"Jernbanemuseet"},arkeologi:{grouped:!0,name:"Arkeologi",style:{fillcolor:"#436978",circle:!1,thumbnail:!0},datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER regex(?loccatlabel, "^Arkeologisk", "i") .',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}}],description:"Arkeologidata fra Universitetsmuseene og Riksantikvaren"},historie:{grouped:!0,name:"Historie",style:{fillcolor:"#D252B9",circle:!1,thumbnail:!0},datasets:[{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER (!regex(?loccatlabel, "^Arkeologisk", "i"))',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"-dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Industrimuseum"},isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Foto-SF"},isStatic:!1,bbox:!1,template:KR.Util.getDatasetTemplate("foto_sf")},{dataset:{api:"norvegiana",dataset:"Kystreise"},isStatic:!0,bbox:!1}],description:"Historie og kulturminner fra Riksantikvaren og Digitalt museum "},kunst:{grouped:!0,name:"Kunst",style:{fillcolor:"#72B026",circle:!1,thumbnail:!0},datasets:[{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1}],description:"Kunstdata fra Digitalt museum "},wikipedia:{name:"Wikipedia",provider:"Wikipedia",dataset:{api:"wikipedia"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra bokmålswikipedia"},wikipediaNN:{name:"Wikipedia Nynorsk",provider:"Wikipedia Nynorsk",dataset:{api:"wikipediaNN"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra nynorskwikipedia"},lokalwiki:{id:"lokalwiki",name:"Lokalhistoriewiki",hideFromGenerator:!1,provider:"Lokalhistoriewiki",dataset:{api:"lokalhistoriewiki"},style:{thumbnail:!0},minZoom:13,bbox:!0,isStatic:!1,description:"Stedfestede artikler fra lokalhistoriewiki.no"},riksantikvaren:{id:"riksantikvaren",name:"Kulturminnesøk",hideFromGenerator:!1,provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:10,callback:e.loadKulturminnePoly},description:"Data fra Riksantikvarens kulturminnesøk"},brukerminner:{name:"Kulturminnesøk - brukerregistreringer",hideFromGenerator:!1,provider:"riksantikvaren",dataset:{api:"kulturminnedata",layer:2,getExtraData:!0,extraDataLayer:6,matchId:"KulturminnesokID"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Brukerregistrerte data fra Riksantikvarens kulturminnesøk",template:KR.Util.getDatasetTemplate("brukerminne")},groruddalen:{name:"Byantikvaren Oslo - Groruddalen",hideFromGenerator:!0,provider:"Byantikvaren i Oslo",dataset:{api:"cartodb",table:"byantikvaren_oslo_groruddalen"},bbox:!1,isStatic:!1,style:{thumbnail:!0},template:KR.Util.getDatasetTemplate("byantikvaren_oslo"),description:"Byantikvarens Groruddalsatlas"},norgerundt:{name:"Norge Rundt",hideFromGenerator:!0,provider:"NRK",dataset:{api:"cartodb",table:"nrk_norge_rundt"},bbox:!1,isStatic:!1,style:{thumbnail:!0},description:"Stedfestede innslag fra Norge Rundt"},dimu:{name:"Digitalt Museum",hideFromGenerator:!1,provider:"dimu",dataset:{dataset:"DiMu",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Digitalt Museum",allowTopic:!0,feedbackForm:!0},musit:{name:"Universitetsmuseene",hideFromGenerator:!1,provider:"Universitetsmuseene",dataset:{dataset:"MUSIT",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Universitetsmuseene",allowTopic:!0,feedbackForm:!0},industrimuseum:{name:"Industrimuseum",hideFromGenerator:!1,provider:"Industrimuseum",dataset:{dataset:"Industrimuseum",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Industrimuseum",allowTopic:!0,feedbackForm:!0},kystreise:{name:"Kystreise",hideFromGenerator:!1,provider:"Kystreise",dataset:{dataset:"Kystreise",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Kystreise",allowTopic:!0,feedbackForm:!0},dimufoto:{hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"DiMu",query:"europeana_type_facet:IMAGE"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,style:{thumbnail:!0},noListThreshold:1/0},kulturminnesok_flickr:{name:"Kulturminnesøk",dataset_name_override:"Kulturminnesøk",provider:"Kulturminnesøk Flickr",hideFromGenerator:!0,dataset:{api:"flickr",group_id:"1426230@N24"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!0,style:{thumbnail:!0},description:"Bilder fra Kulturminnesøks Flickr-gruppe"},riksarkivet:{name:"Riksarkivet",dataset_name_override:"Riksarkivet",provider:"riksarkivet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_archives_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Riksarkivets Flickr-konto"},nasjonalbiblioteket:{name:"Nasjonalbiblioteket",dataset_name_override:"Nasjonalbiblioteket",provider:"nasjonalbiblioteket",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_library_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalbibliotekets Flickr-konto"},oslobyarkiv:{name:"Oslo Byarkiv",dataset_name_override:"Oslo Byarkiv",provider:"oslobyarkiv",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"byarkiv"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Oslo byarkiv sin Flickr-konto"},nasjonalmuseet:{name:"Nasjonalmuseet",dataset_name_override:"Nasjonalmuseet",provider:"nasjonalmuseet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nasjonalmuseet"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalmuseet sin Flickr-konto"},nve:{name:"NVE",dataset_name_override:"NVE",provider:"nve",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nve",accuracy:"6"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra NVE Flickr-konto"},vestfoldmuseene:{name:"Vestfoldmuseene",dataset_name_override:"Vestfoldmuseene",provider:"Vestfoldmuseene",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"vestfoldmuseene",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Vestfoldmuseene sin Flickr-konto"},perspektivet:{name:"Perspektivet Museum",dataset_name_override:"Perspektivet Museum",provider:"Perspektivet Museum",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"perspektivetmuseum",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Perspektivet Museum sin Flickr-konto"}};if(!c&&!d){var g={bbox:!0,minZoom:12,isStatic:!1,bboxFunc:KR.Util.sparqlBbox};_.extend(f.riksantikvaren,g),_.extend(f.ark_hist.datasets[2],g),_.extend(f.arkeologi.datasets[1],g),_.extend(f.historie.datasets[0],g)}return f},a.getDatasets=function(b,c,d,e){var f=a.getDatasetList(c,d,e);return _.chain(b).map(function(a){var b;if(a.indexOf(":")>-1){var c=a.split(":");a=c[0],b=c[1]}if(_.has(f,a)){var d=f[a];return b&&"norvegiana"===d.dataset.api&&(d.dataset.query="dc_subject_text:"+b),d}}).compact().value()}}(KR.Config);var KR=this.KR||{};KR.SplashScreen=function(a,b,c,d,e,f){"use strict";function g(){return window.location.href.replace(window.location.hash,"")}function h(){var a=g(),b="remember_"+a+"=",c=document.cookie.split("; "),d=_.find(c,function(a){return 0===a.indexOf(b)});return d?"true"===d.substring(b.length,d.length):void 0}function i(a){document.cookie="remember_"+g()+"="+a}function j(){this._gray&&this._container.removeChild(this._gray),L.Control.Sidebar.prototype.hide.apply(this,arguments)}function k(){this._gray=L.DomUtil.create("div","gray",this._container),L.Control.Sidebar.prototype.show.apply(this,arguments)}function l(){var g=L.DomUtil.create("div","",document.body);g.id="splashscreen";var h=L.control.sidebar("splashscreen",{position:"center",autoPan:!1});h.hide=_.bind(j,h),h.show=_.bind(k,h),a.addControl(h);var i=_.template($("#splashscreen_template").html()),l=$("
"+i({title:b,image:d,description:c,creator:e,spinner:!!f})+"
");return KR.Util.isInIframe()&&l.find("a").attr("target","_blank"),h.setContent(l.html()),h}function m(a){function b(){i(c.prop("checked"))}var c=$(a.getContainer()).find("#persist_splash_cb");c.prop("checked",h()),c.on("change",b),b()}function n(b){return L.easyButton(a,b,{position:"topright",icon:"fa-info-circle",title:"Om"})}var o=l();n(function(){o.isVisible()?o.hide():o.show()});var p=h();return p||(_.isUndefined(p)&&i(!0),o.show()),m(o),{finishedLoading:function(){var a=$(o.getContainer()).find("#splash_spinner");a&&a.remove()}}};var KR=this.KR||{};KR.ResponseForm=function(a,b){function c(a,b){var c=_.reduce(a,function(a,b,c){return a[g[c]]=b,a},{});$.ajax({url:h,data:c,type:"POST",dataType:"xml",success:b,error:b})}function d(b){a.find("form").addClass("hidden"),a.find("#form-success").removeClass("hidden").find(".media-body").text("Din melding er sendt til "+b+". De vil ta kontakt hvis de har behov for ytterligere informasjon")}function e(e){e.preventDefault();var f=a.find("#form_email").val(),g=a.find("#form_message").val();if(""===f||""===g)return!1;var h=_.extend({},b,{email:f,message:g});return c(h,function(){d(h.provider)}),!1}function f(){a.find("#form_email").val(""),a.find("#form_message").val(""),a.find("#form-success").addClass("hidden"),a.find("form").addClass("hidden"),a.find(".show-more").removeClass("hidden")}var g={message:"entry.126368279",email:"entry.748218122",id:"entry.2043404140",url:"entry.243673559",provider:"entry.826324496"},h="https://docs.google.com/forms/d/1ah66lattC8it7OTIM6de20NSNkBeiQ0vabpsHSaPU7s/formResponse",i=$("#response_form_template").html();a.append(i),a.find("form").on("submit",e),a.find(".show-more").click(function(){a.find(".show-more").addClass("hidden"),a.find("form").removeClass("hidden")}),a.find(".close ").click(f)};var KR=this.KR||{};!function(a){"use strict";function b(a){return function(b){if(!b||!b.features.length)return b;if(-1===b.features[0].geometry.type.indexOf("Polygon"))return turf.within(b,a);var c=_.filter(b.features,function(b){var c=turf.extent(b),d=turf.bboxPolygon(c);return!!turf.intersect(d,a.features[0])});return KR.Util.createFeatureCollection(c)}}function c(a,b,c,d,e){return c&&(b=KR.Config.getDatasets(b,a,d,e)),b}function d(a,b){var c={stroke:!1,fillColor:"#ddd",fillOpacity:.8},d=_.reduce(b.features,function(a,b){return turf.erase(a,b)},KR.Util.WORLD);L.geoJson(d,c).addTo(a)}function e(a,c,e,f,g,h,i,j){if(a.geomFilter){var k={api:"cartodb"};k[h]=g,c.getData(k,function(c){a.showGeom&&d(a.map,c);var f=L.geoJson(c),g=b(c);i(f.getBounds(),e,g,null,j)})}else f(g,function(a){var b=L.latLngBounds.fromBBoxString(a);i(b,e,null,null,j)})}function f(a,b,d,f,g,h){d=c(b,d,f,a.komm),_.isString(a.komm)&&(a.komm=a.komm.split(",")),e(a,b,d,b.getMunicipalityBounds,a.komm,"municipality",g,h)}function g(a,b,d,f,g,h){d=c(b,d,f,null,a.fylke),_.isString(a.fylke)&&(a.fylke=a.fylke.split(",")),e(a,b,d,b.getCountyBounds,a.fylke,"county",g,h)}function h(a,b,d,e,f,g){d=c(b,d,e);var h=L.latLngBounds.fromBBoxString(a.bbox);f(h,d,null,null,g)}function i(a){var b=[];return _.each(a.features,function(a){"GeometryCollection"===a.geometry.type?_.each(a.geometry.geometries,function(c){b.push(KR.Util.createGeoJSONFeatureFromGeom(c,a.properties))}):b.push(a)}),KR.Util.createFeatureCollection(b)}function j(a){var b=_.map(a.features,function(a){return turf.simplify(a,.01,!1)});return KR.Util.createFeatureCollection(b)}function k(a,d,e,f,g,h,k){var l={};e.linecolor&&(l.color=e.linecolor);var m=L.geoJson(a,l),n=m.getBounds();f=c(d,f,g);var o;if(a&&e.buffer){a=i(a),a.features.length>5&&(a=j(a));var p=turf.buffer(a,e.buffer,"kilometers");o=b(p)}h(n,f,o,m,k)}function l(a,b,c,d,e,f){KR.Util.getLine(b,a.line,function(g){k(g,b,a,c,d,e,f)})}function m(a){var b=KR.UrlFunctions.getHashFeature();if(b){var c=function(a){return decodeURIComponent(a.feature.id)===decodeURIComponent(b)||a.feature.id===decodeURIComponent(b)},d=_.find(_.flatten(a),function(a){return _.find(a.getLayers(),c)});if(d){var e=_.find(d.getLayers(),c);e.fire("click"),d.setLayerSelected(e)}}}function n(a,b){return _.map(a,function(a){return a.isStatic&&(a.fixedBbox=b),a.datasets&&(a.datasets=_.map(a.datasets,function(a){return a.isStatic&&(a.fixedBbox=b),a})),a})}function o(a){return _.map(a,function(a){return a.isStatic=!0,a.datasets&&(a.datasets=_.map(a.datasets,function(a){return a.isStatic=!0,a})),a})}var p={geomFilter:!1,showGeom:!1,loactionHash:!0,featureHash:!0};a.setupMap=function(a,b,c,d){function e(a,b,d,e,f){c.allstatic&&(b=o(b)),b=n(b,a.toBBoxString());var g=L.Knreise.LocateButton(null,null,{bounds:a});g.addTo(i);var h=function(f){f?(i.setView([f.lat,f.lon],f.zoom),a=i.getBounds()):i.fitBounds(a),c.loactionHash&&KR.UrlFunctions.setupLocationUrl(i);var g,h=function(a){m(a),q&&q.finishedLoading()};c.geomFilter&&a&&(g=a.toBBoxString());var j=k.loadDatasets(b,a.toBBoxString(),d,h,g);e&&e.addTo(i),b.length>1&&L.control.datasets(j).addTo(i)};c.initUserPos?(i.addOneTimeEventListener("locationChange",function(){var a={lat:i.userPosition.lat,lon:i.userPosition.lng,zoom:16};h(a)}),i.addOneTimeEventListener("locationError",function(){h(f)}),g.getLocation()):h(f)}c=c||{},c=_.extend({},p,c);var i=KR.Util.createMap("map",c),j=KR.Util.setupSidebar(i,{featureHash:c.featureHash}),k=new KR.DatasetLoader(a,i,j,null,c.cluster,c.clusterRadius);i.sidebar=j;var q;c.title&&(q=KR.SplashScreen(i,c.title,c.description,c.image,null,!1));var r,s=KR.UrlFunctions.getLocationUrl(i);return c.initUserPos||(r=s),c.map=i,c.komm?f(c,a,b,d,e,r):c.fylke?g(c,a,b,d,e,r):c.line?l(c,a,b,d,e,r):c.bbox?h(c,a,b,d,e,r):alert("Missing parameters!"),i},a.setupMapFromUrl=function(b,c,d){a.setupMap(b,c,d,!0)}}(KR);var KR=this.KR||{};KR.setupCollectionMap=function(a,b,c){"use strict";function d(a){var b=KR.Util.createMap("map",{layer:c});KR.SplashScreen(b,a.title,a.description,a.image,a.creator),$("title").append(a.title);var d=L.latLngBounds.fromBBoxArray(turf.extent(a.geo_json));_.each(a.geo_json.features,function(a){a.properties.datasetId=a.properties.provider,_.has(e,a.properties.provider)&&(a.template=e[a.properties.provider])});var f=KR.Util.setupSidebar(b),g=KR.Util.clusterClick(f),h=KR.Util.featureClick(f);L.Knreise.LocateButton(null,null,{bounds:d}).addTo(b),b.fitBounds(d);var i=L.Knreise.geoJson(a.geo_json,{onEachFeature:function(a,b){h(a,b)}}),j=(new L.Knreise.MarkerClusterGroup).addTo(b);j.addLayers(i.getLayers()),g(j)}var e={"Digitalt fortalt":KR.Util.getDatasetTemplate("digitalt_fortalt"),DigitaltMuseum:KR.Util.getDatasetTemplate("digitalt_museum"),Musit:KR.Util.getDatasetTemplate("musit"),Artsdatabanken:KR.Util.getDatasetTemplate("popup")};a.getCollection(b,d)}; \ No newline at end of file diff --git a/dist/scripts3d.js b/dist/scripts3d.js index d6bc5206..9fb5170d 100644 --- a/dist/scripts3d.js +++ b/dist/scripts3d.js @@ -2485,212 +2485,74 @@ KR.Config = KR.Config || {}; 'use strict'; ns.getKulturminneFunctions = function (api) { -/* - var _vectorLayer; - var loadedIds = []; - - - - function findLayer(lok) { - if (!_vectorLayer) { - return null; - } - - return _.find(_vectorLayer.getLayers(), function (layer) { - return (layer.feature.properties.id === lok); - }); - } - var loadKulturminnePoly = function (map, dataset, features) { - if (features) { - var ids = _.map(features, function (feature) { - return feature.properties.id; - }); - - var idsToLoad = _.filter(ids, function (id) { - return loadedIds.indexOf(id) === -1; - }); - - loadedIds = loadedIds.concat(idsToLoad); + var _vectorLayer; + var _map; + var _polygonLayer; + var _loadEnkeltminner; + var _enkeltMinneLayer; + var _loadedIds = []; + var _hideMarker = false; + var _showEnkeltminner = true; - if (idsToLoad.length) { - var q = { - api: 'kulturminnedataSparql', - type: 'lokalitetpoly', - lokalitet: idsToLoad - }; - api.getData(q, function (geoJson) { - dataset.extraFeatures.addData(geoJson); - if (!geoJson.features) { - return - } - _.chain(geoJson.features) - .map(function (f) { - return f.properties.lok; - }) - .uniq() - .each(function (lok) { - var l = findLayer(lok); - if (l) { - l.setOpacity(0); - } - }); - }); - } - } + var _hidePolygonLayer = function () { + map.removeLayer(_polygonLayer); }; - var initKulturminnePoly = function (map, dataset, vectorLayer) { - console.log(vectorLayer); - _vectorLayer = vectorLayer; - var showEnkeltminner = true; - if (_.has(dataset, 'showEnkeltminner')) { - showEnkeltminner = dataset.showEnkeltminner; - } - var enkeltMinneLayer; - var loadEnkeltminner; - if (showEnkeltminner) { + var _showPolygonLayer = function () { + map.addLayer(_polygonLayer); + }; - if (!_.has(dataset, 'enkeltminner')) { - dataset.enkeltminner = {}; + var _checkRemove = function (direction) { + var shouldShow = (direction === 'down'); + if (shouldShow) { + _map.addLayer(_polygonLayer); + if (_enkeltMinneLayer) { + _map.addLayer(_enkeltMinneLayer); } - - var enkeltminneStyle = dataset.enkeltminner.style || { - color: '#fff', - weight: 1, - fillColor: '#B942D0' - }; - - enkeltMinneLayer = L.geoJson(null, { - onEachFeature: function (feature, layer) { - feature.properties.provider = dataset.enkeltminner.provider || 'Enkeltminne'; - feature.properties.color = dataset.enkeltminner.sidebarColor || '#B942D0'; - layer.on('click', function () { - if (map.sidebar) { - map.sidebar.showFeature( - feature, - dataset.enkeltminner.template || KR.Util.getDatasetTemplate('ra_enkeltminne') - ); - } - }); - }, - style: function () { - return enkeltminneStyle; - } - }).addTo(map); - loadEnkeltminner = function (feature) { - var q = { - api: 'kulturminnedataSparql', - type: 'enkeltminner', - lokalitet: feature.properties.lok - }; - api.getData(q, function (geoJson) { - enkeltMinneLayer.clearLayers(); - enkeltMinneLayer.addData(geoJson); - }); - }; - } - - var highlightPolygons = true; - var onPolyClick; - if (highlightPolygons) { - - var deselectPolys = function () { - _.each(dataset.extraFeatures.getLayers(), function (l) { - l.setStyle(KR.Style.getPathStyle(l.feature, true)); - }); - }; - - onPolyClick = function (e) { - deselectPolys(); - var lok = e.layer.feature.properties.id; - var poly = _.find(dataset.extraFeatures.getLayers(), function (l) { - return (l.feature.properties.lok === lok); - }); - console.log(poly); - if (! poly) { - return; - } - poly.setStyle({ - weight: 1, - color: '#436978', - fillColor: '#72B026', - clickable: true, - opacity: 0.8, - fillOpacity: 0.4 - }); + } else { + _map.removeLayer(_polygonLayer); + if (_enkeltMinneLayer) { + _map.removeLayer(_enkeltMinneLayer); } - - vectorLayer.on('click', onPolyClick); - - map.on('layerDeselect', function (e) { - deselectPolys(); - }); } + }; - dataset.extraFeatures = L.geoJson(null, { - onEachFeature: function (feature, layer) { - if (dataset.extras && dataset.extras.groupId) { - layer.setStyle(KR.Style.getPathStyleForGroup(dataset.extras.groupId)); - } else { - feature.properties.datasetId = dataset.id; - layer.setStyle(KR.Style.getPathStyle(feature, true)); - } - - layer.on('click', function () { - - if (loadEnkeltminner) { - loadEnkeltminner(feature); - } - - var parent = _.find(dataset.geoJSONLayer.getLayers(), function (parentLayer) { - return (parentLayer.feature.properties.id === feature.properties.lok); - }); - - if (parent) { - parent.fire('click'); - if (onPolyClick) { - onPolyClick({layer: parent}) - } - } - }); + var _checkThresholdPassed = function (map, threshold, callback) { + var prevZoom; + map.on('zoomstart', function (e) { + prevZoom = map.getZoom(); + }); + map.on('zoomend', function (e) { + var currentZoom = map.getZoom(); + if (prevZoom > threshold && currentZoom <= threshold) { + callback('up'); } - }).addTo(map); - - - map.on('zoomend', function () { - var shouldShow = !(map.getZoom() < 13); - if (shouldShow) { - if (!map.hasLayer(dataset.extraFeatures)) { - map.addLayer(dataset.extraFeatures); - } - } else { - if (map.hasLayer(dataset.extraFeatures)) { - map.removeLayer(dataset.extraFeatures); - } + if (prevZoom <= threshold && currentZoom > threshold) { + callback('down'); } }); + } - vectorLayer.on('hide', function () { - map.removeLayer(dataset.extraFeatures); - if (enkeltMinneLayer) { - map.removeLayer(enkeltMinneLayer) - } + var _getMarkerForId = function (id) { + return _.find(_vectorLayer.getLayers(), function (layer) { + return (layer.feature.properties.id === id); }); + }; - vectorLayer.on('show', function () { - map.addLayer(dataset.extraFeatures); - if (enkeltMinneLayer) { - map.addLayer(enkeltMinneLayer) - } + var _getPolygonForId = function (id) { + return _.find(_polygonLayer.getLayers(), function (layer) { + return (layer.feature.properties.lok === id); }); }; - */ - var _vectorLayer; - var _map; - var _polygonLayer; - var _loadedIds = []; + var _polygonClicked = function (feature, layer) { + var parent = _getMarkerForId(feature.properties.lok); + if (parent) { + parent.fire('click'); + } + }; + var _createPolygonLayer = function (dataset) { return L.geoJson(null, { onEachFeature: function (feature, layer) { @@ -2700,50 +2562,118 @@ KR.Config = KR.Config || {}; feature.properties.datasetId = dataset.id; layer.setStyle(KR.Style.getPathStyle(feature, true)); } + layer.on('click', function () { + _polygonClicked(feature, layer); + }); } }).addTo(_map); }; - var _hidePolygonLayer = function () { - map.removeLayer(_polygonLayer); + var _checkCluster = function () { + /* + if (!_loadedIds.length) { + return; + } + _.each(_loadedIds, function (loadedId) { + var marker = _getMarkerForId(loadedId); + var visibleOne = _vectorLayer.getVisibleParent(marker); + //console.log(visibleOne._leaflet_id, marker._leaflet_id); + //console.log(marker, visibleOne); + }); + */ }; - var _showPolygonLayer = function () { - map.addLayer(_polygonLayer); + var _deselectPolygons = function () { + _.each(_polygonLayer.getLayers(), function (l) { + l.setStyle(KR.Style.getPathStyle(l.feature, true)); + }); }; - var _checkRemove = function () { - var shouldShow = !(_map.getZoom() < 13); - if (shouldShow) { - if (!map.hasLayer(dataset.extraFeatures)) { - map.addLayer(dataset.extraFeatures); - } - } else { - if (map.hasLayer(dataset.extraFeatures)) { - map.removeLayer(dataset.extraFeatures); - } + var _markerClicked = function (e) { + _deselectPolygons(); + var id = e.layer.feature.properties.id; + var poly = _getPolygonForId(id); + if (!poly) { + return; + } + poly.setStyle({ + weight: 1, + color: '#436978', + fillColor: '#72B026', + clickable: true, + opacity: 0.8, + fillOpacity: 0.4 + }); + if (_loadEnkeltminner) { + console.log("loadEnkeltminner") + _loadEnkeltminner(e.layer.feature); + } + } + + var _enkeltminneClick = function (feature, dataset) { + if (_map.sidebar) { + _map.sidebar.showFeature( + feature, + dataset.enkeltminner.template || KR.Util.getDatasetTemplate('ra_enkeltminne') + ); } }; - var _checkThresholdPassed = function (map, threshold, callback) { - var prevZoom; - map.on('zoomstart', function (e) { - prevZoom = map.getZoom(); - }); - map.on('zoomend', function (e) { - var currentZoom = map.getZoom(); - console.log('end:', prevZoom, currentZoom); - }); + var _setupEnkeltminner = function (dataset) { + if (!_.has(dataset, 'enkeltminner')) { + dataset.enkeltminner = {}; + } + + var enkeltminneStyle = dataset.enkeltminner.style || { + color: '#fff', + weight: 1, + fillColor: '#B942D0' + }; + + _enkeltMinneLayer = L.geoJson(null, { + onEachFeature: function (feature, layer) { + feature.properties.provider = dataset.enkeltminner.provider || 'Enkeltminne'; + feature.properties.color = dataset.enkeltminner.sidebarColor || '#B942D0'; + layer.on('click', function () { _enkeltminneClick(feature, dataset)}); + }, + style: function () { + return enkeltminneStyle; + } + }).addTo(_map); + + _loadEnkeltminner = function (feature) { + var q = { + api: 'kulturminnedataSparql', + type: 'enkeltminner', + lokalitet: feature.properties.id + }; + api.getData(q, function (geoJson) { + _enkeltMinneLayer.clearLayers(); + _enkeltMinneLayer.addData(geoJson); + }); + }; } + var initKulturminnePoly = function (map, dataset, vectorLayer) { _vectorLayer = vectorLayer; _map = map; - vectorLayer.on('hide', _hidePolygonLayer); - vectorLayer.on('show', _showPolygonLayer); + _vectorLayer.on('hide', _hidePolygonLayer); + _vectorLayer.on('show', _showPolygonLayer); _polygonLayer = _createPolygonLayer(dataset) - _checkThresholdPassed(_map, 13); + _checkThresholdPassed(_map, 13, _checkRemove); + _map.on('zoomend', _checkCluster); + _map.on('layerDeselect', _deselectPolygons); + _vectorLayer.on('click', _markerClicked); + + if (_.has(dataset, 'showEnkeltminner')) { + _showEnkeltminner = dataset.showEnkeltminner; + } + + if (_showEnkeltminner) { + _setupEnkeltminner(dataset); + } }; var _dataLoaded = function (geoJson) { @@ -2754,14 +2684,20 @@ KR.Config = KR.Config || {}; }) .uniq() .value(); - _loadedIds = _loadedIds.concat(newIds); - console.log("new ids", newIds); + if (_hideMarker) { + _.each(newIds, function (newId) { + var marker = _getMarkerForId(newId); + if (marker) { + //marker.setOpacity(0); + } + }) + } + _loadedIds = _loadedIds.concat(newIds); } var loadKulturminnePoly = function (map, dataset, features) { if (!features) { - console.log('no features to show for'); return; } @@ -2775,7 +2711,6 @@ KR.Config = KR.Config || {}; .value() if (!idsToLoad.length) { - console.log("no new features to load"); return; } var q = { diff --git a/dist/scripts3d.min.js b/dist/scripts3d.min.js index ab3b55a8..b127cda5 100644 --- a/dist/scripts3d.min.js +++ b/dist/scripts3d.min.js @@ -1,2 +1,2 @@ -var KR=this.KR||{};!function(a){"use strict";a.parseError=function(a){if(a.responseJSON){if(a.responseJSON.error)return a.responseJSON.error.join(", ");if(a.responseJSON.status)return a.responseJSON.status}return a.statusText?a.statusText:a.error?a.error.info?a.error.info:a.error.error?a.error.error:a.error:"Unknown error"},a.errorHandler=function(b){var c=$(b);c.find(".close").on("click",function(){c.find(".content").html(""),c.remove()});var d=_.template("
<%= dataset %>: <%= error %>
");return function(b){var e=d({dataset:b.dataset,error:a.parseError(b.error)});c.parent()?c.find(".content").append(e):c.find(".content").html(e),$("body").append(c)}}}(KR);var KR=this.KR||{};KR.Config={contentIcons:{IMAGE:"camera-retro",VIDEO:"file-video-o",SOUND:"music",TEXT:"file-text","default":"file-o"},templates:{}},KR.Config.ImageCaheUrl="http://egbtmre.cloudimg.io",KR.Util=KR.Util||{},function(a){"use strict";function b(a,b){var c=a.lastIndexOf(b);return-1!==c&&c+b.length===a.length}function c(a){return 1e3>a?"0"+a:a}a.iconForContentType=function(a){var b=a.properties.contentType;return _.has(KR.Config.contentIcons,b)?KR.Config.contentIcons[b]:KR.Config.contentIcons["default"]},a.getDatasetTemplate=function(a){var b=$("#"+a+"_template").html();return b?_.template(b):void 0},a.templateForDataset=function(a){return _.has(KR.Config.templates,a)?KR.Config.templates[a]:void 0},a.createStyleString=function(a){return _.map(a,function(a,b){return b+": "+a}).join(";")},a.colorForProvider=function(a,b){var c=!0;"hex"!==b&&(c=!1);var d={properties:{datasetId:a}};return KR.Style.colorForFeature(d,c,!0)},a.featureClick=function(a){return function(b,c,d){c.on("click",function(c){d&&d.toPoint&&d.toPoint.stopPolyClick&&!c.parent||(d?a.showFeature(b,d.template,d.getFeatureData):a.showFeature(b))})}},a.getTemplateForFeature=function(a,b){if(b){if(b.datasets){var c=_.find(b.datasets,function(b){return b._knreise_id===a.properties.datasetID});return c.template}return b.template}},a.clusterClick=function(b){return function(c,d){c.on("clusterclick",function(c){var e=_.map(c.layer.getAllChildMarkers(),function(b){var c=b.feature;return d&&!c.template&&(c.template=a.getTemplateForFeature(c,d)),c}),f=_.extend({},{template:null,getFeatureData:null,noListThreshold:null},d);b.showFeatures(e,f.template,f.getFeatureData,f.noListThreshold)})}},a.hexToRgba=function(a,b){b=b||1;var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);if(!c)return 0;var d={r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)};return"rgba("+d.r+","+d.g+","+d.b+","+b+")"},a.filterByBbox=function(a,b){var c=turf.featurecollection([turf.bboxPolygon(KR.Util.splitBbox(b))]);return turf.within(a,c)},a.getDatasetId=function(a){return"norvegiana"===a.dataset.api?a.dataset.dataset:"wikipedia"===a.dataset.api?"wikipedia":a.id?a.id:KR.Util.stamp(a)},"undefined"!=typeof L&&(L.latLngBounds.fromBBoxArray=function(a){return new L.LatLngBounds(new L.LatLng(a[1],a[0]),new L.LatLng(a[3],a[2]))},L.latLngBounds.fromBBoxString=function(a){return L.latLngBounds.fromBBoxArray(KR.Util.splitBbox(a))},L.rectangle.fromBounds=function(a){return L.rectangle([a.getSouthWest(),a.getNorthEast()])}),a.parseQueryString=function(a){var b=decodeURIComponent(a);if(""!==b)return _.reduce(b.replace("?","").split("&"),function(a,b){b=b.split("=");var c=b[1];return"true"===c?c=!0:"false"===c&&(c=!1),a[b[0]]=c,a},{})};var d=_.template("<%= totalt %> (<%= menn %> menn, <%= kvinner %> kvinner)");a.formatPersons=function(a){var b=a.split("-");return b.length<2?a:d({totalt:b[0],menn:b[1],kvinner:b[2]})},a.getBaseLayer=function(a,b){var c={nib:KR.getNibLayer,hist:function(a){a(L.tileLayer.wms("http://wms.geonorge.no/skwms1/wms.historiskekart",{layers:"historiskekart",format:"image/png",attribution:"Kartverket"}))}};if(_.has(c,a))c[a](b);else{var d=navigator.userAgent.indexOf("Safari")>-1,e=!d;b(L.tileLayer.kartverket(a,{useCache:e}))}},a.getLine=function(a,c,d){if(_.isFunction(c))return void c(function(a){d(a)});var e;if(0===c.indexOf("utno/")){var f=c.replace("utno/","");e={api:"utno",id:f,type:"gpx"}}else 0===c.indexOf("http")&&(b(c,"kml")?e={api:"kml",url:c}:b(c,"gpx")||-1!==c.indexOf("http://ut.no/tur/")?e={api:"gpx",url:c}:b(c,"geojson")&&(e={api:"geojson",url:c}));e?a.getData(e,function(a){d(a)}):alert("Kunne ikke laste linjegeometri")},a.messageDisplayer=function(a){return function(b,c){var d=$(a);d.find(".close").on("click",function(){d.find(".content").html(""),d.remove()}),d.addClass("alert-"+b),d.find(".content").html(c),$("body").append(d)}},a.mostlyCoveringMunicipality=function(a,b,c){var d="ST_MakeEnvelope("+b+", 4326)",e="SELECT komm FROM kommuner WHERE ST_Intersects(the_geom, "+d+")ORDER BY st_area(st_intersection(the_geom, "+d+")) DESC LIMIT 1",f={api:"cartodb",query:e,mapper:function(a){return a.rows[0].komm}};a.getData(f,c)},a.sparqlBbox=function(a,b,d,e,f){KR.Util.mostlyCoveringMunicipality(a,d,function(d){b.kommune=c(d),a.getData(b,e,f)})},a.distanceAndSort=function(a,b){var c=_.map(a.features,function(a){return a.properties.distance=turf.distance(b,a),a});return turf.featurecollection(c.sort(function(a,b){return a.properties.distanceb.properties.distance?1:0}))},a.round=function(a,b){_.isUndefined(b)&&(b=2);var c=Math.pow(10,b);return Math.round(a*c)/c};var e=_.template("#<%= zoom %>/<%= lat %>/<%= lon %>");a.getPositionHash=function(b,c,d){return e({zoom:d,lat:a.round(b,4),lon:a.round(c,4)})},a.WORLD={type:"Feature",geometry:{type:"Polygon",coordinates:[[[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]]}},a.createMap=function(b,c){c=c||{};var d=L.map(b,{minZoom:c.minZoom||3,maxZoom:c.maxZoom||18,maxBounds:L.geoJson(a.WORLD).getBounds()}),e=c.layer||"norges_grunnkart_graatone";return _.isString(e)?KR.Util.getBaseLayer(e,function(a){a.addTo(d)}):e.addTo(d),d},a.setupSidebar=function(a,b){b=b||{};var c=KR.Util.getDatasetTemplate("popup"),d=_.template($("#list_item_template").html()),e=_.template($("#marker_template").html()),f=_.template($("#thumbnail_template").html()),g=_.template($("#footer_template").html()),h=_.extend({},{position:"left",template:c,listElementTemplate:d,markerTemplate:e,thumbnailTemplate:f,footerTemplate:g},b),i=L.Knreise.Control.sidebar("sidebar",h);return a.addControl(i),i},a.distanceAndBearing=function(a,b){return{distance:1e3*turf.distance(a,b,"kilometers"),bearing:turf.bearing(a,b)}};var f=_.template("<%= service %>/s/crop/<%= width %>x<%= height %>/<%= image %>");a.getImageCache=function(a,b,c){return KR.Config.ImageCaheUrl?f({service:KR.Config.ImageCaheUrl,width:b,height:c,image:a}):a},a.isInIframe=function(){try{return window.self!==window.top}catch(a){return!0}}}(KR.Util);var KR=this.KR||{};KR.Style={},function(a){"use strict";function b(a){var b=a.properties.vernef_id;return _.find(p,function(a){return-1!==a.ids.indexOf(b)})}function c(a){return u[a]||"blue"}function d(a,b,c,d){return _.isFunction(a[b])?d?a[b]():a[b](c):a[b]}function e(a,b,c){return c?d(a,"fillcolor",b,!0):d(a,"fillcolor",b)}function f(a,b){return a.bordercolor?d(a,"bordercolor",b):e(a,b)}function g(b){return a.groups[b]}function h(b){var c;return b.properties&&b.properties.groupId?g(b.properties.groupId):(b.properties&&b.properties.datasetId&&(c=a.getDatasetStyle(b.properties.datasetId)),c?c:_.extend({},s))}function i(a,b,c){return c=c||9,{radius:c,weight:1,opacity:1,color:a,fillColor:b,fillOpacity:.4}}function j(a,b,c){return L.circleMarker(a,i(b,c))}function k(a){return L.Knreise.icon({markerColor:a})}function l(a,b,c){var d="";return a.properties&&a.properties.title&&(d=a.properties.title),L.marker(b,{icon:c,title:d})}function m(a,b,c){if(a.properties&&a.properties.thumbnail){var d={"border-color":b,"background-image":"url("+a.properties.thumbnail+")"};c&&(d["border-width"]="3px");var e=KR.Util.getImageCache(a.properties.thumbnail,50,50),f='
';return new L.DivIcon({className:"leaflet-marker-circle",html:f,iconSize:[50,50],iconAnchor:[25,25]})}}function n(a,b,c){var d=_.filter(a,function(a){return a.feature.properties.thumbnail});if(d.length){var e;_.isArray(b)&&(e=_.rest(b),b=b[0]);var f=KR.Util.getImageCache(d[0].feature.properties.thumbnail,50,50),g={"border-color":b,"background-image":"url("+f+");"};e&&(g["box-shadow"]=_.map(e,function(a,b){var c=2*(b+1);return"0 0 0 "+c+"px "+a}).join(",")+";"),c&&(g["border-width"]="3px");var h='
'+a.length+"";return new L.DivIcon({className:"leaflet-marker-photo",html:h,iconSize:[60,60],iconAnchor:[30,30]})}}function o(a,b){var c=KR.Util.hexToRgba(b,.4);return new L.DivIcon({className:"leaflet-marker-circle",html:'
'+a.length+"",iconSize:[20,20],iconAnchor:[10,10]})}var p={landskapsvern:{ids:["LVO","LVOD","LVOP","LVOPD","BV","MAV","P","GVS","MIV","NM","BVV","PO","DO","D"],style:{fillColor:"#d8cb7a",color:"#9c8f1b"}},nasjonalpark:{ids:["NP","NPS"],style:{fillColor:"#7f9aac",color:"#b3a721"}},naturreservat:{ids:["NR","NRS"],style:{fillColor:"#ef9874",color:"#ef9873"}}},q="#72B026",r="#38A9DC",s={fillcolor:r,circle:!1,thumbnail:!0},t={difo:"Digitalt fortalt",Kulturminnesok:"Kulturminnesok",DiMu:"DigitaltMuseum",MUSIT:"Musit",Artsdatabanken:"Artsdatabanken",wikipedia:"wikipedia",riksantikvaren:"riksantikvaren"};a.datasets={"Digitalt fortalt":{fillcolor:"#F69730",circle:!1,thumbnail:!0},Kulturminnesok:{fillcolor:"#436978",circle:!1,thumbnail:!1},DigitaltMuseum:{fillcolor:"#436978",circle:!1,thumbnail:!1},Musit:{fillcolor:"#436978",circle:!1,thumbnail:!1},Artsdatabanken:{fillcolor:"#5B396B",thumbnail:!1,circle:!0},riksantikvaren:{fillcolor:"#436978",circle:!1,thumbnail:!0},verneomraader:{fillcolor:function(a){if(a){var c=b(a);if(c)return c.style.fillColor}return"#009300"},bordercolor:function(a){if(a){var c=b(a);if(c)return c.style.color}return"#009300"},thumbnail:!1,circle:!0},wikipedia:{fillcolor:"#D14020",thumbnail:!0}},a.groups={},a.getDatasetStyle=function(b){var c=a.datasets[t[b]];return c||(c=a.datasets[b]),c},a.setDatasetStyle=function(b,c){_.has(t,b)||(t[b]=b);var d=a.getDatasetStyle(b);d||(d=s),a.datasets[t[b]]=_.extend({},d,c)};var u={"#F69730":"orange","#38A9DC":"blue","#A23336":"darkred","#72B026":"green","#436978":"cadetblue","#5B396B":"darkpurple","#728224":"darkgreen","#D252B9":"purple","#D14020":"red"};a.getClusterIcon=function(a,b){var c,d=a.getAllChildMarkers(),f=_.uniq(_.map(d,function(a){return a.feature.properties.groupId})),i=h(d[0].feature);if(_.compact(f).length>1){var j=_.compact(f);j.length>1&&(c=_.map(j,_.compose(e,g)))}else c=e(i,d[0].feature);if(b&&(c=q),i.thumbnail){var k=n(d,c,b);if(k)return k}return o(d,c)},a.getIcon=function(a,b){var c=h(a),d=b?q:e(c,a),g=b?q:f(c,a);if(c.thumbnail){var j=m(a,g,b);if(j)return j}return c.circle?i(g,d,c.radius):k(d)},a.getMarker=function(b,c){var d=h(b);if(d.thumbnail){var g=m(b,f(d,b),!1);if(g)return l(b,c,g)}return d.circle?j(c,f(d,b),e(d,b)):l(b,c,a.getIcon(b,!1))},a.colorForFeature=function(a,b,d){var f=h(a);return f?b?e(f,a,d):c(e(f,a)):void 0},a.colorForDataset=function(b,d,f){var g,i;return b.grouped?(g=a.groups[KR.Util.stamp(b)],g||(i=b.datasets[0].extras.datasetId)):(i||(i=b.extras.datasetId),g=h({properties:{datasetId:i}})),g?d?e(g,null,f):c(e(g,null)):void 0},a.getPathStyle=function(a,b){b=b||!1;var c=h(a),d=e(c,a),g=f(c,a);return{weight:1,color:g,fillColor:d,clickable:b,opacity:.8,fillOpacity:.4}},a.getPathStyleForGroup=function(b,c){var d={properties:{groupId:b}};return a.getPathStyle(d,c)}}(KR.Style);var KR=this.KR||{};KR.PathTracer=function(a,b,c){"use strict";function d(b,c){Cesium.Math.setRandomNumberSeed(3),a.clock.startTime=b.clone(),a.clock.stopTime=c.clone(),a.clock.currentTime=b.clone(),a.clock.clockRange=Cesium.ClockRange.LOOP_STOP,a.clock.multiplier=l,a.clock.shouldAnimate=!1}function e(b,c,d){var e=a.entities.add({availability:new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({start:b,stop:c})]),position:d,orientation:new Cesium.VelocityOrientationProperty(d)});return e}function f(a,b,c){b=b.reverse(),c.geometry.coordinates=c.geometry.coordinates.reverse();var d=0,e=turf.point(c.geometry.coordinates[0]),f=new Cesium.SampledPositionProperty;return _.each(b,function(b,g){var h=turf.point(c.geometry.coordinates[g]);d+=1e3*turf.distance(e,h,"kilometers"),e=h;var i=Cesium.JulianDate.addSeconds(a,d/k,new Cesium.JulianDate),j=new Cesium.Cartesian3(b.x,b.y,b.z+2);f.addSample(i,j)}),f}function g(b){a.clock.onTick.addEventListener(function(c){if(m){var d=Cesium.Cartesian3,e=b.position.getValue(c.currentTime,new d),f=b.position.getValue(Cesium.JulianDate.addSeconds(c.currentTime,1/60,new Cesium.JulianDate),new d),g=d.subtract(f,e,new d);d.normalize(g,g);var h=new d,i=new d,j=new d;Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(e,h),d.cross({x:0,y:0,z:1},h,i),d.cross(h,i,j);var k=new d;k.x=d.dot(g,i),k.y=d.dot(g,j),k.z=d.dot(g,h);var l=new d(0,0,1),o=new d(1,0,0),p=new d(0,1,0),q=d.dot(k,o),r=d.dot(k,p),s=d.dot(k,l),t=Math.atan2(q,r),u=Math.asin(s);t+=0*Math.PI,u+=-20/180*Math.PI;var v=800,w=new Cesium.HeadingPitchRange(t,u+n,v);a.scene.camera.lookAt(b.position.getValue(c.currentTime),w)}})}function h(){var h=c.features[0],i=1e3*turf.lineDistance(h,"kilometers"),j=i/k,l=Cesium.JulianDate.fromDate(new Date(2015,2,25,16)),m=Cesium.JulianDate.addSeconds(l,j,new Cesium.JulianDate);d(l,m);var n=f(l,b,h),o=e(l,m,n);o.position.setInterpolationOptions({interpolationDegree:5,interpolationAlgorithm:Cesium.LagrangePolynomialApproximation}),a.trackedEntity=void 0,g(o)}function i(){m=!0,a.clock.shouldAnimate=!0}function j(){m=!1,a.clock.shouldAnimate=!1}var k=1.4,l=35,m=!1,n=0;return h(),{start:i,stop:j,isRunning:function(){return m},setPitchCorr:function(a){n=a}}};var KR=this.KR||{};KR.CesiumMap=function(a,b,c){"use strict";function d(a){return a=a||"//assets.agi.com/stk-terrain/world",new Cesium.CesiumTerrainProvider({url:a,requestVertexNormals:!0,requestWaterMask:!1})}function e(a){var b,c=s.scene.camera;c.moveEnd.addEventListener(function(){var d=Cesium.Ellipsoid.WGS84.cartesianToCartographic(c.position),e=!Cesium.Rectangle.contains(a,d);e&&b&&(c.position=b),b=c.position.clone()})}function f(){s=new Cesium.Viewer(a,t.cesiumViewerOpts);var b=s.scene;b.imageryLayers.removeAll();var f=b.globe;t.cesiumViewerOpts.enableLighting&&(f.enableLighting=!0),f.depthTestAgainstTerrain=!0,s.terrainProvider=d(t.cesiumViewerOpts.terrainUrl);var g,h=b.camera;if(c){c=KR.Util.splitBbox(c);var i=Cesium.Ellipsoid.WGS84;g=new Cesium.Rectangle(Cesium.Math.toRadians(c[0]),Cesium.Math.toRadians(c[1]),Cesium.Math.toRadians(c[2]),Cesium.Math.toRadians(c[3])),h.viewRectangle(g,i)}g&&t.cesiumViewerOpts.limitBounds&&e(g)}function g(a,b){var c=a.features[0].geometry.coordinates,d=_.map(c,function(a){return new Cesium.Cartographic.fromDegrees(a[0],a[1])}),e=Cesium.sampleTerrain(s.terrainProvider,14,d);Cesium.when(e,function(a){b(Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(a))})}function h(a){return _.map(a,function(a,b){return b+"="+a}).join("&")}function i(a){return new Cesium.UrlTemplateImageryProvider({url:a})}function j(a,b,c){var d={SERVICE:"WMTS",REQUEST:"GetTile",TILEROW:"{TileRow}",TILECOL:"{TileCol}",STYLE:"{Style}",LAYER:b};return{url:a+"?"+h(_.extend({},d,c||{})),layer:"",tileMatrixSetID:""}}function k(a,b,c){var d={style:"default",version:"1.0.0",format:"image/png",maximumLevel:19};return new Cesium.WebMapTileServiceImageryProvider(_.extend({},d,j(a,b,c)))}function l(a,b){return new Cesium.WebMapServiceImageryProvider({url:a,layers:b,parameters:{service:"WMS",version:"1.1.1",request:"GetMap",styles:"",format:"image/png",transparent:!0}})}function m(a){return _.map(a,function(a){var b={position:Cesium.Cartesian3.fromDegrees(a.pos.lng,a.pos.lat,a.pos.height||80),billboard:{image:a.icon,show:!0,heightReference:2,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1},label:{text:a.text,font:"14pt monospace",style:Cesium.LabelStyle.FILL_AND_OUTLINE,outlineWidth:2,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,pixelOffset:new Cesium.Cartesian2(0,32)},properties:a.properties};return s.entities.add(b),b})}function n(a,b,c,d){c=c||14;var e=[];d||(d=0),_.each(a.features,function(a){var b=a.geometry.coordinates;e.push(new Cesium.Cartographic.fromDegrees(b[0],b[1]))});var f=Cesium.sampleTerrain(s.terrainProvider,c,e);Cesium.when(f,function(c){var e=c;_.each(a.features,function(a,b){var c=e[b];a.geometry.coordinates=[Cesium.Math.toDegrees(c.longitude),Cesium.Math.toDegrees(c.latitude),c.height+d]}),b(a)})}function o(a){var b=new Cesium.EntityCollection,c=new Cesium.ScreenSpaceEventHandler(s.scene.canvas);c.setInputAction(function(c){var d=s.scene.drillPick(c.position);if(Cesium.defined(d)){b.removeAll();var e=_.map(d,function(a){var c=a.id;return b.add(c),c.properties});e.length&&a(e)}},Cesium.ScreenSpaceEventType.LEFT_CLICK)}function p(a,b,c,d){c.getBbox(a,b,function(a){n(a,function(a){var b=Cesium.GeoJsonDataSource.load(a);d(b)})},function(a){d()})}function q(a,b,c,d){c.getBbox(a,b,function(a){_.each(a.features,function(a){a.properties=_.extend(a.properties,d)}),n(a,function(a){var b=_.map(a.features,function(a){var b=a.properties["marker-color"]||"blue";return{pos:{lat:a.geometry.coordinates[1],lng:a.geometry.coordinates[0],height:a.geometry.coordinates[2]},icon:"../common/img/markers/"+b+".png",properties:a.properties}});m(b)})},function(b){console.warn("could not load dataset",a)})}function r(){$(".spinner-wrapper").delay(2e3).fadeOut({duration:200})}Cesium.BingMapsApi.defaultKey="";var s,t={cesiumViewerOpts:_.extend({timeline:!1,baseLayerPicker:!1,geocoder:!1,enableLighting:!0,infoBox:!1,animation:!1,orderIndependentTranslucency:!1},b||{})};return f(),{viewer:s,addMarkers:m,build3DLine:g,addClickhandler:o,loadDataset:p,loadDataset2:q,stopLoading:r,getTiles:i,getWmts:k,getWms:l,addImageryProvider:function(a){s.imageryLayers.addImageryProvider(a)}}},KR.CesiumUtils={},KR.CesiumUtils.getBounds=function(a){"use strict";var b=turf.envelope(a),c=b.geometry.coordinates[0];return c[0].concat(c[2]).join(",")};var KR=this.KR||{};KR.CesiumSidebar=function(a,b,c,d){"use strict";function e(a){o.html(a)}function f(a){return{properties:a,template:a.template}}function g(a){p.showFeature(f(a))}function h(a){var b=_.map(a,f);p.showFeatures(b)}function i(b){a.show("slide",{direction:"left"},100),1===b.length?g(b[0]):h(b)}function j(){a.hide("slide",{direction:"left"},100),e(""),q&&q()}d=d||{footerTemplate:_.template($("#footer_template").html()),listElementTemplate:_.template($("#list_item_template").html()),markerTemplate:_.template($("#marker_template").html()),thumbnailTemplate:_.template($("#thumbnail_template").html())};var k=$('');a.append(k);var l=$('
');k.append(l);var m=$('×');l.append(m);var n=$("");l.append(n);var o=$('');k.append(o);var p=new KR.SidebarContent(k,o,n,d),q=c;return a.addClass("knreise-sidebar"),m.click(j),{show:i,addCloseCb:function(a){q=a}}};var KR=this.KR||{};!function(){"use strict";function a(){function a(a){if(d&&d.userPosition){var b=turf.point([d.userPosition.lng,d.userPosition.lat]),c=KR.Util.distanceAndBearing(b,a),e=c.distance;return e=1e3>e?KR.Util.round(e,0)+" Meter":KR.Util.round(e/1e3,2)+" Kilometer",{dist:e,rot:c.bearing-45}}}function b(){if(e&&d&&d.userPosition&&f){g&&g.remove();var b=e.find("h3").eq(0),c=a(f);g=$(h({distanceBearing:c})),b.length?b.after(g):e.prepend(g)}}function c(a,c){e=c,f=a,b()}var d,e,f,g,h=_.template($("#user_position_template").html());return{setMap:function(a){d=a,d.on("locationChange",b)},selectFeature:c}}KR.SidebarContent=function(b,c,d,e){function f(a){c.html(a)}function g(a){a&&c.swipe({swipe:function(){},allowPageScroll:"vertical"}).off("swipeLeft").on("swipeLeft",function(){a.next&&a.next()}).off("swipeRight").on("swipeRight",function(){a.prev&&a.prev()})}function h(a,b,c,d,f,g){var i;b>0&&(i=function(e){e&&e.preventDefault(),b-=1,a=f[b];var i=h(a,b,c,d,f,g);j(a,c,d,i,b,f.length)});var l;return b"),p+='',f(p),void i(a,function(b){b.properties=_.extend(a.properties,b.properties),j(b,h,null,k,n,o)})}h=h||a.template||KR.Util.templateForDataset(a.properties.dataset)||l;var q=a.properties.images;_.isArray(q)&&(q=q[0]),a.properties.images||(a.properties.images=null),a.properties.allProps&&a.properties.allProps.europeana_rights?a.properties.license=a.properties.allProps.europeana_rights[0]:a.properties.license=null;var r=a.properties.color||KR.Style.colorForFeature(a,!0,!0),p=''+a.properties.provider+"";if(p+=h(_.extend({image:null},a.properties)),e.footerTemplate&&a.properties.link&&(p+=e.footerTemplate(a.properties)),p=$(["
",p,"
"].join(" ")),KR.Util.isInIframe()&&p.find("a").attr("target","_blank"),m.selectFeature(a,p),f(p),g(k),b.find(".prev-next-arrows").remove(),d.html(""),k){var s=$('');d.append(s),s.click(k.close);var t=n+1;d.append($('
'+t+" av "+o+"
"));var u=$('');b.append(u),k.prev&&u.click(k.prev).addClass("active");var v=$('');b.append(v),k.next&&v.click(k.next).addClass("active")}var w=c.find(".media-container");w.length&&KR.MediaCarousel.SetupMediaCarousel(w),"undefined"!=typeof audiojs&&audiojs.createAll(),c.scrollTop(0)}function k(a,b,f,g,j){g=void 0===g?e.noListThreshold:g;var k=a.length<=g;if(k&&j!==!0){var l=a[0];c.html("");var m=h(l,0,b,f,a);return void this.showFeature(l,b,f,m,0,a.length)}var n=$(''+a.length+"");d.html(n);var o=_.chain(a).groupBy(function(a){return a.properties.provider}).map(function(c,d){var e=$("
"),g=$('
'),h=_.map(c,function(c){var d=_.findIndex(a,function(a){return a===c});return i(c,d,b,f,a)},this);return g.append(h),e.append('
'+d+"
"),e.append(g),e}).value();c.html(o),c.scrollTop(0)}var l=KR.Util.getDatasetTemplate("popup"),m=new a;return c=$(c),b=$(b),d=$(d),{showFeature:j,showFeatures:k,setMap:function(a){m.setMap(a)}}}}();var KR=this.KR||{};KR.DatasetLoader=function(a,b,c,d,e,f){"use strict";function g(a){var b=KR.Util.stamp(a);return function(c){return c&&c.features.length?(_.each(c.features,function(c){c.properties.datasetID=b,_.has(a,"circle")&&(c.properties.circle=a.circle),_.has(a,"provider")&&(c.properties.provider=a.provider),_.has(a,"extras")&&(c.properties=_.extend(c.properties,a.extras)),c.properties.feedbackForm=a.feedbackForm,_.has(a,"mappings")&&_.each(a.mappings,function(a,b){c.properties[b]=c.properties[a]}),c.template=KR.Util.getTemplateForFeature(c,a)}),c):c}}function h(a){var b=_.reduce(_.without(_.keys(a),"datasets"),function(b,c){return"style"!==c&&(b[c]=a[c]),b},{});if(a.style){b.extras=b.extras||{};var c=KR.Util.stamp(a);b.extras.groupId=c,KR.Style.groups[c]=a.style}return a.datasets=_.map(a.datasets,function(a){return _.extend({},b,a)}),a}function i(a,b){var c={dataset:b,onEachFeature:function(a,c){A&&A(a,c,b)}};return b.style&&(c.style=b.style),L.Knreise.geoJson(a,c)}function j(a,b){a.clearLayers();var c=_.reduce(b,function(a,b){return a.concat(b.toGeoJSON().features)},[]);a.addData(KR.Util.createFeatureCollection(c)),a.fire("dataAdded")}function k(a,c){a.clearLayers();var d=_.reduce(c,function(a,c){return c.setMap(b),a.concat(c.getLayers())},[]);a.addLayers(d)}function l(a,b){a.on("hide",function(){b(!0)}),a.on("show",function(){b(!0)})}function m(a,b){var c;e?c=i(null,a):a.cluster?(c=new L.Knreise.MarkerClusterGroup({dataset:a,maxClusterRadius:f}).addTo(b),z&&z(c,a)):c=i(null,a).addTo(b);var d=!0;return a.minFeatures&&(d=!1),c.enabled=d,c}function n(a,b){a.enabled!==b&&(a.enabled=b,a.fire("changeEnabled"))}function o(a){if(a.datasets&&!a.grouped){var b=_.filter(a.datasets,function(a){return a.visible}).length;return b>0}return a.visible}function p(a){return a.minZoom&&b.getZoom()-1){var c=a.split(":");a=c[0],b=c[1]}if(_.has(f,a)){var d=f[a];return b&&"norvegiana"===d.dataset.api&&(d.dataset.query="dc_subject_text:"+b),d}}).compact().value()}}(KR.Config);var KR=this.KR||{};!function(a){"use strict";function b(a){return turf.featurecollection([turf.simplify(a.features[0],.001,!1)])}function c(a,b){return b=b||{},{polyline:{positions:a,width:5,material:new Cesium.PolylineOutlineMaterialProperty({color:Cesium.Color.ORANGE,outlineWidth:2,outlineColor:Cesium.Color.BLACK})}}}function d(a,b,c){var d=a.layer||"topo2";if("norges_grunnkart_graatone"===d&&(d="norges_grunnkart"),"hist"===d)c(b.getWms("http://wms.geonorge.no/skwms1/wms.historiskekart","historiskekart"));else if("nib"===d){var e="http://knreise.no/nib/?type=token";KR.Util.sendRequest(e,null,function(a){c(0!==a.indexOf("**")?b.getWmts("http://crossorigin.me/http://gatekeeper1.geonorge.no/BaatGatekeeper/gk/gk.nibcache_wmts","NiB",{TILEMATRIXSET:"EPSG:900913",TILEMATRIX:"EPSG:900913:{TileMatrix}",FORMAT:"image/jpeg",GKT:a}):b.getTiles("http://www.webatlas.no/wacloud/servicerepository/combine.aspx?X={x}&Y={y}&Z={z}&layers=TMS_WEBATLAS_STANDARD:1"))})}else c(b.getWmts("http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts",d,{TILEMATRIXSET:"EPSG:3857",TILEMATRIX:"EPSG:3857:{TileMatrix}",FORMAT:"image/png"}))}function e(a){function b(){e.find(".glyphicon").removeClass("glyphicon-play").addClass("glyphicon-pause"),a.start()}function c(){e.find(".glyphicon").removeClass("glyphicon-pause").addClass("glyphicon-play"),a.stop()}function d(){a.isRunning()?c():b()}var e=$("#playpause");return{play:b,pause:c,toggle:d}}var f={animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!1,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,navigationHelpButton:!0,navigationInstructionsInitiallyVisible:!1,orderIndependentTranslucency:!1};a.setupMap3d=function(a,g,h){function i(){var b=KR.Config.getDatasets(g,a);return _.chain(b).map(function(a){return a.datasets?a.datasets:a}).flatten().filter(function(a){return _.has(a.dataset,"kommune")&&_.isUndefined(a.dataset.kommune)?!1:!0}).value()}function j(a,b){return new KR.CesiumMap(a,_.extend(f,{limitBounds:h.limitBounds,terrainUrl:h.terrainUrl,enableLighting:h.enableLighting}),b)}function k(b,c,d){_.each(b,function(b){var d=KR.Util.getDatasetId(b),e={template:b.template,datasetId:d,"marker-color":KR.Style.colorForFeature({properties:{datasetId:d}},!1)};o.loadDataset2(b.dataset,c,a,e)}),o.addClickhandler(function(a){q.show(a),d&&d()})}function l(a){o=j("cesium-viewer",a),o.viewer.scene.imageryLayers.removeAll(),d(h,o,o.addImageryProvider),k(i(),a),o.stopLoading()}function m(){var f,g,l=!1;KR.Util.getLine(a,h.line,function(a){if(p=KR.CesiumUtils.getBounds(a),o=j("cesium-viewer",p),d(h,o,o.addImageryProvider),k(i(),p,function(){h.player&&(l=f.isRunning(),g.pause(),f.stop())}),o.build3DLine(a,function(a){var b=c(a,{color:Cesium.Color.DEEPSKYBLUE,glow:.25});o.viewer.zoomTo(o.viewer.entities.add(b)),o.stopLoading()}),h.player){var m=b(a);o.build3DLine(m,function(a){f=new KR.PathTracer(o.viewer,a,m),f.setPitchCorr(.1),g=new e(f),$("#playpause").removeClass("hidden"),$("#playpause").click(g.toggle)}),q.addCloseCb(function(){l&&g.play()})}})}function n(){h.bbox?l(h.bbox):h.komm?a.getMunicipalityBounds(h.komm,l):h.line?m():alert("Missing parameters!")}h=h||{},h=_.extend({player:!0,limitBounds:!1},h);var o,p,q=KR.CesiumSidebar($("#cesium-sidebar"),{});n()}}(KR); \ No newline at end of file +var KR=this.KR||{};!function(a){"use strict";a.parseError=function(a){if(a.responseJSON){if(a.responseJSON.error)return a.responseJSON.error.join(", ");if(a.responseJSON.status)return a.responseJSON.status}return a.statusText?a.statusText:a.error?a.error.info?a.error.info:a.error.error?a.error.error:a.error:"Unknown error"},a.errorHandler=function(b){var c=$(b);c.find(".close").on("click",function(){c.find(".content").html(""),c.remove()});var d=_.template("
<%= dataset %>: <%= error %>
");return function(b){var e=d({dataset:b.dataset,error:a.parseError(b.error)});c.parent()?c.find(".content").append(e):c.find(".content").html(e),$("body").append(c)}}}(KR);var KR=this.KR||{};KR.Config={contentIcons:{IMAGE:"camera-retro",VIDEO:"file-video-o",SOUND:"music",TEXT:"file-text","default":"file-o"},templates:{}},KR.Config.ImageCaheUrl="http://egbtmre.cloudimg.io",KR.Util=KR.Util||{},function(a){"use strict";function b(a,b){var c=a.lastIndexOf(b);return-1!==c&&c+b.length===a.length}function c(a){return 1e3>a?"0"+a:a}a.iconForContentType=function(a){var b=a.properties.contentType;return _.has(KR.Config.contentIcons,b)?KR.Config.contentIcons[b]:KR.Config.contentIcons["default"]},a.getDatasetTemplate=function(a){var b=$("#"+a+"_template").html();return b?_.template(b):void 0},a.templateForDataset=function(a){return _.has(KR.Config.templates,a)?KR.Config.templates[a]:void 0},a.createStyleString=function(a){return _.map(a,function(a,b){return b+": "+a}).join(";")},a.colorForProvider=function(a,b){var c=!0;"hex"!==b&&(c=!1);var d={properties:{datasetId:a}};return KR.Style.colorForFeature(d,c,!0)},a.featureClick=function(a){return function(b,c,d){c.on("click",function(c){d&&d.toPoint&&d.toPoint.stopPolyClick&&!c.parent||(d?a.showFeature(b,d.template,d.getFeatureData):a.showFeature(b))})}},a.getTemplateForFeature=function(a,b){if(b){if(b.datasets){var c=_.find(b.datasets,function(b){return b._knreise_id===a.properties.datasetID});return c.template}return b.template}},a.clusterClick=function(b){return function(c,d){c.on("clusterclick",function(c){var e=_.map(c.layer.getAllChildMarkers(),function(b){var c=b.feature;return d&&!c.template&&(c.template=a.getTemplateForFeature(c,d)),c}),f=_.extend({},{template:null,getFeatureData:null,noListThreshold:null},d);b.showFeatures(e,f.template,f.getFeatureData,f.noListThreshold)})}},a.hexToRgba=function(a,b){b=b||1;var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);if(!c)return 0;var d={r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)};return"rgba("+d.r+","+d.g+","+d.b+","+b+")"},a.filterByBbox=function(a,b){var c=turf.featurecollection([turf.bboxPolygon(KR.Util.splitBbox(b))]);return turf.within(a,c)},a.getDatasetId=function(a){return"norvegiana"===a.dataset.api?a.dataset.dataset:"wikipedia"===a.dataset.api?"wikipedia":a.id?a.id:KR.Util.stamp(a)},"undefined"!=typeof L&&(L.latLngBounds.fromBBoxArray=function(a){return new L.LatLngBounds(new L.LatLng(a[1],a[0]),new L.LatLng(a[3],a[2]))},L.latLngBounds.fromBBoxString=function(a){return L.latLngBounds.fromBBoxArray(KR.Util.splitBbox(a))},L.rectangle.fromBounds=function(a){return L.rectangle([a.getSouthWest(),a.getNorthEast()])}),a.parseQueryString=function(a){var b=decodeURIComponent(a);if(""!==b)return _.reduce(b.replace("?","").split("&"),function(a,b){b=b.split("=");var c=b[1];return"true"===c?c=!0:"false"===c&&(c=!1),a[b[0]]=c,a},{})};var d=_.template("<%= totalt %> (<%= menn %> menn, <%= kvinner %> kvinner)");a.formatPersons=function(a){var b=a.split("-");return b.length<2?a:d({totalt:b[0],menn:b[1],kvinner:b[2]})},a.getBaseLayer=function(a,b){var c={nib:KR.getNibLayer,hist:function(a){a(L.tileLayer.wms("http://wms.geonorge.no/skwms1/wms.historiskekart",{layers:"historiskekart",format:"image/png",attribution:"Kartverket"}))}};if(_.has(c,a))c[a](b);else{var d=navigator.userAgent.indexOf("Safari")>-1,e=!d;b(L.tileLayer.kartverket(a,{useCache:e}))}},a.getLine=function(a,c,d){if(_.isFunction(c))return void c(function(a){d(a)});var e;if(0===c.indexOf("utno/")){var f=c.replace("utno/","");e={api:"utno",id:f,type:"gpx"}}else 0===c.indexOf("http")&&(b(c,"kml")?e={api:"kml",url:c}:b(c,"gpx")||-1!==c.indexOf("http://ut.no/tur/")?e={api:"gpx",url:c}:b(c,"geojson")&&(e={api:"geojson",url:c}));e?a.getData(e,function(a){d(a)}):alert("Kunne ikke laste linjegeometri")},a.messageDisplayer=function(a){return function(b,c){var d=$(a);d.find(".close").on("click",function(){d.find(".content").html(""),d.remove()}),d.addClass("alert-"+b),d.find(".content").html(c),$("body").append(d)}},a.mostlyCoveringMunicipality=function(a,b,c){var d="ST_MakeEnvelope("+b+", 4326)",e="SELECT komm FROM kommuner WHERE ST_Intersects(the_geom, "+d+")ORDER BY st_area(st_intersection(the_geom, "+d+")) DESC LIMIT 1",f={api:"cartodb",query:e,mapper:function(a){return a.rows[0].komm}};a.getData(f,c)},a.sparqlBbox=function(a,b,d,e,f){KR.Util.mostlyCoveringMunicipality(a,d,function(d){b.kommune=c(d),a.getData(b,e,f)})},a.distanceAndSort=function(a,b){var c=_.map(a.features,function(a){return a.properties.distance=turf.distance(b,a),a});return turf.featurecollection(c.sort(function(a,b){return a.properties.distanceb.properties.distance?1:0}))},a.round=function(a,b){_.isUndefined(b)&&(b=2);var c=Math.pow(10,b);return Math.round(a*c)/c};var e=_.template("#<%= zoom %>/<%= lat %>/<%= lon %>");a.getPositionHash=function(b,c,d){return e({zoom:d,lat:a.round(b,4),lon:a.round(c,4)})},a.WORLD={type:"Feature",geometry:{type:"Polygon",coordinates:[[[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]]}},a.createMap=function(b,c){c=c||{};var d=L.map(b,{minZoom:c.minZoom||3,maxZoom:c.maxZoom||18,maxBounds:L.geoJson(a.WORLD).getBounds()}),e=c.layer||"norges_grunnkart_graatone";return _.isString(e)?KR.Util.getBaseLayer(e,function(a){a.addTo(d)}):e.addTo(d),d},a.setupSidebar=function(a,b){b=b||{};var c=KR.Util.getDatasetTemplate("popup"),d=_.template($("#list_item_template").html()),e=_.template($("#marker_template").html()),f=_.template($("#thumbnail_template").html()),g=_.template($("#footer_template").html()),h=_.extend({},{position:"left",template:c,listElementTemplate:d,markerTemplate:e,thumbnailTemplate:f,footerTemplate:g},b),i=L.Knreise.Control.sidebar("sidebar",h);return a.addControl(i),i},a.distanceAndBearing=function(a,b){return{distance:1e3*turf.distance(a,b,"kilometers"),bearing:turf.bearing(a,b)}};var f=_.template("<%= service %>/s/crop/<%= width %>x<%= height %>/<%= image %>");a.getImageCache=function(a,b,c){return KR.Config.ImageCaheUrl?f({service:KR.Config.ImageCaheUrl,width:b,height:c,image:a}):a},a.isInIframe=function(){try{return window.self!==window.top}catch(a){return!0}}}(KR.Util);var KR=this.KR||{};KR.Style={},function(a){"use strict";function b(a){var b=a.properties.vernef_id;return _.find(p,function(a){return-1!==a.ids.indexOf(b)})}function c(a){return u[a]||"blue"}function d(a,b,c,d){return _.isFunction(a[b])?d?a[b]():a[b](c):a[b]}function e(a,b,c){return c?d(a,"fillcolor",b,!0):d(a,"fillcolor",b)}function f(a,b){return a.bordercolor?d(a,"bordercolor",b):e(a,b)}function g(b){return a.groups[b]}function h(b){var c;return b.properties&&b.properties.groupId?g(b.properties.groupId):(b.properties&&b.properties.datasetId&&(c=a.getDatasetStyle(b.properties.datasetId)),c?c:_.extend({},s))}function i(a,b,c){return c=c||9,{radius:c,weight:1,opacity:1,color:a,fillColor:b,fillOpacity:.4}}function j(a,b,c){return L.circleMarker(a,i(b,c))}function k(a){return L.Knreise.icon({markerColor:a})}function l(a,b,c){var d="";return a.properties&&a.properties.title&&(d=a.properties.title),L.marker(b,{icon:c,title:d})}function m(a,b,c){if(a.properties&&a.properties.thumbnail){var d={"border-color":b,"background-image":"url("+a.properties.thumbnail+")"};c&&(d["border-width"]="3px");var e=KR.Util.getImageCache(a.properties.thumbnail,50,50),f='
';return new L.DivIcon({className:"leaflet-marker-circle",html:f,iconSize:[50,50],iconAnchor:[25,25]})}}function n(a,b,c){var d=_.filter(a,function(a){return a.feature.properties.thumbnail});if(d.length){var e;_.isArray(b)&&(e=_.rest(b),b=b[0]);var f=KR.Util.getImageCache(d[0].feature.properties.thumbnail,50,50),g={"border-color":b,"background-image":"url("+f+");"};e&&(g["box-shadow"]=_.map(e,function(a,b){var c=2*(b+1);return"0 0 0 "+c+"px "+a}).join(",")+";"),c&&(g["border-width"]="3px");var h='
'+a.length+"";return new L.DivIcon({className:"leaflet-marker-photo",html:h,iconSize:[60,60],iconAnchor:[30,30]})}}function o(a,b){var c=KR.Util.hexToRgba(b,.4);return new L.DivIcon({className:"leaflet-marker-circle",html:'
'+a.length+"",iconSize:[20,20],iconAnchor:[10,10]})}var p={landskapsvern:{ids:["LVO","LVOD","LVOP","LVOPD","BV","MAV","P","GVS","MIV","NM","BVV","PO","DO","D"],style:{fillColor:"#d8cb7a",color:"#9c8f1b"}},nasjonalpark:{ids:["NP","NPS"],style:{fillColor:"#7f9aac",color:"#b3a721"}},naturreservat:{ids:["NR","NRS"],style:{fillColor:"#ef9874",color:"#ef9873"}}},q="#72B026",r="#38A9DC",s={fillcolor:r,circle:!1,thumbnail:!0},t={difo:"Digitalt fortalt",Kulturminnesok:"Kulturminnesok",DiMu:"DigitaltMuseum",MUSIT:"Musit",Artsdatabanken:"Artsdatabanken",wikipedia:"wikipedia",riksantikvaren:"riksantikvaren"};a.datasets={"Digitalt fortalt":{fillcolor:"#F69730",circle:!1,thumbnail:!0},Kulturminnesok:{fillcolor:"#436978",circle:!1,thumbnail:!1},DigitaltMuseum:{fillcolor:"#436978",circle:!1,thumbnail:!1},Musit:{fillcolor:"#436978",circle:!1,thumbnail:!1},Artsdatabanken:{fillcolor:"#5B396B",thumbnail:!1,circle:!0},riksantikvaren:{fillcolor:"#436978",circle:!1,thumbnail:!0},verneomraader:{fillcolor:function(a){if(a){var c=b(a);if(c)return c.style.fillColor}return"#009300"},bordercolor:function(a){if(a){var c=b(a);if(c)return c.style.color}return"#009300"},thumbnail:!1,circle:!0},wikipedia:{fillcolor:"#D14020",thumbnail:!0}},a.groups={},a.getDatasetStyle=function(b){var c=a.datasets[t[b]];return c||(c=a.datasets[b]),c},a.setDatasetStyle=function(b,c){_.has(t,b)||(t[b]=b);var d=a.getDatasetStyle(b);d||(d=s),a.datasets[t[b]]=_.extend({},d,c)};var u={"#F69730":"orange","#38A9DC":"blue","#A23336":"darkred","#72B026":"green","#436978":"cadetblue","#5B396B":"darkpurple","#728224":"darkgreen","#D252B9":"purple","#D14020":"red"};a.getClusterIcon=function(a,b){var c,d=a.getAllChildMarkers(),f=_.uniq(_.map(d,function(a){return a.feature.properties.groupId})),i=h(d[0].feature);if(_.compact(f).length>1){var j=_.compact(f);j.length>1&&(c=_.map(j,_.compose(e,g)))}else c=e(i,d[0].feature);if(b&&(c=q),i.thumbnail){var k=n(d,c,b);if(k)return k}return o(d,c)},a.getIcon=function(a,b){var c=h(a),d=b?q:e(c,a),g=b?q:f(c,a);if(c.thumbnail){var j=m(a,g,b);if(j)return j}return c.circle?i(g,d,c.radius):k(d)},a.getMarker=function(b,c){var d=h(b);if(d.thumbnail){var g=m(b,f(d,b),!1);if(g)return l(b,c,g)}return d.circle?j(c,f(d,b),e(d,b)):l(b,c,a.getIcon(b,!1))},a.colorForFeature=function(a,b,d){var f=h(a);return f?b?e(f,a,d):c(e(f,a)):void 0},a.colorForDataset=function(b,d,f){var g,i;return b.grouped?(g=a.groups[KR.Util.stamp(b)],g||(i=b.datasets[0].extras.datasetId)):(i||(i=b.extras.datasetId),g=h({properties:{datasetId:i}})),g?d?e(g,null,f):c(e(g,null)):void 0},a.getPathStyle=function(a,b){b=b||!1;var c=h(a),d=e(c,a),g=f(c,a);return{weight:1,color:g,fillColor:d,clickable:b,opacity:.8,fillOpacity:.4}},a.getPathStyleForGroup=function(b,c){var d={properties:{groupId:b}};return a.getPathStyle(d,c)}}(KR.Style);var KR=this.KR||{};KR.PathTracer=function(a,b,c){"use strict";function d(b,c){Cesium.Math.setRandomNumberSeed(3),a.clock.startTime=b.clone(),a.clock.stopTime=c.clone(),a.clock.currentTime=b.clone(),a.clock.clockRange=Cesium.ClockRange.LOOP_STOP,a.clock.multiplier=l,a.clock.shouldAnimate=!1}function e(b,c,d){var e=a.entities.add({availability:new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({start:b,stop:c})]),position:d,orientation:new Cesium.VelocityOrientationProperty(d)});return e}function f(a,b,c){b=b.reverse(),c.geometry.coordinates=c.geometry.coordinates.reverse();var d=0,e=turf.point(c.geometry.coordinates[0]),f=new Cesium.SampledPositionProperty;return _.each(b,function(b,g){var h=turf.point(c.geometry.coordinates[g]);d+=1e3*turf.distance(e,h,"kilometers"),e=h;var i=Cesium.JulianDate.addSeconds(a,d/k,new Cesium.JulianDate),j=new Cesium.Cartesian3(b.x,b.y,b.z+2);f.addSample(i,j)}),f}function g(b){a.clock.onTick.addEventListener(function(c){if(m){var d=Cesium.Cartesian3,e=b.position.getValue(c.currentTime,new d),f=b.position.getValue(Cesium.JulianDate.addSeconds(c.currentTime,1/60,new Cesium.JulianDate),new d),g=d.subtract(f,e,new d);d.normalize(g,g);var h=new d,i=new d,j=new d;Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(e,h),d.cross({x:0,y:0,z:1},h,i),d.cross(h,i,j);var k=new d;k.x=d.dot(g,i),k.y=d.dot(g,j),k.z=d.dot(g,h);var l=new d(0,0,1),o=new d(1,0,0),p=new d(0,1,0),q=d.dot(k,o),r=d.dot(k,p),s=d.dot(k,l),t=Math.atan2(q,r),u=Math.asin(s);t+=0*Math.PI,u+=-20/180*Math.PI;var v=800,w=new Cesium.HeadingPitchRange(t,u+n,v);a.scene.camera.lookAt(b.position.getValue(c.currentTime),w)}})}function h(){var h=c.features[0],i=1e3*turf.lineDistance(h,"kilometers"),j=i/k,l=Cesium.JulianDate.fromDate(new Date(2015,2,25,16)),m=Cesium.JulianDate.addSeconds(l,j,new Cesium.JulianDate);d(l,m);var n=f(l,b,h),o=e(l,m,n);o.position.setInterpolationOptions({interpolationDegree:5,interpolationAlgorithm:Cesium.LagrangePolynomialApproximation}),a.trackedEntity=void 0,g(o)}function i(){m=!0,a.clock.shouldAnimate=!0}function j(){m=!1,a.clock.shouldAnimate=!1}var k=1.4,l=35,m=!1,n=0;return h(),{start:i,stop:j,isRunning:function(){return m},setPitchCorr:function(a){n=a}}};var KR=this.KR||{};KR.CesiumMap=function(a,b,c){"use strict";function d(a){return a=a||"//assets.agi.com/stk-terrain/world",new Cesium.CesiumTerrainProvider({url:a,requestVertexNormals:!0,requestWaterMask:!1})}function e(a){var b,c=s.scene.camera;c.moveEnd.addEventListener(function(){var d=Cesium.Ellipsoid.WGS84.cartesianToCartographic(c.position),e=!Cesium.Rectangle.contains(a,d);e&&b&&(c.position=b),b=c.position.clone()})}function f(){s=new Cesium.Viewer(a,t.cesiumViewerOpts);var b=s.scene;b.imageryLayers.removeAll();var f=b.globe;t.cesiumViewerOpts.enableLighting&&(f.enableLighting=!0),f.depthTestAgainstTerrain=!0,s.terrainProvider=d(t.cesiumViewerOpts.terrainUrl);var g,h=b.camera;if(c){c=KR.Util.splitBbox(c);var i=Cesium.Ellipsoid.WGS84;g=new Cesium.Rectangle(Cesium.Math.toRadians(c[0]),Cesium.Math.toRadians(c[1]),Cesium.Math.toRadians(c[2]),Cesium.Math.toRadians(c[3])),h.viewRectangle(g,i)}g&&t.cesiumViewerOpts.limitBounds&&e(g)}function g(a,b){var c=a.features[0].geometry.coordinates,d=_.map(c,function(a){return new Cesium.Cartographic.fromDegrees(a[0],a[1])}),e=Cesium.sampleTerrain(s.terrainProvider,14,d);Cesium.when(e,function(a){b(Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(a))})}function h(a){return _.map(a,function(a,b){return b+"="+a}).join("&")}function i(a){return new Cesium.UrlTemplateImageryProvider({url:a})}function j(a,b,c){var d={SERVICE:"WMTS",REQUEST:"GetTile",TILEROW:"{TileRow}",TILECOL:"{TileCol}",STYLE:"{Style}",LAYER:b};return{url:a+"?"+h(_.extend({},d,c||{})),layer:"",tileMatrixSetID:""}}function k(a,b,c){var d={style:"default",version:"1.0.0",format:"image/png",maximumLevel:19};return new Cesium.WebMapTileServiceImageryProvider(_.extend({},d,j(a,b,c)))}function l(a,b){return new Cesium.WebMapServiceImageryProvider({url:a,layers:b,parameters:{service:"WMS",version:"1.1.1",request:"GetMap",styles:"",format:"image/png",transparent:!0}})}function m(a){return _.map(a,function(a){var b={position:Cesium.Cartesian3.fromDegrees(a.pos.lng,a.pos.lat,a.pos.height||80),billboard:{image:a.icon,show:!0,heightReference:2,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,scale:1},label:{text:a.text,font:"14pt monospace",style:Cesium.LabelStyle.FILL_AND_OUTLINE,outlineWidth:2,verticalOrigin:Cesium.VerticalOrigin.BOTTOM,pixelOffset:new Cesium.Cartesian2(0,32)},properties:a.properties};return s.entities.add(b),b})}function n(a,b,c,d){c=c||14;var e=[];d||(d=0),_.each(a.features,function(a){var b=a.geometry.coordinates;e.push(new Cesium.Cartographic.fromDegrees(b[0],b[1]))});var f=Cesium.sampleTerrain(s.terrainProvider,c,e);Cesium.when(f,function(c){var e=c;_.each(a.features,function(a,b){var c=e[b];a.geometry.coordinates=[Cesium.Math.toDegrees(c.longitude),Cesium.Math.toDegrees(c.latitude),c.height+d]}),b(a)})}function o(a){var b=new Cesium.EntityCollection,c=new Cesium.ScreenSpaceEventHandler(s.scene.canvas);c.setInputAction(function(c){var d=s.scene.drillPick(c.position);if(Cesium.defined(d)){b.removeAll();var e=_.map(d,function(a){var c=a.id;return b.add(c),c.properties});e.length&&a(e)}},Cesium.ScreenSpaceEventType.LEFT_CLICK)}function p(a,b,c,d){c.getBbox(a,b,function(a){n(a,function(a){var b=Cesium.GeoJsonDataSource.load(a);d(b)})},function(a){d()})}function q(a,b,c,d){c.getBbox(a,b,function(a){_.each(a.features,function(a){a.properties=_.extend(a.properties,d)}),n(a,function(a){var b=_.map(a.features,function(a){var b=a.properties["marker-color"]||"blue";return{pos:{lat:a.geometry.coordinates[1],lng:a.geometry.coordinates[0],height:a.geometry.coordinates[2]},icon:"../common/img/markers/"+b+".png",properties:a.properties}});m(b)})},function(b){console.warn("could not load dataset",a)})}function r(){$(".spinner-wrapper").delay(2e3).fadeOut({duration:200})}Cesium.BingMapsApi.defaultKey="";var s,t={cesiumViewerOpts:_.extend({timeline:!1,baseLayerPicker:!1,geocoder:!1,enableLighting:!0,infoBox:!1,animation:!1,orderIndependentTranslucency:!1},b||{})};return f(),{viewer:s,addMarkers:m,build3DLine:g,addClickhandler:o,loadDataset:p,loadDataset2:q,stopLoading:r,getTiles:i,getWmts:k,getWms:l,addImageryProvider:function(a){s.imageryLayers.addImageryProvider(a)}}},KR.CesiumUtils={},KR.CesiumUtils.getBounds=function(a){"use strict";var b=turf.envelope(a),c=b.geometry.coordinates[0];return c[0].concat(c[2]).join(",")};var KR=this.KR||{};KR.CesiumSidebar=function(a,b,c,d){"use strict";function e(a){o.html(a)}function f(a){return{properties:a,template:a.template}}function g(a){p.showFeature(f(a))}function h(a){var b=_.map(a,f);p.showFeatures(b)}function i(b){a.show("slide",{direction:"left"},100),1===b.length?g(b[0]):h(b)}function j(){a.hide("slide",{direction:"left"},100),e(""),q&&q()}d=d||{footerTemplate:_.template($("#footer_template").html()),listElementTemplate:_.template($("#list_item_template").html()),markerTemplate:_.template($("#marker_template").html()),thumbnailTemplate:_.template($("#thumbnail_template").html())};var k=$('');a.append(k);var l=$('
');k.append(l);var m=$('×');l.append(m);var n=$("");l.append(n);var o=$('');k.append(o);var p=new KR.SidebarContent(k,o,n,d),q=c;return a.addClass("knreise-sidebar"),m.click(j),{show:i,addCloseCb:function(a){q=a}}};var KR=this.KR||{};!function(){"use strict";function a(){function a(a){if(d&&d.userPosition){var b=turf.point([d.userPosition.lng,d.userPosition.lat]),c=KR.Util.distanceAndBearing(b,a),e=c.distance;return e=1e3>e?KR.Util.round(e,0)+" Meter":KR.Util.round(e/1e3,2)+" Kilometer",{dist:e,rot:c.bearing-45}}}function b(){if(e&&d&&d.userPosition&&f){g&&g.remove();var b=e.find("h3").eq(0),c=a(f);g=$(h({distanceBearing:c})),b.length?b.after(g):e.prepend(g)}}function c(a,c){e=c,f=a,b()}var d,e,f,g,h=_.template($("#user_position_template").html());return{setMap:function(a){d=a,d.on("locationChange",b)},selectFeature:c}}KR.SidebarContent=function(b,c,d,e){function f(a){c.html(a)}function g(a){a&&c.swipe({swipe:function(){},allowPageScroll:"vertical"}).off("swipeLeft").on("swipeLeft",function(){a.next&&a.next()}).off("swipeRight").on("swipeRight",function(){a.prev&&a.prev()})}function h(a,b,c,d,f,g){var i;b>0&&(i=function(e){e&&e.preventDefault(),b-=1,a=f[b];var i=h(a,b,c,d,f,g);j(a,c,d,i,b,f.length)});var l;return b"),p+='',f(p),void i(a,function(b){b.properties=_.extend(a.properties,b.properties),j(b,h,null,k,n,o)})}h=h||a.template||KR.Util.templateForDataset(a.properties.dataset)||l;var q=a.properties.images;_.isArray(q)&&(q=q[0]),a.properties.images||(a.properties.images=null),a.properties.allProps&&a.properties.allProps.europeana_rights?a.properties.license=a.properties.allProps.europeana_rights[0]:a.properties.license=null;var r=a.properties.color||KR.Style.colorForFeature(a,!0,!0),p=''+a.properties.provider+"";if(p+=h(_.extend({image:null},a.properties)),e.footerTemplate&&a.properties.link&&(p+=e.footerTemplate(a.properties)),p=$(["
",p,"
"].join(" ")),KR.Util.isInIframe()&&p.find("a").attr("target","_blank"),m.selectFeature(a,p),f(p),g(k),b.find(".prev-next-arrows").remove(),d.html(""),k){var s=$('');d.append(s),s.click(k.close);var t=n+1;d.append($('
'+t+" av "+o+"
"));var u=$('');b.append(u),k.prev&&u.click(k.prev).addClass("active");var v=$('');b.append(v),k.next&&v.click(k.next).addClass("active")}var w=c.find(".media-container");w.length&&KR.MediaCarousel.SetupMediaCarousel(w),"undefined"!=typeof audiojs&&audiojs.createAll(),c.scrollTop(0)}function k(a,b,f,g,j){g=void 0===g?e.noListThreshold:g;var k=a.length<=g;if(k&&j!==!0){var l=a[0];c.html("");var m=h(l,0,b,f,a);return void this.showFeature(l,b,f,m,0,a.length)}var n=$(''+a.length+"");d.html(n);var o=_.chain(a).groupBy(function(a){return a.properties.provider}).map(function(c,d){var e=$("
"),g=$('
'),h=_.map(c,function(c){var d=_.findIndex(a,function(a){return a===c});return i(c,d,b,f,a)},this);return g.append(h),e.append('
'+d+"
"),e.append(g),e}).value();c.html(o),c.scrollTop(0)}var l=KR.Util.getDatasetTemplate("popup"),m=new a;return c=$(c),b=$(b),d=$(d),{showFeature:j,showFeatures:k,setMap:function(a){m.setMap(a)}}}}();var KR=this.KR||{};KR.DatasetLoader=function(a,b,c,d,e,f){"use strict";function g(a){var b=KR.Util.stamp(a);return function(c){return c&&c.features.length?(_.each(c.features,function(c){c.properties.datasetID=b,_.has(a,"circle")&&(c.properties.circle=a.circle),_.has(a,"provider")&&(c.properties.provider=a.provider),_.has(a,"extras")&&(c.properties=_.extend(c.properties,a.extras)),c.properties.feedbackForm=a.feedbackForm,_.has(a,"mappings")&&_.each(a.mappings,function(a,b){c.properties[b]=c.properties[a]}),c.template=KR.Util.getTemplateForFeature(c,a)}),c):c}}function h(a){var b=_.reduce(_.without(_.keys(a),"datasets"),function(b,c){return"style"!==c&&(b[c]=a[c]),b},{});if(a.style){b.extras=b.extras||{};var c=KR.Util.stamp(a);b.extras.groupId=c,KR.Style.groups[c]=a.style}return a.datasets=_.map(a.datasets,function(a){return _.extend({},b,a)}),a}function i(a,b){var c={dataset:b,onEachFeature:function(a,c){A&&A(a,c,b)}};return b.style&&(c.style=b.style),L.Knreise.geoJson(a,c)}function j(a,b){a.clearLayers();var c=_.reduce(b,function(a,b){return a.concat(b.toGeoJSON().features)},[]);a.addData(KR.Util.createFeatureCollection(c)),a.fire("dataAdded")}function k(a,c){a.clearLayers();var d=_.reduce(c,function(a,c){return c.setMap(b),a.concat(c.getLayers())},[]);a.addLayers(d)}function l(a,b){a.on("hide",function(){b(!0)}),a.on("show",function(){b(!0)})}function m(a,b){var c;e?c=i(null,a):a.cluster?(c=new L.Knreise.MarkerClusterGroup({dataset:a,maxClusterRadius:f}).addTo(b),z&&z(c,a)):c=i(null,a).addTo(b);var d=!0;return a.minFeatures&&(d=!1),c.enabled=d,c}function n(a,b){a.enabled!==b&&(a.enabled=b,a.fire("changeEnabled"))}function o(a){if(a.datasets&&!a.grouped){var b=_.filter(a.datasets,function(a){return a.visible}).length;return b>0}return a.visible}function p(a){return a.minZoom&&b.getZoom()b&&b>=f&&c("up"),b>=d&&f>b&&c("down")})},n=function(a){return _.find(b.getLayers(),function(b){return b.feature.properties.id===a})},o=function(a){return _.find(d.getLayers(),function(b){return b.feature.properties.lok===a})},p=function(a,b){var c=n(a.properties.lok);c&&c.fire("click")},q=function(a){return L.geoJson(null,{onEachFeature:function(b,c){a.extras&&a.extras.groupId?c.setStyle(KR.Style.getPathStyleForGroup(a.extras.groupId)):(b.properties.datasetId=a.id,c.setStyle(KR.Style.getPathStyle(b,!0))),c.on("click",function(){p(b,c)})}}).addTo(c)},r=function(){},s=function(){_.each(d.getLayers(),function(a){a.setStyle(KR.Style.getPathStyle(a.feature,!0))})},t=function(a){s();var b=a.layer.feature.properties.id,c=o(b);c&&(c.setStyle({weight:1,color:"#436978",fillColor:"#72B026",clickable:!0,opacity:.8,fillOpacity:.4}),e&&(console.log("loadEnkeltminner"),e(a.layer.feature)))},u=function(a,b){c.sidebar&&c.sidebar.showFeature(a,b.enkeltminner.template||KR.Util.getDatasetTemplate("ra_enkeltminne"))},v=function(b){_.has(b,"enkeltminner")||(b.enkeltminner={});var d=b.enkeltminner.style||{color:"#fff",weight:1,fillColor:"#B942D0"};f=L.geoJson(null,{onEachFeature:function(a,c){a.properties.provider=b.enkeltminner.provider||"Enkeltminne",a.properties.color=b.enkeltminner.sidebarColor||"#B942D0",c.on("click",function(){u(a,b)})},style:function(){return d}}).addTo(c),e=function(b){var c={api:"kulturminnedataSparql",type:"enkeltminner",lokalitet:b.properties.id};a.getData(c,function(a){f.clearLayers(),f.addData(a)})}},w=function(a,e,f){b=f,c=a,b.on("hide",j),b.on("show",k),d=q(e),m(c,13,l),c.on("zoomend",r),c.on("layerDeselect",s),b.on("click",t),_.has(e,"showEnkeltminner")&&(i=e.showEnkeltminner),i&&v(e)},x=function(a){d.addData(a);var b=_.chain(a.features).map(function(a){return a.properties.lok}).uniq().value();h&&_.each(b,function(a){n(a)}),g=g.concat(b)},y=function(b,c,d){if(d){var e=_.chain(d).map(function(a){return a.properties.id}).filter(function(a){return-1===g.indexOf(a)}).value();if(e.length){var f={api:"kulturminnedataSparql",type:"lokalitetpoly",lokalitet:e};a.getData(f,x)}}};return{loadKulturminnePoly:y,initKulturminnePoly:w}}}(KR.Config);var KR=this.KR||{};KR.Config=KR.Config||{},function(a){"use strict";a.getDatasetList=function(b,c,d){var e=a.getKulturminneFunctions(b);c&&3===c.length&&(c="0"+c);var f={difo:{name:"Digitalt fortalt",dataset:{dataset:"difo",api:"norvegiana"},cluster:!0,template:KR.Util.getDatasetTemplate("digitalt_fortalt"),noListThreshold:1/0,description:"Kulturrådets tjeneste for personlige fortellinger fra kulturinstitusjoner og privatpersoner.",allowTopic:!0,feedbackForm:!0,isStatic:!1},verneomr:{id:"verneomraader",dataset:{api:"cartodb",table:"naturvernomrader_utm33_2",columns:["iid","omradenavn","vernef_id","verneform"]},provider:"Naturbase",name:"Verneområder",template:KR.Util.getDatasetTemplate("verneomraader"),getFeatureData:function(a,c){b.getItem({api:"norvegiana",id:"kulturnett_Naturbase_"+a.properties.iid +},c)},toPoint:{showAlways:!0,stopPolyClick:!0,minSize:20},minZoom:10,cluster:!1,description:"Nasjonalparker og andre naturvernområder - ca. 2700 i hele landet."},artobs:{name:"Artsobservasjoner",hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"Artsdatabanken"},cluster:!1,description:"Artsobservasjoner fra Artsdatabanken",template:KR.Util.getDatasetTemplate("popup")},folketelling:{name:"Folketelling 1910",provider:"Folketelling 1910",dataset:{api:"folketelling",dataset:"property"},isStatic:!1,minZoom:14,template:KR.Util.getDatasetTemplate("folketelling"),getFeatureData:function(a,c){b.getData({api:"folketelling",type:"propertyData",propertyId:a.properties.efid},function(b){a.properties=b.properties,a.properties.provider="Folketelling 1910",c(a)})},mappings:{title:"gaardsnavn_gateadr"},noListThreshold:0,description:"Personer og eiendommer fra folketellingen 1910"},ark_hist:{grouped:!0,name:"Arkeologi og historie",datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}}],description:"Data fra Universitetsmuseene, Digitalt museum og Riksantikvaren"},jernbane:{id:"jernbane",dataset:{api:"jernbanemuseet"},provider:"Jernbanemuseet",name:"Jernbanemuseet",hideFromGenerator:!0,template:KR.Util.getDatasetTemplate("jernbanemuseet"),getFeatureData:function(a,c){b.getItem({api:"jernbanemuseet",id:a.properties.id},c)},isStatic:!0,bbox:!1,description:"Jernbanemuseet"},arkeologi:{grouped:!0,name:"Arkeologi",style:{fillcolor:"#436978",circle:!1,thumbnail:!0},datasets:[{name:"MUSIT",provider:"Universitetsmuseene",dataset:{api:"norvegiana",dataset:"MUSIT"},template:KR.Util.getDatasetTemplate("musit")},{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER regex(?loccatlabel, "^Arkeologisk", "i") .',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}}],description:"Arkeologidata fra Universitetsmuseene og Riksantikvaren"},historie:{grouped:!0,name:"Historie",style:{fillcolor:"#D252B9",circle:!1,thumbnail:!0},datasets:[{id:"riksantikvaren",name:"Riksantikvaren",provider:"Riksantikvaren",dataset:{filter:'FILTER (!regex(?loccatlabel, "^Arkeologisk", "i"))',api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:5,callback:e.loadKulturminnePoly}},{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"-dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Industrimuseum"},isStatic:!1,bbox:!0},{dataset:{api:"norvegiana",dataset:"Foto-SF"},isStatic:!1,bbox:!1,template:KR.Util.getDatasetTemplate("foto_sf")},{dataset:{api:"norvegiana",dataset:"Kystreise"},isStatic:!0,bbox:!1}],description:"Historie og kulturminner fra Riksantikvaren og Digitalt museum "},kunst:{grouped:!0,name:"Kunst",style:{fillcolor:"#72B026",circle:!1,thumbnail:!0},datasets:[{name:"DiMu",dataset:{api:"norvegiana",dataset:"DiMu",query:"dc_subject_facet:Kunst"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1}],description:"Kunstdata fra Digitalt museum "},wikipedia:{name:"Wikipedia",provider:"Wikipedia",dataset:{api:"wikipedia"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra bokmålswikipedia"},wikipediaNN:{name:"Wikipedia Nynorsk",provider:"Wikipedia Nynorsk",dataset:{api:"wikipediaNN"},style:{thumbnail:!0},minZoom:13,template:KR.Util.getDatasetTemplate("wikipedia"),description:"Stedfestede artikler fra nynorskwikipedia"},lokalwiki:{id:"lokalwiki",name:"Lokalhistoriewiki",hideFromGenerator:!1,provider:"Lokalhistoriewiki",dataset:{api:"lokalhistoriewiki"},style:{thumbnail:!0},minZoom:13,bbox:!0,isStatic:!1,description:"Stedfestede artikler fra lokalhistoriewiki.no"},riksantikvaren:{id:"riksantikvaren",name:"Kulturminnesøk",hideFromGenerator:!1,provider:"Riksantikvaren",dataset:{api:"kulturminnedataSparql",kommune:c,fylke:d},template:KR.Util.getDatasetTemplate("ra_sparql"),bbox:!1,isStatic:!0,init:e.initKulturminnePoly,loadWhenLessThan:{count:10,callback:e.loadKulturminnePoly},description:"Data fra Riksantikvarens kulturminnesøk"},brukerminner:{name:"Kulturminnesøk - brukerregistreringer",hideFromGenerator:!1,provider:"riksantikvaren",dataset:{api:"kulturminnedata",layer:2,getExtraData:!0,extraDataLayer:6,matchId:"KulturminnesokID"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Brukerregistrerte data fra Riksantikvarens kulturminnesøk",template:KR.Util.getDatasetTemplate("brukerminne")},groruddalen:{name:"Byantikvaren Oslo - Groruddalen",hideFromGenerator:!0,provider:"Byantikvaren i Oslo",dataset:{api:"cartodb",table:"byantikvaren_oslo_groruddalen"},bbox:!1,isStatic:!1,style:{thumbnail:!0},template:KR.Util.getDatasetTemplate("byantikvaren_oslo"),description:"Byantikvarens Groruddalsatlas"},norgerundt:{name:"Norge Rundt",hideFromGenerator:!0,provider:"NRK",dataset:{api:"cartodb",table:"nrk_norge_rundt"},bbox:!1,isStatic:!1,style:{thumbnail:!0},description:"Stedfestede innslag fra Norge Rundt"},dimu:{name:"Digitalt Museum",hideFromGenerator:!1,provider:"dimu",dataset:{dataset:"DiMu",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Digitalt Museum",allowTopic:!0,feedbackForm:!0},musit:{name:"Universitetsmuseene",hideFromGenerator:!1,provider:"Universitetsmuseene",dataset:{dataset:"MUSIT",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Universitetsmuseene",allowTopic:!0,feedbackForm:!0},industrimuseum:{name:"Industrimuseum",hideFromGenerator:!1,provider:"Industrimuseum",dataset:{dataset:"Industrimuseum",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Industrimuseum",allowTopic:!0,feedbackForm:!0},kystreise:{name:"Kystreise",hideFromGenerator:!1,provider:"Kystreise",dataset:{dataset:"Kystreise",api:"norvegiana"},cluster:!0,isStatic:!1,style:{thumbnail:!0},description:"Alle stedfestede data fra Kystreise",allowTopic:!0,feedbackForm:!0},dimufoto:{hideFromGenerator:!0,dataset:{api:"norvegiana",dataset:"DiMu",query:"europeana_type_facet:IMAGE"},template:KR.Util.getDatasetTemplate("digitalt_museum"),isStatic:!1,style:{thumbnail:!0},noListThreshold:1/0},kulturminnesok_flickr:{name:"Kulturminnesøk",dataset_name_override:"Kulturminnesøk",provider:"Kulturminnesøk Flickr",hideFromGenerator:!0,dataset:{api:"flickr",group_id:"1426230@N24"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!0,style:{thumbnail:!0},description:"Bilder fra Kulturminnesøks Flickr-gruppe"},riksarkivet:{name:"Riksarkivet",dataset_name_override:"Riksarkivet",provider:"riksarkivet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_archives_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Riksarkivets Flickr-konto"},nasjonalbiblioteket:{name:"Nasjonalbiblioteket",dataset_name_override:"Nasjonalbiblioteket",provider:"nasjonalbiblioteket",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"national_library_of_norway"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalbibliotekets Flickr-konto"},oslobyarkiv:{name:"Oslo Byarkiv",dataset_name_override:"Oslo Byarkiv",provider:"oslobyarkiv",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"byarkiv"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Oslo byarkiv sin Flickr-konto"},nasjonalmuseet:{name:"Nasjonalmuseet",dataset_name_override:"Nasjonalmuseet",provider:"nasjonalmuseet",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nasjonalmuseet"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Nasjonalmuseet sin Flickr-konto"},nve:{name:"NVE",dataset_name_override:"NVE",provider:"nve",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"nve",accuracy:"6"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra NVE Flickr-konto"},vestfoldmuseene:{name:"Vestfoldmuseene",dataset_name_override:"Vestfoldmuseene",provider:"Vestfoldmuseene",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"vestfoldmuseene",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Vestfoldmuseene sin Flickr-konto"},perspektivet:{name:"Perspektivet Museum",dataset_name_override:"Perspektivet Museum",provider:"Perspektivet Museum",hideFromGenerator:!0,dataset:{api:"flickr",user_id:"perspektivetmuseum",accuracy:"1"},template:KR.Util.getDatasetTemplate("flickr"),isStatic:!1,style:{thumbnail:!0},description:"Bilder fra Perspektivet Museum sin Flickr-konto"}};if(!c&&!d){var g={bbox:!0,minZoom:12,isStatic:!1,bboxFunc:KR.Util.sparqlBbox};_.extend(f.riksantikvaren,g),_.extend(f.ark_hist.datasets[2],g),_.extend(f.arkeologi.datasets[1],g),_.extend(f.historie.datasets[0],g)}return f},a.getDatasets=function(b,c,d,e){var f=a.getDatasetList(c,d,e);return _.chain(b).map(function(a){var b;if(a.indexOf(":")>-1){var c=a.split(":");a=c[0],b=c[1]}if(_.has(f,a)){var d=f[a];return b&&"norvegiana"===d.dataset.api&&(d.dataset.query="dc_subject_text:"+b),d}}).compact().value()}}(KR.Config);var KR=this.KR||{};!function(a){"use strict";function b(a){return turf.featurecollection([turf.simplify(a.features[0],.001,!1)])}function c(a,b){return b=b||{},{polyline:{positions:a,width:5,material:new Cesium.PolylineOutlineMaterialProperty({color:Cesium.Color.ORANGE,outlineWidth:2,outlineColor:Cesium.Color.BLACK})}}}function d(a,b,c){var d=a.layer||"topo2";if("norges_grunnkart_graatone"===d&&(d="norges_grunnkart"),"hist"===d)c(b.getWms("http://wms.geonorge.no/skwms1/wms.historiskekart","historiskekart"));else if("nib"===d){var e="http://knreise.no/nib/?type=token";KR.Util.sendRequest(e,null,function(a){c(0!==a.indexOf("**")?b.getWmts("http://crossorigin.me/http://gatekeeper1.geonorge.no/BaatGatekeeper/gk/gk.nibcache_wmts","NiB",{TILEMATRIXSET:"EPSG:900913",TILEMATRIX:"EPSG:900913:{TileMatrix}",FORMAT:"image/jpeg",GKT:a}):b.getTiles("http://www.webatlas.no/wacloud/servicerepository/combine.aspx?X={x}&Y={y}&Z={z}&layers=TMS_WEBATLAS_STANDARD:1"))})}else c(b.getWmts("http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts",d,{TILEMATRIXSET:"EPSG:3857",TILEMATRIX:"EPSG:3857:{TileMatrix}",FORMAT:"image/png"}))}function e(a){function b(){e.find(".glyphicon").removeClass("glyphicon-play").addClass("glyphicon-pause"),a.start()}function c(){e.find(".glyphicon").removeClass("glyphicon-pause").addClass("glyphicon-play"),a.stop()}function d(){a.isRunning()?c():b()}var e=$("#playpause");return{play:b,pause:c,toggle:d}}var f={animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!1,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,navigationHelpButton:!0,navigationInstructionsInitiallyVisible:!1,orderIndependentTranslucency:!1};a.setupMap3d=function(a,g,h){function i(){var b=KR.Config.getDatasets(g,a);return _.chain(b).map(function(a){return a.datasets?a.datasets:a}).flatten().filter(function(a){return _.has(a.dataset,"kommune")&&_.isUndefined(a.dataset.kommune)?!1:!0}).value()}function j(a,b){return new KR.CesiumMap(a,_.extend(f,{limitBounds:h.limitBounds,terrainUrl:h.terrainUrl,enableLighting:h.enableLighting}),b)}function k(b,c,d){_.each(b,function(b){var d=KR.Util.getDatasetId(b),e={template:b.template,datasetId:d,"marker-color":KR.Style.colorForFeature({properties:{datasetId:d}},!1)};o.loadDataset2(b.dataset,c,a,e)}),o.addClickhandler(function(a){q.show(a),d&&d()})}function l(a){o=j("cesium-viewer",a),o.viewer.scene.imageryLayers.removeAll(),d(h,o,o.addImageryProvider),k(i(),a),o.stopLoading()}function m(){var f,g,l=!1;KR.Util.getLine(a,h.line,function(a){if(p=KR.CesiumUtils.getBounds(a),o=j("cesium-viewer",p),d(h,o,o.addImageryProvider),k(i(),p,function(){h.player&&(l=f.isRunning(),g.pause(),f.stop())}),o.build3DLine(a,function(a){var b=c(a,{color:Cesium.Color.DEEPSKYBLUE,glow:.25});o.viewer.zoomTo(o.viewer.entities.add(b)),o.stopLoading()}),h.player){var m=b(a);o.build3DLine(m,function(a){f=new KR.PathTracer(o.viewer,a,m),f.setPitchCorr(.1),g=new e(f),$("#playpause").removeClass("hidden"),$("#playpause").click(g.toggle)}),q.addCloseCb(function(){l&&g.play()})}})}function n(){h.bbox?l(h.bbox):h.komm?a.getMunicipalityBounds(h.komm,l):h.line?m():alert("Missing parameters!")}h=h||{},h=_.extend({player:!0,limitBounds:!1},h);var o,p,q=KR.CesiumSidebar($("#cesium-sidebar"),{});n()}}(KR); \ No newline at end of file