|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Open Space Web-Map builder Code</title> <!-- Download OpenSpace API using your key --> <script type="text/javascript" src="/http://openspaceregister.ordnancesurvey.co.uk/osmapapi/openspace.js?key=D8418B2F2259C6F8E0405F0ACA605247"></script> <script type= "text/javascript" src="/http://openspaceregister.ordnancesurvey.co.uk/osmapapi/script/mapbuilder/basicmap.js"></script> <script type= "text/javascript" src="/http://openspaceregister.ordnancesurvey.co.uk/osmapapi/script/mapbuilder/searchbox.js"></script> <script type="text/javascript"> //variables for routes var linesLayer, points, lineFeature, lineString, routeMarkersLayer, routepos, routesize, routeoffset, routeicon; var style_blue = {strokeColor: "#0000CD", strokeOpacity: 0.5, strokeWidth: 4.5};
function initmapbuilder() { //initiate the map var options = {resolutions: [2500, 1000, 500, 200, 100, 50, 25, 10, 5, 4, 2.5, 2, 1]}; osMap = new OpenSpace.Map('map', options);
//configure map options (basicmap.js) setglobaloptions(); //set the center of the map and the zoom level osMap.setCenter(new OpenSpace.MapPoint(269701,798503),8); linesLayer = osMap.getVectorLayer(); // Set up layer for route markers routeMarkersLayer = new OpenLayers.Layer.Markers("Route Markers"); //make a route points = new Array(); points.push(new OpenLayers.Geometry.Point(270346,798708)); points.push(new OpenLayers.Geometry.Point(270306,798623)); points.push(new OpenLayers.Geometry.Point(270246,798698)); points.push(new OpenLayers.Geometry.Point(270161,798678)); points.push(new OpenLayers.Geometry.Point(270091,798618)); points.push(new OpenLayers.Geometry.Point(270051,798558)); points.push(new OpenLayers.Geometry.Point(269966,798503)); points.push(new OpenLayers.Geometry.Point(269971,798428)); points.push(new OpenLayers.Geometry.Point(269981,798323)); points.push(new OpenLayers.Geometry.Point(269966,798243)); points.push(new OpenLayers.Geometry.Point(269916,798163)); points.push(new OpenLayers.Geometry.Point(269851,798118)); points.push(new OpenLayers.Geometry.Point(269791,798093)); points.push(new OpenLayers.Geometry.Point(269746,798048)); points.push(new OpenLayers.Geometry.Point(269641,797938)); points.push(new OpenLayers.Geometry.Point(269541,797693)); points.push(new OpenLayers.Geometry.Point(269456,797598)); points.push(new OpenLayers.Geometry.Point(269301,797443)); points.push(new OpenLayers.Geometry.Point(269221,797338)); points.push(new OpenLayers.Geometry.Point(269186,797428)); points.push(new OpenLayers.Geometry.Point(269191,797528)); points.push(new OpenLayers.Geometry.Point(269301,797668)); points.push(new OpenLayers.Geometry.Point(269306,797758)); points.push(new OpenLayers.Geometry.Point(269321,797858)); points.push(new OpenLayers.Geometry.Point(269381,797953)); points.push(new OpenLayers.Geometry.Point(269481,798068)); points.push(new OpenLayers.Geometry.Point(269746,798403)); points.push(new OpenLayers.Geometry.Point(269896,798568)); points.push(new OpenLayers.Geometry.Point(270006,798758)); points.push(new OpenLayers.Geometry.Point(270106,798878)); points.push(new OpenLayers.Geometry.Point(270171,798943)); points.push(new OpenLayers.Geometry.Point(270201,798923)); points.push(new OpenLayers.Geometry.Point(270301,798928)); points.push(new OpenLayers.Geometry.Point(270306,798873)); points.push(new OpenLayers.Geometry.Point(270376,798873)); points.push(new OpenLayers.Geometry.Point(270336,798768)); points.push(new OpenLayers.Geometry.Point(270346,798743)); points.push(new OpenLayers.Geometry.Point(270346,798708)); // create a polyline feature from the array of points lineString = new OpenLayers.Geometry.LineString(points); lineFeature = new OpenLayers.Feature.Vector(lineString, null, style_blue); linesLayer.addFeatures([lineFeature]); //make a route points = new Array(); points.push(new OpenLayers.Geometry.Point(270386,798683)); points.push(new OpenLayers.Geometry.Point(270376,798618)); points.push(new OpenLayers.Geometry.Point(270506,798558)); points.push(new OpenLayers.Geometry.Point(270521,798498)); points.push(new OpenLayers.Geometry.Point(270456,798293)); points.push(new OpenLayers.Geometry.Point(270466,798163)); points.push(new OpenLayers.Geometry.Point(270521,798048)); points.push(new OpenLayers.Geometry.Point(270591,797913)); points.push(new OpenLayers.Geometry.Point(270636,797868)); points.push(new OpenLayers.Geometry.Point(270571,797813)); points.push(new OpenLayers.Geometry.Point(270461,797738)); points.push(new OpenLayers.Geometry.Point(270211,797603)); points.push(new OpenLayers.Geometry.Point(270021,797428)); points.push(new OpenLayers.Geometry.Point(269861,797323)); points.push(new OpenLayers.Geometry.Point(269416,797103)); points.push(new OpenLayers.Geometry.Point(269196,797013)); points.push(new OpenLayers.Geometry.Point(269126,797078)); points.push(new OpenLayers.Geometry.Point(269271,797218)); points.push(new OpenLayers.Geometry.Point(269396,797343)); points.push(new OpenLayers.Geometry.Point(269541,797528)); points.push(new OpenLayers.Geometry.Point(269616,797583)); points.push(new OpenLayers.Geometry.Point(269751,797503)); points.push(new OpenLayers.Geometry.Point(269901,797393)); points.push(new OpenLayers.Geometry.Point(269976,797448)); points.push(new OpenLayers.Geometry.Point(270041,797628)); points.push(new OpenLayers.Geometry.Point(270091,797813)); points.push(new OpenLayers.Geometry.Point(270186,797918)); points.push(new OpenLayers.Geometry.Point(270266,797973)); points.push(new OpenLayers.Geometry.Point(270291,798078)); points.push(new OpenLayers.Geometry.Point(270371,798248)); points.push(new OpenLayers.Geometry.Point(270456,798358)); points.push(new OpenLayers.Geometry.Point(270446,798558)); points.push(new OpenLayers.Geometry.Point(270386,798683)); // create a polyline feature from the array of points lineString = new OpenLayers.Geometry.LineString(points); lineFeature = new OpenLayers.Feature.Vector(lineString, null, style_blue); linesLayer.addFeatures([lineFeature]); //make a route points = new Array(); points.push(new OpenLayers.Geometry.Point(270396,798883)); points.push(new OpenLayers.Geometry.Point(270341,799058)); points.push(new OpenLayers.Geometry.Point(270371,799178)); points.push(new OpenLayers.Geometry.Point(270331,799278)); points.push(new OpenLayers.Geometry.Point(270226,799363)); points.push(new OpenLayers.Geometry.Point(270136,799433)); points.push(new OpenLayers.Geometry.Point(270041,799483)); points.push(new OpenLayers.Geometry.Point(270091,799598)); points.push(new OpenLayers.Geometry.Point(270131,799653)); points.push(new OpenLayers.Geometry.Point(270136,799703)); points.push(new OpenLayers.Geometry.Point(270036,799748)); points.push(new OpenLayers.Geometry.Point(269991,799723)); points.push(new OpenLayers.Geometry.Point(269901,799738)); points.push(new OpenLayers.Geometry.Point(269821,799813)); points.push(new OpenLayers.Geometry.Point(269626,799758)); points.push(new OpenLayers.Geometry.Point(269546,799638)); points.push(new OpenLayers.Geometry.Point(269486,799588)); points.push(new OpenLayers.Geometry.Point(269596,799613)); points.push(new OpenLayers.Geometry.Point(269706,799693)); points.push(new OpenLayers.Geometry.Point(269816,799723)); points.push(new OpenLayers.Geometry.Point(269901,799668)); points.push(new OpenLayers.Geometry.Point(269971,799648)); points.push(new OpenLayers.Geometry.Point(269996,799583)); points.push(new OpenLayers.Geometry.Point(269871,799503)); points.push(new OpenLayers.Geometry.Point(269746,799448)); points.push(new OpenLayers.Geometry.Point(269671,799353)); points.push(new OpenLayers.Geometry.Point(269561,799283)); points.push(new OpenLayers.Geometry.Point(269506,799218)); points.push(new OpenLayers.Geometry.Point(269526,799178)); points.push(new OpenLayers.Geometry.Point(269646,799188)); points.push(new OpenLayers.Geometry.Point(269736,799228)); points.push(new OpenLayers.Geometry.Point(269896,799253)); points.push(new OpenLayers.Geometry.Point(270031,799203)); points.push(new OpenLayers.Geometry.Point(270121,799123)); points.push(new OpenLayers.Geometry.Point(270176,798993)); points.push(new OpenLayers.Geometry.Point(270176,798928)); points.push(new OpenLayers.Geometry.Point(270296,798918)); points.push(new OpenLayers.Geometry.Point(270366,798878)); points.push(new OpenLayers.Geometry.Point(270411,798863)); points.push(new OpenLayers.Geometry.Point(270396,798883)); // create a polyline feature from the array of points lineString = new OpenLayers.Geometry.LineString(points); lineFeature = new OpenLayers.Feature.Vector(lineString, null, style_blue); linesLayer.addFeatures([lineFeature]); //crate a route start/end marker routepos = new OpenSpace.MapPoint(270346,798708); routesize = new OpenLayers.Size(33,45); routeoffset = new OpenLayers.Pixel(-5,-37); routeicon = new OpenSpace.Icon('http://openspacewmb.ordnancesurvey.co.uk/osmapapi/img_versions/img_1.1/mapbuilder/routemarker-startend.png', routesize, routeoffset, null, null); routeMarkersLayer.addMarker(new OpenLayers.Marker(routepos, routeicon)); osMap.addLayer(routeMarkersLayer);} </script> </head> <body onload="initmapbuilder()"> <div id="map" style="border: 1px solid black; width:540px; height:440px;"></div> </body> </html>
|