{"version":3,"file":"uppsala.arcgismap.localplan.min.js","names":["define","Map","MapView","FeatureLayer","TileLayer","Basemap","MapViewConfigurator","localplan","init","mapId","backgroundMapUrl","queryValue","layers","initMap","map","ukBasemapLayer","url","ukBaseMap","baseLayers","basemap","initBasemap","view","container","center","zoom","navigation","getNavigation","forEach","item","index","arcgisLayer","query","layer","hasResult","result","undefined","features","length","zoomToLayer","q","createQuery","outSpatialReference","spatialReference","queryExtent","then","response","goTo","extent","when","definitionExpression","queryFeatures","initLayer","add"],"sources":["arcgis/uppsala.arcgismap.localplan.js"],"mappings":"AACAA,OAAO,CACH,WACA,qBACA,2BACA,wBACA,eACA,yBACD,SAAUC,EAAKC,EAASC,EAAcC,EAAWC,EAASC,GACzD,IAAIC,EAAY,CAGZC,KAAM,SAAcC,EAAOC,EAAkBC,EAAYC,GACrDL,EAAUM,QAAQJ,EAAOC,EAAkBC,EAAYC,EAC3D,EAQAC,QAAS,SAAUJ,EAAOC,EAAkBC,EAAYC,GAEpD,IAAIE,EAkBJ,SAAqBJ,GAGjB,IAAIK,EAAiB,IAAIX,EAAU,CAC/BY,IAAKN,IAGLO,EAAY,IAAIZ,EAAQ,CACxBa,WAAY,CAACH,KAEbD,EAAM,IAAIb,EAAI,CACdkB,QAASF,IAGb,OAAOH,CACX,CAjCUM,CAAYV,GAElBW,EAAO,IAAInB,EAAQ,CACnBoB,UAAWb,EACXK,IAAKA,EACLS,OAAQ,CAAC,SAAW,WACpBC,KAAM,GAENC,WAAYnB,EAAoBoB,kBAGpCpB,EAAoBE,KAAKa,GAEzBT,EAAOe,SAAQ,SAAUC,EAAMC,GAC3B,IAAIC,EAqBR,SAAmBd,EAAKe,EAAOpB,GAE3B,IAAIqB,EAAQ,IAAI7B,EAAa,CACzBa,IAAKA,IAYT,SAASiB,EAAUC,QAEAC,IAAXD,GAAwBA,EAAOE,SAASC,OAAS,GACjDC,EAAYN,EACpB,CAEA,SAASM,EAAYN,GAEjB,IAAIO,EAAIP,EAAMQ,cAEd,OADAD,EAAEE,oBAAsBpB,EAAKqB,iBACtBV,EAAMW,YAAYJ,GAAGK,MAAK,SAAUC,GACvCxB,EAAKyB,KAAKD,EAASE,OACvB,GACJ,CAEA,OAzBAf,EAAMgB,MAAK,WAEP,GAAmB,KAAfrC,EAAmB,CACnBqB,EAAMiB,qBAAuB,IAAMlB,EAAQ,IAAMpB,EAAa,KAE9D,IAAI4B,EAAIP,EAAMQ,cACd,OAAOR,EAAMkB,cAAcX,EAC/B,CACJ,IAAGK,KAAKX,GAiBDD,CACX,CApDsBmB,CAAUvB,EAAKZ,IAAKY,EAAKG,MAAOpB,GAClDG,EAAIsC,IAAItB,EACZ,GAoDJ,GAGJ,OAAOvB,CACX","ignoreList":[],"sourcesContent":["\ndefine([\n \"esri/Map\",\n \"esri/views/MapView\",\n \"esri/layers/FeatureLayer\",\n \"esri/layers/TileLayer\",\n \"esri/Basemap\",\n \"behaviorconfigurator\",\n], function (Map, MapView, FeatureLayer, TileLayer, Basemap, MapViewConfigurator) {\n var localplan = {\n\n //init method ensures functional cookies are accepted and initializes the map if they are\n init: function init(mapId, backgroundMapUrl, queryValue, layers) {\n localplan.initMap(mapId, backgroundMapUrl, queryValue, layers);\n },\n\n // layers is defined as in this example\n // [{url: \"https://...\", query: \"DiarieNummer =\"}, ...]\n\n // basemaps: \n // https://kartor.uppsala.se/ags02/rest/services/aBakgrund/UaBakgrundskarta_fargad/MapServer\n // https://dzgisweb01.uppsala.se/ags02/rest/services/aBakgrund/UaBakgrundskarta_gratonad/MapServer\n initMap: function (mapId, backgroundMapUrl, queryValue, layers) {\n\n var map = initBasemap(backgroundMapUrl);\n\n var view = new MapView({\n container: mapId, // Reference to the DOM node that will contain the view\n map: map,\n center: [17.637770, 59.858948], // long, lat \n zoom: 10,\n\n navigation: MapViewConfigurator.getNavigation()\n });\n\n MapViewConfigurator.init(view);\n\n layers.forEach(function (item, index) {\n var arcgisLayer = initLayer(item.url, item.query, queryValue);\n map.add(arcgisLayer);\n });\n\n function initBasemap(backgroundMapUrl) {\n\n // gets the uk basemap\n var ukBasemapLayer = new TileLayer({\n url: backgroundMapUrl\n });\n\n var ukBaseMap = new Basemap({\n baseLayers: [ukBasemapLayer]\n });\n var map = new Map({\n basemap: ukBaseMap\n });\n\n return map;\n }\n\n function initLayer(url, query, queryValue) {\n\n var layer = new FeatureLayer({\n url: url\n });\n layer.when(function () {\n // filter the features\n if (queryValue !== '') {\n layer.definitionExpression = \"(\" + query + \"'\" + queryValue + \"')\";\n\n var q = layer.createQuery();\n return layer.queryFeatures(q);\n }\n }).then(hasResult);\n\n function hasResult(result) {\n // if there are any features, zoom to the layer\n if (result !== undefined && result.features.length > 0)\n zoomToLayer(layer);\n }\n\n function zoomToLayer(layer) {\n // we ask for the extent (view box) of current layer and then zoom to it\n var q = layer.createQuery();\n q.outSpatialReference = view.spatialReference;\n return layer.queryExtent(q).then(function (response) {\n view.goTo(response.extent);\n });\n }\n\n return layer;\n }\n\n }\n };\n\n return localplan;\n});\n\n"]}