dojo.require("esri.map"); dojo.require("esri.tasks.query"); dojo.require("esri.tasks.identify"); dojo.require("dijit.Dialog"); dojo.require("dojo.parser"); dojo.require("dijit.layout.AccordionContainer"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.layout.TabContainer"); dojo.require("dijit.TitlePane"); // needed? dojo.require("dijit.form.HorizontalSlider"); // needed? dojo.require("dijit.form.Button"); dojo.require("dijits.overview.OverviewMap"); dojo.require("dojo.date"); // for print clocking dojo.require("dojo.date.stamp"); // for print clocking //dojo.registerModulePath ("geo", "../../src/geo/dijit"); dojo.require("geo.tasks.printer"); dojo.require("geo.tasks.PrintServiceParameters"); dojo.require("geo.tasks.PrintServiceResults"); var layer, map, visible, lodsArr, resizeTimer, overviewMapDijit, geometrySvc, idConnect, tb, bizSvc, baseSvc, baseMap, layerStore, printer; hostName = document.location.host; // get services relative to test/prod environment bizSvc = []; baseSvc = []; layerStore = []; lodsArr = []; /* +++++++++ CONFIGURATION +++++++++ */ // set to TRUE for verbose firebugging internalDebug = true; bizSvc.push("ext_div"); layerStore["ext_div"] = []; if (internalDebug) { console.log('STATUS: access config db for svc ext_div'); } layerStore["ext_div"].push({name_ags: "namenbuch_flurnamen", name_sde: "GEO.GEO_00100857001", name_alias: "Flurnamen (Luzerner Namenbuch)", vis: 0, vis_min: 350000, vis_max: 2250 }); layerStore["ext_div"].push({name_ags: "bistum_pfarreien", name_sde: "GEO.GEO_00100823001", name_alias: "Bistum: Pfarreien", vis: 1, vis_min: 350000, vis_max: 250 }); layerStore["ext_div"].push({name_ags: "bistum_pastoralraeume", name_sde: "GEO.GEO_00100823001", name_alias: "Bistum: Pastoralräume", vis: 1, vis_min: 350000, vis_max: 250 }); layerStore["ext_div"].push({name_ags: "bistum_dekanate", name_sde: "GEO.GEO_00100823001", name_alias: "Bistum: Dekanate", vis: 0, vis_min: 350000, vis_max: 50000 }); layerStore["ext_div"].push({name_ags: "bund_kbs_oev", name_sde: "GEO.GEO_00101011001", name_alias: "Kataster der belasteten Standorte - Öff. Verkehr (KbS ÖV)", vis: 0, vis_min: 350000, vis_max: 250 }); bizSvc.push("int_query"); layerStore["int_query"] = []; if (internalDebug) { console.log('STATUS: access config db for svc int_query'); } layerStore["int_query"].push({name_ags: "adr_geopost", name_sde: "GEO.GEO_00100006001", name_alias: "Geopost-Adressen", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_gebaeudeeingaenge", name_sde: "GO.GEO_00100617001 ", name_alias: "AV Gebäudeeingänge", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_bb_txt", name_sde: "GEO.GEO_00100032002", name_alias: "Beschrift. Bodenbedeck.", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_sr", name_sde: "GEO.GEO_00100355001", name_alias: "Baurechte", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_prz", name_sde: "GEO.GEO_00100030001", name_alias: "Parzellen / Grundstücke", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_prz_proj", name_sde: "GEO.GEO_00100001001", name_alias: "Parzellen / Grundstücke, projektiert", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_sr_proj ", name_sde: "GEO.GEO_00100001001", name_alias: "Baurechte, projektiert", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "gem_up10", name_sde: "GEO.GEO_00100001001", name_alias: "Gemeinden ab ÜP10", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_ortschaftsnamen", name_sde: "GEO.GEO_00100001001", name_alias: "AAV Orthscftasnamen: Beeschriftung", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_lokale_namen_fl", name_sde: "GEO.GEO_00100605001 ", name_alias: "AV Lokale Namen", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "flurnamen", name_sde: "GEO.GEO_00100048001", name_alias: "Flurnamen", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "swissnames_25", name_sde: "GEO.GEO_00100915001", name_alias: "swissnames_25", vis: 0, vis_min: 350000, vis_max: 250 }); layerStore["int_query"].push({name_ags: "av_eob_txt", name_sde: "GEO.GEO_00100001001", name_alias: "AV Einzelobjekte: Beschriftung (Gebäudenummern)", vis: 0, vis_min: 350000, vis_max: 250 }); // initialize app function init(){ var initialExtent, m1, m2, m3, m4; //define proxy page (e.g. for complex measuring) esri.config.defaults.io.proxyUrl = "../../../src/sec/proxy.ashx"; esri.config.defaults.io.alwaysUseProxy = false; // preloader dojo.byId('loaderInner').innerHTML += " fertig."; setTimeout(function hideLoader(){ var loader = dojo.byId('loader'); dojo.fadeOut({ node: loader, duration:500, onEnd: function(){ loader.style.display = "none"; } }).play(); }, 250); lodsArr = [ {"level" : 0, "resolution" : 92.6043518753704, "scale" : 350000}, {"level" : 1, "resolution" : 52.9167725002117, "scale" : 200000}, {"level" : 2, "resolution" : 26.4583862501058, "scale" : 100000}, {"level" : 3, "resolution" : 13.2291931250529, "scale" : 50000}, {"level" : 4, "resolution" : 6.61459656252646, "scale" : 25000}, {"level" : 5, "resolution" : 4.63021759376852, "scale" : 17500}, {"level" : 6, "resolution" : 2.64583862501058, "scale" : 10000}]; // CUSTOM. shorten scale-list dojo.byId('scale').options.length = 0; dojo.forEach (lodsArr.reverse(), function(LOD, i) { dojo.byId('scale').options[i] = new Option(LOD.scale, LOD.scale, false, false); }); // set initial extent (set crazy large to be on top LOD). Leave default and set actual extent below. initialExtent = new esri.geometry.Extent(600000, 150000, 700000, 250000, new esri.SpatialReference({ wkid: 21781 })); map = new esri.Map("map", { extent: initialExtent, lods: lodsArr } ); geometrySvc = new esri.tasks.GeometryService("http://svc.geo.lu.ch/main0/rest/services/Utilities/Geometry/GeometryServer"); var basis_rastch = new esri.layers.ArcGISTiledMapServiceLayer("http://svc.geo.lu.ch/main0/rest/services/basis/basis_rastch/MapServer", {id: "basis_rastch", visible: false }); basis_rastch.setOpacity(.3); map.addLayer(basis_rastch, true); if (internalDebug) { console.log("STATUS: added base svc 'basis_rastch' (trans: TRANS_APP_BISTUM) from host PROD (all svc)"); } var ext_div = new esri.layers.ArcGISDynamicMapServiceLayer("http://svc.geo.lu.ch/main0/rest/services/ext/ext_div/MapServer", {id: "ext_div", visible: true }); ext_div.setOpacity(.8); map.addLayer(ext_div); if (internalDebug) { console.log("STATUS: added biz svc 'ext_div' (trans: TRANS_APP_BISTUM)from host PROD (all svc)"); } var int_query = new esri.layers.ArcGISDynamicMapServiceLayer("http://svc.geo.lu.ch/main0/rest/services/basis/int_query/MapServer", {id: "int_query", visible: true }); int_query.setOpacity(1); map.addLayer(int_query); if (internalDebug) { console.log("STATUS: added biz svc 'int_query' (trans: TRANS_APP_BISTUM)from host PROD (all svc)"); } // connect measuring behaviour dojo.connect(geometrySvc, "onLengthsComplete", outputMeasureDistance); dojo.connect(geometrySvc, "onAreasAndLengthsComplete", outputAreaAndLength); // connect behaviours to map dojo.connect(map, 'onLoad', function(theMap){ // map resizing dojo.connect(dijit.byId('main'), 'resize', function(){ resizeMap(); }); // mouse coord display dojo.connect(map, "onMouseMove", showCoordinates); dojo.connect(map, "onMouseDrag", showCoordinates); // extent dependent behaviour dojo.connect(map, "onExtentChange", function(extent, delta, outLevelChange, outLod) { if(outLevelChange){ dojo.byId("scale").value = outLod.scale; pScaleSelector = dojo.byId('print_sel_PSC'); lastValue = pScaleSelector.options[pScaleSelector.options.length - 1].value; if (outLod.scale < lastValue) { dojo.byId("print_sel_PSC").value = outLod.scale; } else { dojo.byId("print_sel_PSC").value = lastValue; } if ((dojo.byId('printPreview')) && (dojo.byId('printPreview').style.display == "block")) { togglePrintPreview(); } dojo.byId("visualScale").src = "../../src/img/scale_" + outLod.scale + ".gif"; setOutOfRangeVis(outLod.scale); // in agsTOC } }); // identify idConnect = dojo.connect(map, "onClick", doIdentify); mapLoaded(); }); // make legend and id panes moveable --> must stay here !! m1 = new dojo.dnd.Moveable("mapLegend"); m2 = new dojo.dnd.Moveable("idResults"); m3 = new dojo.dnd.Moveable("mapMeasure"); m4 = new dojo.dnd.Moveable("printPreview"); // init the printer dijit //initPrinter(); } // do stuff AFTER whole map has loaded... function mapLoaded() { var distGraphic, graphic, infoPanel1HTML, infoPanel1, infoPanel2HTML, infoPanel2; // set document title document.title = 'Bistum Basel - Geoportal Kanton Luzern'; // start up overview map (Dijit) overviewMapDijit = new dijits.overview.OverviewMap({ map: map, id: "overview-map", width: 238, height: 180, expandFactor: 1.5, color: "#FF0000", opacity: 0.55 }, dojo.byId("ovMap") ); overviewMapDijit.startup(); // CUSTOM: define TOC // syntax layers: service, shortname, name, sdename, node, metadata available?, identifyable? // syntax groups: id, name, node, expanded?, virtual? //addGroup("GWS", "Bistum", "tocRoot", true, false); //addLayer("ext_div", "bistum_pfarreien", "Pfarreien", "GEO.GEO_00100823001", "tocRoot", true, true); addLayer("ext_div", "bistum_dekanate", "Dekanate", "GEO_00100823001", "tocRoot", true, true); addLayer("ext_div", "bistum_pastoralraeume", "Pastoralräume", "GEO_00100823001", "tocRoot", true, true); // build TOC (agsTOC) initTOC(); // init measure //on draw end add graphic and get distance/area (agsMap.js) tb = new esri.toolbars.Draw(map); dojo.connect(tb, "onDrawEnd", processMeasurement); // FOCUS: set start extent by param or defaults (agsMap.js) setStartExtent(parseFloat(2629500), parseFloat(1232226), 350000); // BFS/PARCEL: highlight query results on startup (Params: agsMap.js, Func: agsQuery.js) setStartQueries(); // BASEMAP: set startup base map (agsMap.js) setBaseMap("basis_rastch"); // CUSTOM: set on-map info panel // infoPanel1HTML ='Hinweis: Karteninhalte werden zurzeit revidiert (insb. Gemeinden Hochdorf, Rickenbach und Kriens). Im Baugebiet ist die Zulässigkeit von Erdwärmesonden beim uwe, Fachbereich Erdwärmenutzung, abzuklären (041 228 60 60, uwe@lu.ch).'; // infoPanel1 = dojo.create("div", { id: "InfoPanel1" }, "info"); // dojo.attr("InfoPanel1", { "class": "infoPanel", "innerHTML": infoPanel1HTML }); //INIT PRINTER printer = new geo.tasks.PrintService(printOptions); dojo.connect(dojo.byId('printBtn'), 'onclick', startPrint); // in mapPrint.js.php dojo.connect(printer, "onPrintingComplete", this, "_showPrintout"); dojo.connect(printer, "onError", this, "_onPrintError"); // custom print settings (overrides mapPrintConfig102.js ) printOptions.print.department = ""; printOptions.print.section = ""; // resize to prevent IE display glitch dijit.byId("container").resize(); // enforce visibility toggling between layer dekanate and layer pastoralräume manageExclusiveLayerVisibility(); // Printing: hide print preview and scale selector dojo.byId("print_PSC_container").style.display = "none"; dojo.byId("printPreview_container").style.display = "none"; dojo.byId("ovmap_panel").style.display = "none"; dojo.byId("print_panel").style.display = "none"; } function manageExclusiveLayerVisibility() { // query the layer-image-elements (those img elements that contain the string "chkbox" in the id) dojo.query('img[id*="chkbox"]').forEach(function(imgNode){ dojo.connect(imgNode, "onclick", null, function(img) { // only if the clicked layer checkbox was set visible, then the other layer needs to be set invisible //if (imgNode.classList.contains("on")) { if (imgNode.className.indexOf("on")!=-1) { if (imgNode.id.indexOf("dekanate")!=-1) { var targetNode = getImageNodeByIdPart("pastoral"); targetNode.forEach(function(node) { //if (node.classList.contains("on")) { if (node.className.indexOf("on")!=-1) { toggleLayer(node); } }); } if (imgNode.id.indexOf("pastoral")!=-1) { var targetNode = getImageNodeByIdPart("dekanate"); targetNode.forEach(function(node) { //if (node.classList.contains("on")) { if (node.className.indexOf("on")!=-1) { toggleLayer(node); } }); } } }); }); } // search an img element where the id contains a defined string (idPart) function getImageNodeByIdPart (idPart) { var nodeObj = dojo.query('img[id*=' + idPart + ']').at(0); return nodeObj.at(0); } function initPrinter () { var cfg = this.config.print; var printer = new geo.dijit.Printer({ map: this.map, layerStore: this.layerStore, options: cfg, lods: cfg.scales, scaleLabelText: "Mst. 1:" }, dom.byId(cfg.div)); printer.startup(); dojo.connect(this.map, "onExtentChange", this, function (extent, delta, outLevelChange, outLod) { var handler = dojo.connect(this.map, "onUpdateEnd", this, function () { dojo.disconnect(handler); if (outLod == null) { if (this._internalDebug) console.log("STATUS: no level of detail - WMS Base layers"); var scale = this.mapExtentToScale(); outLod = this.getMapLevel(scale); } printer.updatePrintScale(outLod); printer.updatePrintPreview(outLevelChange); }); }); var tabs = registry.byId("sidebarAcc"); tabs.watch("selectedChildWidget", function (name, oval, nval) { if (nval.id == "printMap_panel") { printer.isVisible = true; } else { printer.isVisible = false; } printer.setPreviewVisibility(); }); return printer; } // It all starts here. dojo.addOnLoad(init);