Offline routing

View inWPFUWPFormsiOSAndroid
View on GitHub

Solve a route on-the-fly using offline data.

Image of offline routing

Use case

You can use an offline network to enable routing in disconnected scenarios. For example, you could provide offline location capabilities to field workers repairing critical infrastructure in a disaster when network availability is limited.

How to use the sample

Tap near a road to start adding a stop to the route, tap again to place it on the map. A number graphic will show its order in the route. After adding at least 2 stops, a route will display. Choose "Fastest" or "Shortest" to control how the route is optimized. The route will update on-the-fly while moving stops. The green box marks the boundary of the routable area provided by the offline data. This sample limits routes to 5 stops for performance reasons.

How it works

  1. Create the map's Basemap from a local tile package using a TileCache and ArcGISTiledLayer
  2. Create a RouteTask with an offline locator geodatabase.
  3. Get the RouteParameters using routeTask.CreateDefaultParameters()
  4. Create Stops and add them to the route task's parameters.
  5. Solve the Route using routeTask.SolveRouteAsync(routeParameters)
  6. Create a graphic with the route's geometry and a SimpleLineSymbol and display it on another GraphicsOverlay.

Offline data

The data used by this sample is available on ArcGIS Online.

About the data

This sample uses a pre-packaged sample dataset consisting of a geodatabase with a San Diego road network and a tile package with a streets basemap.

Relevant API

  • RouteParameters
  • RouteResult
  • RouteTask
  • Stop
  • TravelMode


connectivity, disconnected, fastest, locator, navigation, network analysis, offline, routing, routing, shortest, turn-by-turn

Sample Code

            BindingContext="{x:Reference Name=ResponsiveFormContainer}"
            Style="{StaticResource MapWithFormStyle}"
            ViewInsets="0,250,0,0" />
        <resources:ResponsiveFormContainer x:Name="ResponsiveFormContainer">
                            <OnPlatform x:TypeArguments="GridLength">
                                <On Platform="UWP" Value="45" />
                                <On Platform="Android, iOS" Value="Auto" />
                            <OnPlatform x:TypeArguments="GridLength">
                                <On Platform="UWP" Value="45" />
                                <On Platform="Android, iOS" Value="Auto" />
                            <OnPlatform x:TypeArguments="GridLength">
                                <On Platform="UWP" Value="30" />
                                <On Platform="Android, iOS" Value="Auto" />
                <Label Grid.Row="0" Text="Click the map to add up to 5 stops. Route lines will be displayed automatically." />
                    ItemDisplayBinding="{Binding Name}"
                    VerticalOptions="CenterAndExpand" />