Open Location Services
Extend OpenLayers to add driving directions. Directions and Addresses are defined by Open LS OGC standard, v1.1. Directions may be displayed as either a polyline drawing the route on the map, as a series of textual description within a DIV element or both. Let's say that the base class is Directions.
var options = {
routingUrl: 'url of a RouteService',
routingPars: 'service params',
xslUrl: 'xsl url'
};
directions = new OpenLayers.Layer.Directions(options);
Rendering directions on map
In Open LS a RouteService response consists of Instructions and a gml describing the route geometry. This gml can be added to a map as a VectorLayer; directions can be rendered as LineStrings.
// type can be Shortest, Fastest and Pedestrian
directions.load('start','end','type');
Showing Instructions
Instructions may be shown in a div element somewhere inside the html page. A client side XSL transformation of the determineRouteResponse xml can create the html. Dom injection allows to refresh div contents and show Istructions.
//xmlResponse is OLS RouteService response. directions.drawOnMap(xmlResponse);
OpenLayers.transformXml method may be created to transform xml. XSLTProcessor (Moz) or an ActiveXObject (IE) may be used to transform xml with the desired xsl.
Storing Routing Informations
Directions can internally store results.
//retrive total time of the route directions.getTotalTime(); //retrive total distance of the route directions.getTotalDistance(); //retrive polygon of the route directions.getGeometryPoloygon(); //retrive an array of instructions for the route directions.getGeometryPoloygon(); ..... .....
Directions can fire events to intercept (load, error,...).
Geocoding Addresses
Addresses should be geocoded using with Open LS LocationUtilityService before searching directions. A GeocodedAddress object might be created to store addreess informations. Directions may store GeocodedAddresses.
