var osMap; // OS Variable var pt; // OS Variable var oldpt; // OS Variable var oldptm1 var lonlat; // OS Variable var lineString; // OS Variable var lineFeature; // OS Variable var p1; // last clicked position var p2; // previous clicked position var points = []; // mini array showing each end of the line var startmap=0 var dist=0; //total distance of route var inc; //incremental distance var ptmouse; //capture mouse posn var ptm; var k=-1; //position in array var firsttime=0; var finished=0; var pos3 var sections; var lCol; var lf; // var colour = "#FF0000" var linftrs = new Array; var linPr = new Array; //record of plotted route var latPts = new Array; var lonPts =new Array; var latty = new Array var lonny = new Array; var incdistPr = new Array; var bearingPr = new Array; var gridPr = new Array; var ptPr = new Array; var pos2Pr= new Array; var p1Pr = new Array; var lincol= new Array; var sw= new Array; var sop = new Array; var sFormat = new Array; var locations = new Array; //**** variables used to draw lines var vectorLayer = new OpenLayers.Layer.Vector("Vector Layer"); var gridProjection = new OpenSpace.GridProjection(); // var linestyle = {strokeColor: "Red", strokeOpacity: 0.4, strokeWidth: 6, pointRadius: 1, pointerEvents: "visiblePainted"}; var screenOverlay = new OpenSpace.Layer.ScreenOverlay("coords"); screenOverlay.setPosition(new OpenLayers.Pixel(100, 0)); var screenOverlay2 = new OpenSpace.Layer.ScreenOverlay("coords"); screenOverlay2.setPosition(new OpenLayers.Pixel(850, 20)); var icon1 = new OpenLayers.Layer.Markers("Markers"); function init() { osMap = new OpenSpace.Map('map'); osMap.setCenter(new OpenSpace.MapPoint(431150,276300), 7); postcodeService = new OpenSpace.Postcode(); var vectorLayer = new OpenLayers.Layer.Vector("Map Layer"); osMap.addLayer(vectorLayer); osMap.events.register("mousemove", osMap, function(e) { pt = osMap.getLonLatFromViewPortPx(e.xy); lonlat = gridProjection.getLonLatFromMapPoint(pt); }); osMap.addLayer(screenOverlay); osMap.addLayer(screenOverlay2); size = new OpenLayers.Size(15,15); offset = new OpenLayers.Pixel(-5,-5); infoWindowAnchor = new OpenLayers.Pixel(16,16); //icon1 = new OpenSpace.Icon('http://openspace.ordnancesurvey.co.uk/osmapapi/img_versions/img_1.1.0/OS/images/markers/marker_red.png', size, offset, null, infoWindowAnchor); icon1 = new OpenSpace.Icon('http://openspace.ordnancesurvey.co.uk/osmapapi/img_versions/img_1.1.0/OS/images/markers/round-marker-lrg-red.png', size, offset, null, infoWindowAnchor); icon2 = new OpenSpace.Icon('http://openspace.ordnancesurvey.co.uk/osmapapi/img_versions/img_1.1.0/OS/images/markers/round-marker-lrg-green.png', size, offset, null, infoWindowAnchor); //icon2 = new OpenSpace.Icon('http://openspace.ordnancesurvey.co.uk/osmapapi/img_versions/img_1.1.0/OS/images/markers/marker_green.png', size, offset, null, infoWindowAnchor); // printoverlays(0.000001.toFixed(2)) lincol[0] ="Red" lincol[1] ="Blue" lincol[2] ="Green" lincol[3] ="Yellow" lincol[4] ="Teal" lincol[5] ="Turquoise" lcol=0 sw[0]=1 sw[1]=4 sw[2]=5 sw[3]=7 sw[4]=9 strokew=1 sop[0]=0.0 sop[1]=0.2 sop[2]=0.4 sop[3]=0.6 sop[4]=0.8 sop[5]=1.0 strokop=3 sFormat[0]="solid" sFormat[1]="dash" sFormat[2]="dot" setlinecolour() } function recentre(){ pt=ptPr[sections] osMap.setCenter(new OpenSpace.MapPoint(pt.lon,pt.lat), 7); } //resets everything function reset(){ document.getEl Route Report ementById("startbutton").src='/maps/icons/start.png'; document.getElementById("finishbutton").src='/maps/icons/disabled.png'; document.getElementById("undobutton").src='/maps/icons/disabled.png'; document.getElementById("resetbutton").src='/maps/icons/disabled.png'; document.getElementById("printbutton").src='/maps/icons/disabled.png'; document.getElementById("reportbutton").src='/maps/icons/disabled.png'; document.getElementById("gpxbutton").src='/maps/icons/disabled.png'; document.getElementById("pcbutton").src='/maps/icons/postcode.png'; document.getElementById("gazbutton").src='/maps/icons/gazetteer.png'; document.getElementById("recentrebutton").src='/maps/icons/disabled.png'; linPr = new Array(); startmap=0; p1=''; k=-1; dist=0; dist2=0; finished=0 firsttime=0 removeLine() osMap.removeMarker(marker2) osMap.removeMarker(marker1) pos2Pr=[] ptPr=[] linPr=[] latPts=[] lonPts=[] linftrs=[] indistPr=[] } function report(){ if (finished==0) return var x= window.open("","route_planner","location=no,toolbar=yes,menubar=yes,scrollbars=yes,width=800" ) x.document.open() x.document.write(''); dist=0 x.document.write(0); x.document.write(" start at") x.document.write("                                                                          ") x.document.write ( " ",lonPts[0] ," ", latPts[0],'
') now=1 { while (now
Route Report') now=now+1 } x.document.writeln() x.document.writeln ("total distance travelled = ",dist.toFixed(2)," kms") } x.document.write(''); x.document.write(''); x.document.close() return false; } function download(){ var x= window.open("","route_planner","location=no,toolbar=yes,menubar=yes,scrollbars=yes,width=800" ) x.document.open() x.document.close() return false; } function gpxmake(){ var gpxWin= window.open("","gpxroute","location=no,toolbar=yes,menubar=yes,scrollbars=yes,width=800" ) // alert("1") gpxWin.document.open('text/xml') x="" // x+=('') // x+=('') x+=("<"+"?xml version=\"1.0\"?>\n") x+=("\n") x+=("\n") x+=("testing\n") x+=("\n") now=0 while (now < sections+1) { x+=("") x+=("\n") now=now+1 } x+=("\n") x+=("\n") x+=("\n") //x+=("/\n") //x+=("/html\n") gpxWin.document.write(x) gpxWin.document.close() return false } function finish() { document.getElementById("finishbutton").src='/maps/icons/disabled.png'; document.getElementById("undobutton").src='/maps/icons/disabled.png'; document.getElementById("resetbutton").src='/maps/icons/reset.png'; document.getElementById("printbutton").src='/maps/icons/print.png'; document.getElementById("reportbutton").src='/maps/icons/report.png'; document.getElementById("gpxbutton").src='/maps/icons/gps.png'; finished=1 startmap=0 // report() // waymarks() } function printoverlays(dist2) { screenOverlay.setHTML("
" + " kms = : " + dist2 + "
"); // screenOverlay2.setHTML("
" + // "Grid Ref =: " + ptm + "
"+ "Bearing = : " + b2+ "
"); } // removes all the lines on the map function removeLine(){ for(var i=0; iMap Print'); dp.document.write('') dp.document.write(contentset); // dp.document.write(vectorLayer) dp.document.write(''); dp.document.close() return false; } function searchPostcode() { if (startmap==1) return var query = document.getElementById("postcode"); postcodeService.getLonLat(query.value, onResult); return false; } function onResult(mapPoint) { /*if found, a MapPoint is passed into this function and the map is centered on it at zoom level 10 */ osMap.setCenter(mapPoint, 7); } function searchGazetteer(query) { if (startmap==1) return var gazetteer = new OpenSpace.Gazetteer(); var query = document.getElementById("gazetteer"); gazetteer.getLocations(query.value, onResult1); return false; } function onResult1(locations) { if (locations != null && locations.length > 0) // { // for (var i=0; i < locations.length; i++) // { // Extract result fields // var name = locations[i].name; // var county = locations[i].county; var location = locations[0].location var coordStr = location.toCoordString(); // Do something with the info // €€ // } // (Or optionally) // Set centre of the map to the first point osMap.setCenter(locations[0].location, 7); // } } function setlinecolour(){ linecolour= document.colourchange.lCol.selectedIndex; strokew = document.linewidth.lWidth.selectedIndex; op = document.opacity.lop.selectedIndex; lf=document.lineformat.lForm.selectedIndex; linestyle = {strokeColor:lincol[linecolour], strokeOpacity: sop[op], strokeWidth:sw[strokew],strokeDashstyle:sFormat[lf], pointRadius: 1, pointerEvents: "visiblePainted"}; // linestyle={strokeColor: "#ff0033", strokeOpacity: 0.4, strokeWidth: 6, pointRadius: 1, pointerEvents: "visiblePainted"}; } function setlinedefault() { linestyle = {strokeColor:red, strokeOpacity: 0.6, strokeWidth:5, pointRadius: 1, pointerEvents: "visiblePainted"}; } function help(){ winHelp = open ("/maps/help/help.html"); } function ck() { recntre=0 {if( document.centre.Reset[1].checked) recntre=1} }


Post Code Search
Gazeteer Search
---------------------------------- Alter Line Details
Line Colour
Line Width
Line Opacity
Line Format
---------------------------------- Re-centre Map Each Click

no yes

----------------------------------