var pageLoaded = 0; var newMinx = 0; var newMiny = 0; var newMaxx = 0; var newMaxy = 0; var boxMinx = 0; var boxMiny = 0; var boxMaxx = 0; var boxMaxy = 0; var cdArrayX = new Array(); var cdArrayY = new Array(); var mapClickAsRecenter = true; var mapBoxAsZoom = true; var allowRubberband = true; var allowMapClick = true; var state = "zoomIn"; // zoomOut, pan // Global vars to save mouse position var mouseX=0; var mouseY=0; var x1=0; var y1=0; var x2=0; var y2=0; var zminx=0; var zmaxx=0; var zmaxy=0; var zminy=0; var mapX = 0; var mapY = 0; var zoomBoxWidth = 1; var sfsType=''; var sfsVar=''; var digUrl=''; var digType=''; var digitizeUrl = ''; //URL kan spesifiserast til målfil var digitizeType = ''; //Innsetting av ny geometri eller oppdatering //SEARCHLITE var state = "zoom"; // "pan" var zooming=false; var panning=false; var identifying=false; var measuring=false; var measuringarea=false; var drawing=false; var bottomBorderHeight = 0; // setup test for Nav 4.0 var isIE = false; var isNav = (navigator.appName.indexOf("Netscape")>=0); var isNav4 = false; var isIE4 = false; var is5up = false; var isMac = false; var isWin = false; if (isNav) { if (parseFloat(navigator.appVersion)<5) { isNav4=true; //alert("Netscape 4.x or older"); } else { is5up = true; } } else { isIE4=true; isIE=true; if (navigator.appVersion.indexOf("MSIE 5")>0) { isIE4 = false; is5up = true; //alert("IE5"); } } if (navigator.userAgent.indexOf("Win") >= 0) isWin = true; else isMac = true; //*********************************************** //***************** FUNCTIONS ******************* //*********************************************** // check for mouseup function chkMouseUp(e) { if (zooming || panning || identifying || measuring || measuringarea || drawing) { if (mouseX<0) mouseX = 0; if (mouseX>iWidth) mouseX = iWidth; if (mouseY<0) mouseY = 0; if (mouseY>iHeight) mouseY = iHeight; mapTool(e); } } function customMapBox(_newMinx, _newMiny, _newMaxx, _newMaxy) { } function customMapClick(_newX, _newY) { } function getImageXY(e) { //if (document.layers) { if (isNav) { mouseX=e.pageX; mouseY=e.pageY; } else { mouseX=event.clientX + document.body.scrollLeft; mouseY=event.clientY + document.body.scrollTop; } // subtract offsets from page left and right mouseX = mouseX-hspc; mouseY = mouseY-vspc; } // convert mouse click xy's into map coordinates function getMapXY(xIn,yIn) { mouseX = xIn; var pixelX = (maxx-minx) / iWidth; mapX = parseFloat(pixelX * mouseX) + parseFloat(minx); mouseY = iHeight - yIn; var pixelY = (maxy-miny) / iHeight; mapY = parseFloat(pixelY * mouseY) + parseFloat(miny); } // get the coords at mouse position function getMouse(e) { getImageXY(e); if (zooming || identifying) { if (mouseX<0) mouseX = 0; if (mouseX>iWidth) mouseX = iWidth; if (mouseY<0) mouseY = 0; if (mouseY>iHeight-bottomBorderHeight) mouseY = iHeight-bottomBorderHeight; x2=mouseX; y2=mouseY; setClip(); return false; } else if (panning) { x2=mouseX; y2=mouseY; panMouse(); return false; } else if (measuring) { x2=mouseX; y2=mouseY; if (x2 > x1) { tmpWidth = x2 - x1; } else { tmpWidth = x1 - x2; } if (y2 > y1) { tmpHeight = y2 - y1; } else { tmpHeight = y1 - y2; } cdArrayX.push(x2); cdArrayY.push(y2); //vi må gå gjennom alle punkt som er teikna var totalLength = 0; for (var i = 0; i < cdArrayX.length; i++) { if (cdArrayX.length > 1) { if (i > 0) { if (cdArrayX[i] > cdArrayX[i-1]) { tmpWidth = cdArrayX[i] - cdArrayX[i-1]; } else { tmpWidth = cdArrayX[i-1] - cdArrayX[i]; } if (cdArrayY[i] > cdArrayY[i-1]) { tmpHeight = cdArrayY[i] - cdArrayY[i-1]; } else { tmpHeight = cdArrayY[i-1] - cdArrayY[i]; } //total lengde på linje teikna i kartet totalLength += (Math.round((Math.sqrt(Math.pow(tmpWidth,2) + Math.pow(tmpHeight,2)) * ((maxx-minx)/iWidth))) / 1000); //runde av tal kilometer til 2 desimalar var rlength = 3; if (totalLength > 8191 && totalLength < 10485) { totalLength = totalLength-5000; var newtotalLength = Math.round(totalLength*Math.pow(10,rlength))/Math.pow(10,rlength); } else { var newtotalLength = Math.round(totalLength*Math.pow(10,rlength))/Math.pow(10,rlength); } } } } cdArrayX.pop(); cdArrayY.pop(); //skriv ut resultat til statuslinja window.status = "Distance: " + newtotalLength + " km"; //dersom skjema finst i result ramme så skiv vi resultat til skjema if (parent.result.document.measure.measureResult){ parent.result.document.measure.measureResult.value = newtotalLength + " km"; } panMeasure(); return false; } else if (measuringarea) { x2=mouseX; y2=mouseY; if (x2 > x1) { tmpWidth = x2 - x1; } else { tmpWidth = x1 - x2; } if (y2 > y1) { tmpHeight = y2 - y1; } else { tmpHeight = y1 - y2; } panMeasureArea(); return false; } else if (drawing) { x2=mouseX; y2=mouseY; if (x2 > x1) { tmpWidth = x2 - x1; } else { tmpWidth = x1 - x2; } if (y2 > y1) { tmpHeight = y2 - y1; } else { tmpHeight = y1 - y2; } panDrawing(); return false; } else { return true; } return true; } function hideZoomBox() { hideLayer("zoomBoxTop"); hideLayer("zoomBoxLeft"); hideLayer("zoomBoxRight"); hideLayer("zoomBoxBottom"); } // perform appropriate action with mapTool function mapTool (e) { getImageXY(e); //START FANGAR OPP HØGREKLIKK var rightclick; if (!e) { var e = window.event; } if (e.which) { rightclick = (e.which == 3); } else if (e.button) { rightclick = (e.button == 2); } if (rightclick == true) { //går til rightClickMenu modus setState('rightClickMenu'); //slettar gamle menyelemet hideMenus(); //slår av standard høgreklikkmeny document.oncontextmenu=new Function("return false"); //viser høgreklikkmenymeny showRightClickMenu(e); return false; } //SLUTT FANGAR OPP HØGREKLIKK if ((!zooming) && (!panning) && (!identifying) && (!measuring) && (!drawing) && (!measuringarea) && (mouseX >= 0) && (mouseX <= iWidth) && (mouseY >= 0) && (mouseY <= iHeight)) { if (state == "pan") { startPan(e); } else if (state == "identify" || state == "buffer") { startIdentifyBox(e); } else if (state == "drawing") { startDrawing(e); } else if (state == "measure") { startMeasure(e); } else if (state == "measurearea") { startMeasureArea(e); } else { startZoomBox(e); } return false; } else if (zooming) { getMouse(e); stopZoomBox(e); } else if (identifying && ((state == "identify" || state == "buffer") && (mouseX >= 0) && (mouseX <= iWidth) && (mouseY >= 0) && (mouseY <= iHeight))) { getMouse(e); stopZoomBox(e); } else if (drawing) { stopDrawing(e); } else if (measuring) { stopMeasure(e); } else if (measuringarea) { stopMeasureArea(e); } else if (panning) { getMouse(e); stopPan(e); } return true; } // move map image with mouse function panMouse() { var xMove = x2-x1; var yMove = y2-y1; var cLeft = -xMove; var cTop = -yMove; var cRight = iWidth; var cBottom = iHeight; if (xMove>0) { cLeft = 0; cRight = iWidth - xMove; } if (yMove>0) { cTop = 0; cBottom = iHeight - yMove; } clipLayer("theMap",cLeft,cTop,cRight,cBottom); moveLayer("theMap",xMove+hspc,yMove+vspc); return false; } function panMeasure() { var xMove = mouseX-x1; var yMove = mouseY-y1; var cLeft = -xMove; var cTop = -yMove; var cRight = iWidth; var cBottom = iHeight; if (xMove>0) { cLeft = 0; cRight = iWidth - xMove; } if (yMove>0) { cTop = 0; cBottom = iHeight - yMove; } drawMeasureLines(); return false; } function panMeasureArea() { var xMove = mouseX-x1; var yMove = mouseY-y1; var cLeft = -xMove; var cTop = -yMove; var cRight = iWidth; var cBottom = iHeight; if (xMove>0) { cLeft = 0; cRight = iWidth - xMove; } if (yMove>0) { cTop = 0; cBottom = iHeight - yMove; } drawMeasureLines(); return false; } function panDrawing() { var xMove = mouseX-x1; var yMove = mouseY-y1; var cLeft = -xMove; var cTop = -yMove; var cRight = iWidth; var cBottom = iHeight; if (xMove>0) { cLeft = 0; cRight = iWidth - xMove; } if (yMove>0) { cTop = 0; cBottom = iHeight - yMove; } if (sfsType != "point") { drawMeasureLines(); } return false; } // recenter map is the default option function recenter(e) { // otherwise we don't have these layers if (allowRubberband) hideZoomBox(); getMapXY(mouseX,mouseY); if (mapClickAsRecenter) { var widthHalf = Math.abs(maxx - minx) / 2; var heightHalf = Math.abs(maxy - miny) / 2; newMinx = mapX - widthHalf; newMaxx = mapX + widthHalf; newMaxy = mapY + heightHalf; newMiny = mapY - heightHalf; state = 'pan'; refreshMap(); } else customMapClick(mapX,mapY); } function refreshMap() { hideZoomBox(); if (state == "zoomIn"){ showLayer("loadLayer"); window.document.mapcontrol.minX.value = Math.round(newMinx.toString()); window.document.mapcontrol.minY.value = Math.round(newMiny.toString()); window.document.mapcontrol.maxX.value = Math.round(newMaxx.toString()); window.document.mapcontrol.maxY.value = Math.round(newMaxy.toString()); window.document.mapcontrol.command.value = 'zoomInPointRect'; window.document.mapcontrol.submit(); } if (state == "pan"){ showLayer("loadLayer"); window.document.mapcontrol.minX.value = Math.round(newMinx.toString()); window.document.mapcontrol.minY.value = Math.round(newMiny.toString()); window.document.mapcontrol.maxX.value = Math.round(newMaxx.toString()); window.document.mapcontrol.maxY.value = Math.round(newMaxy.toString()); window.document.mapcontrol.command.value = 'pan'; window.document.mapcontrol.submit(); } if (state == "identify") { sendIdentify(Math.round(newMinx.toString()),Math.round(newMiny.toString()),Math.round(newMaxx.toString()),Math.round(newMaxy.toString())); } if (state == "buffer") { //hentar start klikk getMapXY(x1,y1) var tmpMinX1 = mapX; var tmpMaxY1 = mapY; //hentar slutt klikk getMapXY(x2,y2) var tmpMinX2 = mapX; var tmpMaxY2 = mapY; sendBuffer(Math.round(tmpMinX1),Math.round(tmpMaxY2),Math.round(tmpMinX2),Math.round(tmpMaxY1)); } //NOTE: calling hideLayer("loadLayer") causes // the "Loading" image to disappear // immediately. } function sendIdentify(numMapX,numMapY,numMapX2,numMapY2) { var layerId = window.document.mapcontrol.layerId.value; if (layerId == "") { alert("Please activate one theme before searching!"); return false; } eval("getMapXY(mouseX,mouseY);"); //for WMS tema kan berre imageX/Y sendast til getFeature. var tmpImageX; var tmpImageY; if (x1 != x2){ tmpImageX = Math.round((x1 + x2) / 2); }else{ tmpImageX = x1; } if (y1 != y2){ tmpImageY = Math.round((y1 + y2) / 2); }else{ tmpImageY = y1; } var theURL = 'default_searchThemeByMap.aspx?layerId='+layerId+'&minX=' + numMapX + '&minY=' + numMapY + "&maxX=" + numMapX2 + "&maxY=" + numMapY2 + "&mouseX=" + tmpImageX + "&mouseY=" + tmpImageY; parent.result.location.href = theURL; } function sendBuffer(numMapX,numMapY,numMapX2,numMapY2) { //sjekke om brukar har fleire enn 1 tema aktivert var layerId = window.document.mapcontrol.layerId.value; var tmpLayerId = window.document.mapcontrol.layerId.value.split(","); if (tmpLayerId.length > 1 || tmpLayerId[0] == '') { alert("You can only make buffer on 1 theme."); return false; } eval("getMapXY(mouseX,mouseY);"); //sende til bufferside var theURL = 'advanced_buffer01.aspx?layerId='+layerId+'&minX=' + numMapX + '&minY=' + numMapY + "&maxX=" + numMapX2 + "&maxY=" + numMapY2; parent.result.location.href = theURL; } // clip zoom box layer to mouse coords function setClip() { if (x1>x2) { zmaxx=x1; zminx=x2; } else { zminx=x1; zmaxx=x2; } if (y1>y2) { zminy=y1; zmaxy=y2; } else { zmaxy=y1; zminy=y2; } if ((x1 != x2) && (y1 != y2)) { clipLayer("zoomBoxTop",zminx,zmaxy,zmaxx,zmaxy+zoomBoxWidth); clipLayer("zoomBoxLeft",zminx,zmaxy,zminx+zoomBoxWidth,zminy); clipLayer("zoomBoxRight",zmaxx-zoomBoxWidth,zmaxy,zmaxx,zminy); clipLayer("zoomBoxBottom",zminx,zminy-zoomBoxWidth,zmaxx,zminy); } } function setExtent(_minx,_miny,_maxx,_maxy) { minx = _minx; miny = _miny; maxx = _maxx; maxy = _maxy; } function setState(newState, sfsVar, digUrl, digType) { hideLayer("theJSGraphics"); hideLayer("thePrintLayer"); state = newState; if (sfsVar) { sfsType = sfsVar; } else { sfsType = ''; } if (digUrl) { digitizeUrl = digUrl; } else { digitizeUrl = ''; } if (digType) { digitizeType = digType; } else { digitizeType = ''; } // alert (state + " " + sfsType); if (state == "pan") { if (document.getElementById){ // DOM3 = IE5, NS6 document.getElementById('theTop').style.cursor = "move"; document.getElementById('theMap').style.cursor = "move"; }else if (document.layers){ // Netscape 4 document.theTop.style.cursor = "move"; document.theMap.style.cursor = "move"; }else { // IE 4 document.all.theTop.style.cursor = "move"; document.all.theMap.style.cursor = "move"; }} else if (state == "identify" || state == "buffer") { if (document.getElementById){ // DOM3 = IE5, NS6 document.getElementById('theTop').style.cursor = "help"; document.getElementById('theMap').style.cursor = "help"; }else if (document.layers) { // Netscape 4 document.theTop.style.cursor = "help"; document.theMap.style.cursor = "help"; }else { // IE 4 document.all.theTop.style.cursor = "help"; document.all.theMap.style.cursor = "help"; }} else { if (document.getElementById){ // DOM3 = IE5, NS6 document.getElementById('theTop').style.cursor = "crosshair"; document.getElementById('theMap').style.cursor = "crosshair"; document.getElementById('theJSGraphics').style.cursor = "crosshair"; document.getElementById('thePrintLayer').style.cursor = "crosshair"; }else if (document.layers) { // Netscape 4 document.theTop.style.cursor = "crosshair"; document.theMap.style.cursor = "crosshair"; document.theJSGraphics.style.cursor = "crosshair"; document.thePrintLayer.style.cursor = "crosshair"; }else { // IE 4 document.all.theTop.style.cursor = "crosshair"; document.all.theMap.style.cursor = "crosshair"; document.all.theJSGraphics.style.cursor = "crosshair"; document.all.thePrintLayer.style.cursor = "crosshair"; }} if (state == "zoomIn") { mapBoxAsZoom = true; setZoomBoxColor("#ff0000"); setZoomBoxWidth(1); } else if (state == "zoomOut") { mapBoxAsZoom = true; setZoomBoxColor("#ff0000"); setZoomBoxWidth(1); } else if (state == "pan") { } else if (state == "measure") { showLayer("theJSGraphics"); identifying = false; panning = false; zooming = false; } else if (state == "measurearea") { showLayer("theJSGraphics"); } else if (state == "drawing") { showLayer("theJSGraphics"); identifying = false; panning = false; zooming = false; } else if (state == "identify" || state == "buffer") { mapBoxAsZoom = true; setZoomBoxColor("#ff0000"); setZoomBoxWidth(1); } else if (state == "rightClickMenu") { return false; } //set valt verkty setSelectedImage(state, sfsVar, digUrl, digType); } function setZoomBoxColor(color) { setLayerBackgroundColor("zoomBoxTop", color); setLayerBackgroundColor("zoomBoxLeft", color); setLayerBackgroundColor("zoomBoxRight", color); setLayerBackgroundColor("zoomBoxBottom", color); } function setZoomBoxSettings() { // Set up event capture for mouse movement if (isNav && is5up) { document.captureEvents(Event.MOUSEMOVE); document.captureEvents(Event.MOUSEDOWN); document.captureEvents(Event.MOUSEUP); document.captureEvents(Event.DBLCLICK); document.onmousemove = getMouse; document.onmousedown = mapTool; document.onmouseup = chkMouseUp; document.ondblclick = resetMeasureArray; } else if (isNav4) { // otherwise the buttons don't work getLayer("theTop").captureEvents(Event.MOUSEMOVE); getLayer("theTop").captureEvents(Event.MOUSEDOWN); getLayer("theTop").captureEvents(Event.MOUSEUP); getLayer("theTop").captureEvents(Event.DBLCLICK); getLayer("theTop").onmousemove = getMouse; getLayer("theTop").onmousedown = mapTool; getLayer("theTop").onmouseup = chkMouseUp; document.ondblclick = resetMeasureArray; } else { document.onmousemove = getMouse; document.onmousedown = mapTool; document.onmouseup = chkMouseUp; document.ondblclick = resetMeasureArray; } } function resetMeasureArray() { if (state == "measure") { //vi må gå gjennom alle punkt som er teikna var totalLength = 0; for (var i = 0; i < cdArrayX.length; i++) { if (cdArrayX.length > 1) { if (i > 0) { if (cdArrayX[i] > cdArrayX[i-1]) { tmpWidth = cdArrayX[i] - cdArrayX[i-1]; } else { tmpWidth = cdArrayX[i-1] - cdArrayX[i]; } if (cdArrayY[i] > cdArrayY[i-1]) { tmpHeight = cdArrayY[i] - cdArrayY[i-1]; } else { tmpHeight = cdArrayY[i-1] - cdArrayY[i]; } //total lengde på linje teikna i kartet totalLength += (Math.round((Math.sqrt(Math.pow(tmpWidth,2) + Math.pow(tmpHeight,2)) * ((maxx-minx)/iWidth))) / 1000); //runde av tal kilometer til 2 desimalar var rlength = 2; if (totalLength > 8191 && totalLength < 10485) { totalLength = totalLength-5000; var newtotalLength = Math.round(totalLength*Math.pow(10,rlength))/Math.pow(10,rlength); } else { var newtotalLength = Math.round(totalLength*Math.pow(10,rlength))/Math.pow(10,rlength); } window.status = "Distance: " + newtotalLength + " km"; } } } } if (drawing) { returnSFS(cdArrayX,cdArrayY); } cdArrayX.length = 0; cdArrayY.length = 0; if (measuring || measuringarea){ clearCanvas(); } measuringarea = false; measuring = false; drawing = false; return false; } function returnSFS(xArr, yArr) { var sfsObj; if (sfsType == 'polygon' && cdArrayX[cdArrayX.length -1] != cdArrayX[0] && cdArrayX[cdArrayY.length -1] != cdArrayY[0]) { cdArrayX.push(cdArrayX[0]); cdArrayY.push(cdArrayY[0]); sfsObj = sfsType.toUpperCase()+'(('; } else { sfsObj = sfsType.toUpperCase()+'('; } for(i=0;i'); document.writeln(content); document.writeln(''); layer = getLayer(name); layer.width = width; layer.height = height; } else { document.writeln('
'); document.writeln(content); document.writeln('
'); } clipLayer(name, 0, 0, width, height); } // get the layer object called "name" function getLayer(name) { if (isNav4) return(document.layers[name]); else if (isIE4) { if ( eval('document.all.' + name) != null) { layer = eval('document.all.' + name + '.style'); return(layer); } else return(null); } else if (is5up) { var theObj = document.getElementById(name); return theObj.style } else return(null); } // toggle layer to invisible function hideLayer(name) { var layer = getLayer(name); if (layer != null) { if (isNav4) layer.visibility = "hide"; else layer.visibility = "hidden"; } } // move layer to x,y function moveLayer(name, x, y) { var layer = getLayer(name); if (layer != null) { if (isNav4) layer.moveTo(x, y); else if (isIE) { layer.left = x + "px"; layer.top = y + "px"; } else { layer.height = iHeight - y; layer.width = iWidth - x; layer.left = x + "px"; layer.top = y + "px"; } } } // replace layer's content with new content function replaceLayerContent(name, content) { if (isNav4) { var layer = getLayer(name); if (layer != null) { layer.document.open(); layer.document.writeln(content); layer.document.close(); } } else if (isIE) { if (eval("document.all." + name) != null) { content = content.replace(/\'/g,"\\'"); var str = "document.all." + name + ".innerHTML = '" + content + "'"; eval(str); } } } // set layer background color function setLayerBackgroundColor(name, color) { var layer = getLayer(name); if (layer != null) { if (isNav4) layer.bgColor = color; else layer.backgroundColor = color; } } // toggle layer to visible function showLayer(name) { var layer = getLayer(name); if (layer != null) { if (isNav4) layer.visibility = "show"; else layer.visibility = "visible"; } } //*********************************************** //***************** FUNCTIONS ******************* //*********************************************** // Start funskjonar // draws coordinates in statusbar function drawCoordsInStatusBar(e) { if (pageLoaded == 1) { // array med x og y - blir sent til statusbarConvertCoord for konvertering til Lat/Lon arrXY = new Array(2); arrXY[0] = mapX; arrXY[1] = mapY; eval("statusbarConvertCoord(arrXY);"); eval("getImageXY(e);"); eval("getMapXY(mouseX,mouseY);"); var statusBarText = ''; statusBarText += 'Kosovaref01X/Y: ' + Math.round(mapX) + ' ' + '' + Math.round(mapY) + ' '; statusBarText += 'Lat/Lon: ' + arrXY[0] + ' ' + '' + arrXY[1] + ' '; statusBarText += 'Map scale: ' + Math.round((window.document.mapcontrol.zoomScale.value / 100)) * 100; eval("window.status = statusBarText;"); } } // set command function setCommand(command) { if (command=='zoomFullExtent' || command=='zoomIn' || command=='zoomOut'){ showLayer("loadLayer"); window.document.mapcontrol.command.value = command; window.document.mapcontrol.submit(); } if (command=='zoomScale'){ var zoomScale = prompt("Enter map scale:", ""); if (zoomScale) { showLayer("loadLayer"); window.document.mapcontrol.zoomScale.value = zoomScale window.document.mapcontrol.command.value = command; window.document.mapcontrol.submit(); } } if (command=='refreshMap'){ showLayer("loadLayer"); window.document.mapcontrol.submit(); } if (command=='showReference'){ var flag = ''; var referenceMap = window.document.mapcontrol.referenceMap.value; if (referenceMap == 'false' && flag == ''){ flag = 'ok'; showLayer("theReferenceMapImage"); window.document.mapcontrol.referenceMap.value = 'true'; } if (referenceMap = 'true' && flag == ''){ flag = 'ok'; hideLayer("theReferenceMapImage"); window.document.mapcontrol.referenceMap.value = 'false'; } window.document.mapcontrol.submit(); } if (command=='clearSearchArrow'){ showLayer("loadLayer"); window.document.mapcontrol.command.value = command; window.document.mapcontrol.submit(); } //set valgt verkty setSelectedImage(command); } // for å laste eit pop up vindauge function loadForm(formType) { if (formType == 'skrivut' || formType == 'email' || formType == 'save' || formType == 'legend' || formType == 'makeGeoRefJPEG' || formType == 'savePDF'){ var URL; URL = "mapService=" + window.document.mapcontrol.mapService.value + "&" URL = URL + "mapWidth=" + window.document.mapcontrol.mapWidth.value + "&" URL = URL + "mapHeight=" + window.document.mapcontrol.mapHeight.value + "&" URL = URL + "minX=" + window.document.mapcontrol.minX.value + "&" URL = URL + "minY=" + window.document.mapcontrol.minY.value + "&" URL = URL + "maxX=" + window.document.mapcontrol.maxX.value + "&" URL = URL + "maxY=" + window.document.mapcontrol.maxY.value + "&" URL = URL + "command=" + window.document.mapcontrol.command.value + "&" URL = URL + "layerId=" + window.document.mapcontrol.layerId.value + "&" URL = URL + "maxMapExtent=" + window.document.mapcontrol.maxMapExtent.value + "&" URL = URL + "zoomScale=" + window.document.mapcontrol.zoomScale.value + "&" URL = URL + "zoomWidthValue=" + window.document.mapcontrol.zoomWidthValue.value + "&" URL = URL + "geObject=" + window.document.mapcontrol.geObject.value + "&" URL = URL + "filter=" + escape(window.document.mapcontrol.filter.value) + "&" URL = URL + "usersession=" + window.document.mapcontrol.usersession.value + "&" URL = URL + "buffer_step1=" + window.document.mapcontrol.buffer_step1.value + "&" URL = URL + "buffer_step2=" + window.document.mapcontrol.buffer_step2.value + "&" URL = URL + "dpi=" + window.document.mapcontrol.dpi.value + "&" URL = URL + "WMSdimmension=" + window.document.mapcontrol.WMSdimmension.value if (formType == 'skrivut'){ URL = 'default_printMap.aspx?' + URL; } if (formType == 'email'){ URL = 'advanced_email.aspx?' + URL; } if (formType == 'save'){ URL = 'advanced_save.aspx?' + URL; } if (formType == 'legend'){ URL = 'advanced_legend.aspx?' + URL; } if (formType == 'makeGeoRefJPEG'){ URL = 'advanced_makeGeoRefJPEG.aspx?' + URL; } if (formType == 'savePDF'){ URL = 'advanced_save_pdf.aspx?' + URL; } window.parent.result.location.href = URL; } if (formType == 'statistikk'){ var URL; var maxMapExtent = window.document.mapcontrol.maxMapExtent.value; var arrayOfmaxMapExtent = maxMapExtent.split(","); URL = "mapService=" + window.document.mapcontrol.mapService.value + "&" URL = URL + "mapWidth=" + window.document.mapcontrol.mapWidth.value + "&" URL = URL + "mapHeight=" + window.document.mapcontrol.mapHeight.value + "&" URL = URL + "minX=" + arrayOfmaxMapExtent[0] + "&" URL = URL + "minY=" + arrayOfmaxMapExtent[1] + "&" URL = URL + "maxX=" + arrayOfmaxMapExtent[2] + "&" URL = URL + "maxY=" + arrayOfmaxMapExtent[3] + "&" URL = URL + "command=" + window.document.mapcontrol.command.value + "&" URL = URL + "layerId=" + window.document.mapcontrol.layerId.value + "&" URL = URL + "zoomScale=" + window.document.mapcontrol.zoomScale.value + "&" URL = URL + "maxMapExtent=" + window.document.mapcontrol.maxMapExtent.value + "&" URL = URL + "zoomWidthValue=" + window.document.mapcontrol.zoomWidthValue.value + "&" URL = URL + "geObject=" + window.document.mapcontrol.geObject.value + "&" URL = URL + "usersession=" + window.document.mapcontrol.usersession.value URL = '/statistikk/statistikk.aspx?' + URL window.parent.result.location.href = URL; } //går til zoom in modus setState('zoomIn'); } // for å slå av og på temalag function toggleLayer() { showLayer("loadLayer"); var layerId = ''; //Sjekkar først om det er fleire lag enn 1 (layerID.length vert då eit objekt) if (parent.menuFrame.document.menu.layerID.length){ for (var i = 0; i < parent.menuFrame.document.menu.layerID.length; i++) { if (parent.menuFrame.document.menu.layerID[i].checked == true) { layerId = layerId + parent.menuFrame.document.menu.layerID[i].value + ","; } } //Dersom berre eitt lag }else{ if (parent.menuFrame.document.menu.layerID.checked == true) { layerId = parent.menuFrame.document.menu.layerID.value + ","; } } layerId = layerId.slice(0,-1) window.document.mapcontrol.layerId.value = layerId; window.document.mapcontrol.command.value = ''; window.document.mapcontrol.sqlWhere.value = ''; window.document.mapcontrol.filter.value = ''; window.document.mapcontrol.WMSdimmension.value = toggleLayerWMSDimmension(window.document.mapcontrol.layerId.value,window.document.mapcontrol.WMSdimmension.value); window.document.mapcontrol.submit(); } // for å slå av og på temalag i avansert løysing function toggleLayerAdvanced(value,checked) { showLayer("loadLayer"); var layerId = ''; //Dersom eit lag vert slege av, må det sjekkast om det finst fleire opplistingar av same temalag under t.d. andre kategoriar //Alle tema med same namn vert gå slegne av... if (checked == false){ for (var i = 0; i < parent.menuFrame.document.menu.layerID.length; i++) { if (parent.menuFrame.document.menu.layerID[i].value == value) { parent.menuFrame.document.menu.layerID[i].checked = false; } } } //Sjekkar først om det er fleire lag enn 1 (layerID.length vert då eit objekt) if (parent.menuFrame.document.menu.layerID.length){ for (var i = 0; i < parent.menuFrame.document.menu.layerID.length; i++) { if (parent.menuFrame.document.menu.layerID[i].checked == true) { layerId = layerId + parent.menuFrame.document.menu.layerID[i].value + ","; } } //Dersom berre eitt lag }else{ if (parent.menuFrame.document.menu.layerID.checked == true) { layerId = parent.menuFrame.document.menu.layerID.value + ","; } } layerId = layerId.slice(0,-1) window.document.mapcontrol.layerId.value = layerId; window.document.mapcontrol.command.value = ''; window.document.mapcontrol.sqlWhere.value = ''; window.document.mapcontrol.filter.value = ''; window.document.mapcontrol.WMSdimmension.value = toggleLayerWMSDimmension(window.document.mapcontrol.layerId.value,window.document.mapcontrol.WMSdimmension.value); window.document.mapcontrol.submit(); } //Sjekkar om det finst WMS tid/elevation sendt til mapengine. //Går gjennom alle layerId og sjekkar om det finst samsvarande layerid i wmsdimmension. //Dersom ikkje vert tema fjerna frå WMS dimmenstion streng function toggleLayerWMSDimmension(layerId,WMSdimmension) { var i = 0; var x = 0; var r = ""; layerId = layerId.split(","); WMSdimmension = WMSdimmension.split("####"); while (i < layerId.length) { for (var x = 0; x < WMSdimmension.length; x++) { var myArray = WMSdimmension[x].split("##"); if (myArray[0] == layerId[i]) { if (myArray[0] && myArray[1]) { r = r + myArray[0] + '##' + myArray[1] + '####'; } } } i++; } r = r.substr(0, r.length - 4); return r; } // funksjon som køyrer på BODY onload og sjekkar om sida er lasta function setPageLoaded(){ pageLoaded = 1; } //funksjon for å sette fokus rundt ein extent function goToExtent(extent) { if (extent != ""){ parent.map.showLayer("loadLayer"); extents = extent.split(","); window.document.mapcontrol.minX.value = extents[0]; window.document.mapcontrol.minY.value = extents[1]; window.document.mapcontrol.maxX.value = extents[2]; window.document.mapcontrol.maxY.value = extents[3]; window.document.mapcontrol.command.value = ''; window.document.mapcontrol.submit(); } } //funksjon for å gå til objekt i eit tema (x,y) koordinart function setCoordinateSubmit(coordinate, zoomWidthValue, layerId) { //finne om det er tema på eller ikkje i løysinga var tmpLayerId = window.document.mapcontrol.layerId.value; tmpLayerId = tmpLayerId.split(","); //det er ingen tema på if (window.document.mapcontrol.layerId.value == '') { window.document.mapcontrol.layerId.value = layerId; //går gjennom temaliste og fjernar event layerId som er sendt med inn }else{ //fjernar layerId var i = 0; while (i < tmpLayerId.length) { if (tmpLayerId[i] == layerId) { tmpLayerId.splice(i, 1); } else { i++; } } var newLayers = tmpLayerId.join(","); //dersom ingen andre tema er på if (newLayers == "") { window.document.mapcontrol.layerId.value = layerId; //dersom andre tema er på }else{ window.document.mapcontrol.layerId.value = newLayers + "," + layerId; } } parent.map.showLayer("loadLayer"); window.document.mapcontrol.command.value = 'zoomDrawPoint'; window.document.mapcontrol.zoomWidthValue.value = zoomWidthValue; window.document.mapcontrol.geObject.value = coordinate; //window.document.mapcontrol.layerId.value = layerId; window.document.mapcontrol.submit(); } //funksjon for å gå til objekt (x,y) koordinart function setCoordinateSubmitObject(coordinate, zoomWidthValue) { parent.map.showLayer("loadLayer"); window.document.mapcontrol.command.value = 'zoomDrawPoint'; window.document.mapcontrol.zoomWidthValue.value = zoomWidthValue; window.document.mapcontrol.geObject.value = coordinate; window.document.mapcontrol.submit(); } //funksjon for å sette fokus rundt ein extent til gjeve lag function setCoordinateSubmitRect(extent,layerId) { if (extent != ""){ //finne om det er tema på eller ikkje i løysinga var tmpLayerId = window.document.mapcontrol.layerId.value; tmpLayerId = tmpLayerId.split(","); //det er ingen tema på if (window.document.mapcontrol.layerId.value == '') { window.document.mapcontrol.layerId.value = layerId; //går gjennom temaliste og fjernar event layerId som er sendt med inn }else{ //fjernar layerId var i = 0; while (i < tmpLayerId.length) { if (tmpLayerId[i] == layerId) { tmpLayerId.splice(i, 1); } else { i++; } } var newLayers = tmpLayerId.join(","); //dersom ingen andre tema er på if (newLayers == "") { window.document.mapcontrol.layerId.value = layerId; //dersom andre tema er på }else{ window.document.mapcontrol.layerId.value = newLayers + "," + layerId; } } parent.map.showLayer("loadLayer"); extents = extent.split(","); window.document.mapcontrol.minX.value = extents[0]; window.document.mapcontrol.minY.value = extents[1]; window.document.mapcontrol.maxX.value = extents[2]; window.document.mapcontrol.maxY.value = extents[3]; //window.document.mapcontrol.layerId.value = layerId; window.document.mapcontrol.command.value = ''; window.document.mapcontrol.submit(); } } //funksjon for å sette fokus rundt ein extent function setCoordinateSubmitRectWithoutLayerId(extent) { if (extent != ""){ parent.map.showLayer("loadLayer"); extents = extent.split(","); parent.map.mapcontrol.minX.value = extents[0]; parent.map.mapcontrol.minY.value = extents[1]; parent.map.mapcontrol.maxX.value = extents[2]; parent.map.mapcontrol.maxY.value = extents[3]; parent.map.mapcontrol.command.value = ''; parent.map.mapcontrol.submit(); } } //funksjon for å hente data frå eit WMS lag function setWMSSubmit(layerId, wms_url,x,y) { var theURL = "default_searchThemeByMapWMS.aspx?"; theURL = theURL + "&layerId=" + layerId; theURL = theURL + "&WMSURL=" + escape(wms_url); theURL = theURL + "&minX=" + window.document.mapcontrol.minX.value; theURL = theURL + "&minY=" + window.document.mapcontrol.minY.value; theURL = theURL + "&maxX=" + window.document.mapcontrol.maxX.value; theURL = theURL + "&maxY=" + window.document.mapcontrol.maxY.value; theURL = theURL + "&mapWidth=" + window.document.mapcontrol.mapWidth.value; theURL = theURL + "&mapHeight=" + window.document.mapcontrol.mapHeight.value; theURL = theURL + "&x=" + x; theURL = theURL + "&y=" + y; theURL = theURL + "&WMSdimmension=" + escape(window.document.mapcontrol.WMSdimmension.value); open(theURL); //alert(theURL); } // funksjon som zoomer til brukerbestemt scale. F.eks fra textbox eller dropdown function zoomScale(e) { var zoomScale = e if (zoomScale) { showLayer("loadLayer"); window.document.mapcontrol.zoomScale.value = zoomScale window.document.mapcontrol.command.value = 'zoomScale'; window.document.mapcontrol.submit(); } } // funksjon som trigges når map loades. Den setter inn ny option (current målestokk) i dropdown function zoomScaleOnMapLoad() { if (window.parent.menuFrame) { window.parent.menuFrame.document.menu.zoomScale.options[0] = new Option('1:'+ Math.round((window.document.mapcontrol.zoomScale.value / 100)) * 100,Math.round((window.document.mapcontrol.zoomScale.value / 100)) * 100); window.parent.menuFrame.document.menu.zoomScale.selectedIndex = 0; } } //kopierer URL til kartutsnitt function copyMapURL() { var minX = window.document.mapcontrol.minX.value; var minY = window.document.mapcontrol.minY.value; var maxX = window.document.mapcontrol.maxX.value; var maxY = window.document.mapcontrol.maxY.value; var layerId = window.document.mapcontrol.layerId.value; var mapService = window.parent.menuFrame.document.menu.mapType.selectedIndex; var mapCategory = window.parent.menuFrame.document.menu.mapCategory.value; var pathname = parent.window.location.pathname; if (pathname == "/"){ pathname = "/default.aspx"; } var url = 'http://'+window.location.hostname+pathname+'?minX='+minX+'&minY='+minY+'&maxX='+maxX+'&maxY='+maxY+'&layerId='+layerId+'&mapService='+mapService+'&mapCategory='+mapCategory+'&lang=eng'; sendToClipboard(url); } function sendToClipboard(theString) { if( window.clipboardData && clipboardData.setData ) { clipboardData.setData("Text", theString); //alert("URL to the current map has been copied to the clipboard"); } else { //alert("This function is not supported by your browser. Internet Explorer is required."); } } //fjernar bufferutvalg frå kartet function clearBuffer() { showLayer("loadLayer"); window.document.mapcontrol.command.value = ''; window.document.mapcontrol.buffer_step1.value = ''; window.document.mapcontrol.buffer_step2.value = ''; window.document.mapcontrol.submit(); } //set valgt verkty function setSelectedImage(state, sfsVar, digUrl, digType){ //alert(state + ' ' + sfsVar + ' ' + digUrl + ' ' + digType); if (state == 'identify' && parent.header.document.getElementById('identify')) { setSelectedImageStyle('identify'); } if (state == 'drawing' && sfsVar == 'polygon' && digUrl == 'default_searchThemeByMap.aspx' && digType == 'search' && parent.header.document.getElementById('identifyPolygon')) { setSelectedImageStyle('identifyPolygon'); } if (state == 'pan' && parent.header.document.getElementById('pan')) { setSelectedImageStyle('pan'); } if (state == 'zoomIn' && parent.header.document.getElementById('zoomIn')) { setSelectedImageStyle('zoomIn'); } if (state == 'zoomOut' && parent.header.document.getElementById('zoomOut')) { setSelectedImageStyle('zoomOut'); } if (state == 'zoomFullExtent' && parent.header.document.getElementById('zoomFullExtent')) { setSelectedImageStyle('zoomFullExtent'); } if (state == 'zoomScale' && parent.header.document.getElementById('zoomScale')) { setSelectedImageStyle('zoomScale'); } if (state == 'refreshMap' && parent.header.document.getElementById('refreshMap')) { setSelectedImageStyle('refreshMap'); } if (state == 'measure' && parent.header.document.getElementById('measure')) { setSelectedImageStyle('measure'); } if (state == 'measurearea' && parent.header.document.getElementById('measurearea')) { setSelectedImageStyle('measurearea'); } if (state == 'drawing' && sfsVar == 'point' && digUrl == 'advanced_digitizeform.aspx' && parent.header.document.getElementById('drawingPoint')) { setSelectedImageStyle('drawingPoint'); } if (state == 'drawing' && sfsVar == 'linestring' && digUrl == 'advanced_digitizeform.aspx' && parent.header.document.getElementById('drawingLinestring')) { setSelectedImageStyle('drawingLinestring'); } if (state == 'drawing' && sfsVar == 'polygon' && digUrl == 'advanced_digitizeform.aspx' && parent.header.document.getElementById('drawingPolygon')) { setSelectedImageStyle('drawingPolygon'); } if (state == 'buffer' && parent.header.document.getElementById('buffer')) { setSelectedImageStyle('buffer'); } if (state == 'clearSearchArrow' && parent.header.document.getElementById('clearSearchArrow')) { setSelectedImageStyle('clearSearchArrow'); } if (state == 'drawing' && sfsVar == 'point' && digUrl == 'advanced_goToCoordinateList.aspx') { setSelectedImageStyle('goToCoordinateList'); } if (state == 'drawing' && digUrl == 'advanced_yr.aspx') { setSelectedImageStyle('yr'); } unSelectImage(state, sfsVar, digUrl, digType) } function setSelectedImageStyle(element) { parent.header.document.getElementById(element).style.border = 'solid 1px #000000'; parent.header.document.getElementById(element).style.padding = '1px'; parent.header.document.getElementById(element).style.backgroundColor = '#ECE9D8'; } //fjernar valgt verkty function unSelectImage(state, sfsVar, digUrl, digType) { //alert(state + ' ' + sfsVar + ' ' + digUrl + ' ' + digType); if (state != 'identify' && parent.header.document.getElementById('identify')) { unSelectImageStyle('identify'); } if (parent.header.document.getElementById('identifyPolygon')) { if (state != 'drawing' || sfsVar != 'polygon' || digUrl != 'default_searchThemeByMap.aspx' || digType != 'search') { unSelectImageStyle('identifyPolygon'); } } if (state != 'pan' && parent.header.document.getElementById('pan')) { unSelectImageStyle('pan'); } if (state != 'zoomIn' && parent.header.document.getElementById('zoomIn')) { unSelectImageStyle('zoomIn'); } if (state != 'zoomOut' && parent.header.document.getElementById('zoomOut')) { unSelectImageStyle('zoomOut'); } if (state != 'zoomFullExtent' && parent.header.document.getElementById('zoomFullExtent')) { unSelectImageStyle('zoomFullExtent'); } if (state != 'zoomScale' && parent.header.document.getElementById('zoomScale')) { unSelectImageStyle('zoomScale'); } if (state != 'refreshMap' && parent.header.document.getElementById('refreshMap')) { unSelectImageStyle('refreshMap'); } if (state != 'measure' && parent.header.document.getElementById('measure')) { unSelectImageStyle('measure'); } if (state != 'measurearea' && parent.header.document.getElementById('measurearea')) { unSelectImageStyle('measurearea'); } if (parent.header.document.getElementById('drawingPoint')) { if (state != 'drawing' || sfsVar != 'point' || digUrl != 'advanced_digitizeform.aspx') { unSelectImageStyle('drawingPoint'); } } if (parent.header.document.getElementById('drawingLinestring')) { if (state != 'drawing' || sfsVar != 'linestring' || digUrl != 'advanced_digitizeform.aspx') { unSelectImageStyle('drawingLinestring'); } } if (parent.header.document.getElementById('drawingPolygon')) { if (state != 'drawing' || sfsVar != 'polygon' || digUrl != 'advanced_digitizeform.aspx') { unSelectImageStyle('drawingPolygon'); } } if (state != 'buffer' && parent.header.document.getElementById('buffer')) { unSelectImageStyle('buffer'); } if (state != 'clearSearchArrow' && parent.header.document.getElementById('clearSearchArrow')) { unSelectImageStyle('clearSearchArrow'); } if (parent.header.document.getElementById('goToCoordinateList')) { if (state != 'drawing' || sfsVar != 'point' || digUrl != 'advanced_goToCoordinateList.aspx') { unSelectImageStyle('goToCoordinateList'); } } if (parent.header.document.getElementById('yr')) { if (state != 'drawing' || digUrl != 'advanced_yr.aspx') { unSelectImageStyle('yr'); } } } function unSelectImageStyle(element) { parent.header.document.getElementById(element).style.border = ''; parent.header.document.getElementById(element).style.padding = '2px'; parent.header.document.getElementById(element).style.backgroundColor = ''; } //Sjekkar at lag som er synlege i kartet og viser i menylista function checkLayers(){ var layerId = window.document.mapcontrol.layerId.value; var zoomScale = Math.round(window.document.mapcontrol.zoomScale.value); layerId = layerId.split(",") //Sjekkar først om nokre menyelement er ekspanderte if (parent.menuFrame){ if (parent.menuFrame.document.menu.layerID) { //Sjekkar om det er fleire lag enn 1 synleg i menyen (layerID.length vert då eit objekt) if (parent.menuFrame.document.menu.layerID.length){ //slår først av alle lag for (var i = 0; i < parent.menuFrame.document.menu.layerID.length; i++) { parent.menuFrame.document.menu.layerID[i].checked = false; } //Går gjennom alle lag i menyen for (var i = 0; i < parent.menuFrame.document.menu.layerID.length; i++) { //sjekkar tema skal vere enabla eller ikkje basert på målestokk var maxscale = Math.round(parent.menuFrame.document.menu.maxscale[i].value); var minscale = Math.round(parent.menuFrame.document.menu.minscale[i].value); if (((zoomScale > maxscale) && (maxscale > 0)) || ((zoomScale < minscale) && (minscale > 0))) { parent.menuFrame.document.menu.layerID[i].disabled = true; } else { parent.menuFrame.document.menu.layerID[i].disabled = false; } //Går gjennom alle synlege temalag (henta frå mapFrame) for (var x = 0; x < layerId.length; x++) { if (parent.menuFrame.document.menu.layerID[i].value == layerId[x]) { parent.menuFrame.document.menu.layerID[i].checked = true; } } } //Dersom berre eitt lag er synleg }else{ //Går gjennom alle synlege temalag (henta frå mapFrame) for (var x = 0; x < layerId.length; x++) { //sjekkar tema skal vere enabla eller ikkje basert på målestokk var maxscale = Math.round(parent.menuFrame.document.menu.maxscale.value); var minscale = Math.round(parent.menuFrame.document.menu.minscale.value); if (((zoomScale > maxscale) && (maxscale > 0)) || ((zoomScale < minscale) && (minscale > 0))) { parent.menuFrame.document.menu.layerID.disabled = true; } else { parent.menuFrame.document.menu.layerID.disabled = false; } //sjekkar synleg lag if (parent.menuFrame.document.menu.layerID.value == layerId[x]) { parent.menuFrame.document.menu.layerID.checked = true; } } } } } } // Stop funskjonar