var height = document.getElementById('MainView').imageHeight; var width = document.getElementById('MainView').imageWidth; var MAX_SCALE = 240000000; var marker = document.getElementById('ClickSensibleScaleMarker'); // @param direction - a named cardinal direction or a number of degrees // @param offset - a number indicating the multiplier to offset. // A value of 1.0 indicates a full screen. // Defaults to 0.5. function doPan(direction, offset, target){ if(!offset){ offset = 0.5; } var degrees = 0; if(direction=="NORTH"){ degrees = 0; }else if(direction=="SOUTH"){ degrees = 180; }else if(direction=="EAST"){ degrees = 90; }else if(direction=="WEST"){ degrees = 270; }else if(direction=="NORTHEAST"){ degrees = 45; }else if(direction=="SOUTHEAST"){ degrees = 135; }else if(direction=="SOUTHWEST"){ degrees = 225; }else if(direction=="NORTHWEST"){ degrees = 315; }else { degrees = direction; } var xoffset = offset * width * (1 + Math.sin(Math.PI * degrees / 180.0)); var yoffset = offset * height * (1 - Math.cos(Math.PI * degrees / 180.0)); doPanOffset(xoffset, yoffset, target); } function doPanOffset(xoffset, yoffset, target){ if(target == null){ target = "Context"; } _root().pushflushAsyncEvent(new Array('action','/mapNavigation', 'target', target, 'navAction', 'pan', 'x', xoffset, 'y', yoffset, 'srs','pixelspace')); } function doScale(direction, target){ var scale = document.getElementById('MainView').scale; var rad10 = Math.sqrt(10); if(direction=="IN"){ setScale(scale / rad10, target); }else if(direction=="OUT"){ setScale(scale * rad10, target); } } function setScale(value, target){ if(target == null){ target = "Context"; } _root().pushflushAsyncEvent(new Array('action','/mapNavigation', 'target', target, 'navAction', 'setscale', 'scale', value)); } function scaleToIncludePoint(xval, yval, target){ if(target == null){ target = "Context"; } _root().pushflushAsyncEvent(new Array('action','/scaleToIncludePoint', 'target', target, 'xval', xval, 'yval', yval)); } function getTargetScale(input){ var targetScale = Math.pow(240000000, ((0.6 * input) + 0.4)); modBase = Math.pow(10, Math.round(Math.LOG10E * Math.log(targetScale) - 1)); modValue = targetScale % modBase; targetScale = targetScale - modValue; return targetScale; } function setSensibleScaleInit(){ if(sensibleScaleBar){ var targetHeight = ((Math.log(mainView.scale)/Math.log(MAX_SCALE)) - 0.4) / 0.6; if (targetHeight < 0) targetHeight = 0; updateFromCallback = true; sensibleScaleBar.setValue(targetHeight); } } function setCenter(xval, yval, target, suppressSend){ if(target == null){ target = "Context"; } _root().pushAsyncEvent(new Array('action', '/mapNavigation', 'navAction', 'PAN', 'srs', 'navigatorSRS', 'x', xval, 'y', yval, 'target', target)); if(!suppressSend){ _root().sendEvents(); } } function deleteVertex(index){ _root().pushflushAsyncEvent(new Array('action', '/editVertex', 'modifyOperation', 1, 'vertexNumber', index)); } function addVertex(index, operation){ $('EditPoint').vertexNumber = index; $('EditPoint').modifyOperation = operation; $('MainView').mouseMapProcessor.selectAction('addVertex'); $('GEOMETRY-MainView').style.zIndex = 2; } function moveVertex(index, x, y){ _root().pushflushAsyncEvent(new Array('action', '/editVertex','modifyOperation', 8, 'vertexNumber', index, 'x', x, 'y', y)); } function closeEditPoint(){ $('EditPoint').style.visibility = 'hidden'; $('EditPoint').style.display = 'none'; } // The default uses the Faz d' Hoo equation // to create a smooth curve a sensible minimum and maximum scale for the view. // Other scenarios will want to replace this function with something more appropriate. function computeScale(input){ return 750000000 * Math.sqrt(Math.max(input, 10000) - 5000) / Math.sqrt(input + 100000000); }