RoadSurface

ALKMaps.Layer.RoadSurface and ALKMaps.Layer.RoadSurfaceRoute layers allow you to display road surface conditions as a map tile overlay or visualize color coded road surface conditions along each route.

Road Surface Layer

The display of road surface information is handled through the Road Surface Layer. Once this layer is added to your map, it will display a road surface data overlay that is color coded to indicate the flow of condition on the roads currently visible in the map.

In addition to real-time road condition data, the layer can be configured to show future predicted information within next 24 hours.

The color legend for RoadSurface map is as follows:

  • Not in range
  • Dry road
  • Wet road
  • Ice/snow
  • Mix water/snow
  • Dew
  • Melting snow
  • Frost
  • Icing rain

var roadSurfaceLayer = new ALKMaps.Layer.RoadSurface("ALK RoadSurface");

Real-time Road Surface

By default, the new RoadSurface layer will display real-time road condition information based on the current data for the area visible in the map.

Future Road Surface prediction

To pull future surface prediction data for a specific time, you’ll need to set the appropriate parameters (hourOffset) on the layer. This can be done by either passing in the parameters during the creation of the layer or by setting the parameters on an existing RoadSurface layer and redrawing the layer.

To display Road Surface condition data in next 6 hours, you would use the following code

var roadSurfaceLayer = new ALKMaps.Layer.RoadSurface(
  "ALK LiveRoadSurface",
  {
    hourOffset: 6
  },
  {}
);

hourOffset

The hourOffset parameter is set to an integer. Valid values are 0 to 23 inclusive.

You can modify an existing RoadSurface layer’s future prediction settings by manually setting the individual properties of the params object.

roadSurfaceLayer.disableCache = true;
roadSurfaceLayer.hourOffset = 12;
roadSurfaceLayer.redraw();

To view a demo with live or predictive road surface condition, please visit the Road Surface example page and view the source code.

Road Surface Route Layer

This layer offers two methods for you to visualize road surface conditions quickly. If you want to display road surface conditions along routes on an existing ALKMaps.Layer.Routing layer, the visualizeRoutes method can be called. A routing layer is the required parameter for the method. The addRoutePath method enables you to add a new route on the layer. Route ID and route elements object are required parameters for the method. If duration in minutes, an optional parameter, is supplied to the method, it is used to calculate the temporal offset for each point in the route path.

One easy way to get route elements is by calling the getRouteElements method from a routing layer. In case you want to create the route elements from scratch, route elements object has two properties: routelegs and stops. Each route leg is an object of ALKMaps.Feature.Vector type. The vector feature has a collection of objects with ALKMaps.Geometry.Point type as the geometry components. Each stop is an object of ALKMaps.Feature.Vector type. The vector feature has an object with ALKMaps.Geometry.Point type as the geometry property.

var roadSurfaceRouteLayer = new ALKMaps.Layer.RoadSurfaceRoute(
  "ALK Road Surface with Route"
);

To view a demo with road surface conditions along routes and some useful techniques for customizing your layer, please visit the Road Surface Route example page and view the source code.

Last updated November 5, 2019.