Click or drag to resize

Stop Class

A class that represents a location to be visited along a route.
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.Tasks.NetworkAnalysis
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version:
public sealed class Stop

The Stop type exposes the following members.

Public methodCode exampleStop
Initializes a new instance of the Stop class.
Public propertyArrivalCurbApproach
Gets arrival curb approach.
Public propertyArrivalTime
Gets the stop's arrival time in UTC.
Public propertyArrivalTimeShift
Gets the time-zone shift for arrival time for this stop.
Public propertyCurbApproach
Gets or sets curb approach.
Public propertyCurrentBearing
Gets or sets current bearing in degrees.
Public propertyCurrentBearingTolerance
Gets or sets the current bearing tolerance in degrees. Valid values are 0 to 180.
Public propertyDepartureCurbApproach
Gets departure curb approach.
Public propertyDepartureTime
Gets the stop's departure time in UTC.
Public propertyDepartureTimeShift
Gets the time-zone shift for departure time for this stop.
Public propertyDistanceToNetworkLocation
Gets distance to network location in meters.
Public propertyGeometry
Gets the stop's point geometry.
Public propertyLocationStatus
Gets location status.
Public propertyCode exampleName
Gets or sets the stop name.
Public propertyNavigationLatency
Gets or sets the navigation latency in seconds.
Public propertyNavigationSpeed
Gets or sets the navigation speed in meters per second.
Public propertyNetworkLocation
Gets or sets the network location.
Public propertyRouteName
Gets or sets the route name.
Public propertySequence
Gets sequence.
Public propertyStopId
Gets or sets the stop ID.
Public propertyStopType
Gets or sets stop's type.
Public propertyTimeWindowEnd
Gets or sets time window end in UTC.
Public propertyTimeWindowStart
Gets or sets time window start in UTC.
Public propertyViolationTime
Gets violation time.
Public propertyWaitTime
Gets wait time.
Public methodGetAddedCost
Gets added cost.
Public methodGetCumulativeCost
Gets the cumulative cost attribute value.
Public methodSetAddedCost
Sets added cost.
The Stop class contains location inputs for the Route_task. The Route_task will create a route between two or more Stops. A Stop object is not an arbitrary bag of properties, but contains only the properties needed for routing (for example, a Stop object does not have address information).


Example Name: MobileMapSearchAndRoute

Display maps and use locators to enable search and routing offline using a Mobile Map Package.

Code example screen shot.

// Copyright 2019 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Android.App;
using Android.Graphics;
using Android.Graphics.Drawables;
using Android.OS;
using Android.Widget;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.Tasks.Geocoding;
using Esri.ArcGISRuntime.Tasks.NetworkAnalysis;
using Esri.ArcGISRuntime.UI;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace ArcGISRuntimeXamarin.Samples.MobileMapSearchAndRoute
    [Activity(ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
        name: "Mobile map (search and route)",
        category: "Map",
        description: "Display maps and use locators to enable search and routing offline using a Mobile Map Package.",
        instructions: "A list of maps from a mobile map package will be displayed. If the map contains transportation networks, the list item will have a navigation icon. Tap on a map in the list to open it. If a locator task is available, tap on the map to reverse geocode the location's address. If transportation networks are available, a route will be calculated between geocode locations.",
        tags: new[] { "disconnected", "field mobility", "geocode", "network", "network analysis", "offline", "routing", "search", "transportation" })]
    public class MobileMapSearchAndRoute : Activity
        // Hold references to the UI controls.
        private MapView _myMapView;
        private LinearLayout _mapListView;

        // Hold references to map resources for easy access.
        private List<Map> _maps = new List<Map>();
        private LocatorTask _packageLocator;
        private TransportationNetworkDataset _networkDataset;

        // Overlays for use in visualizing routes.
        private GraphicsOverlay _routeOverlay;
        private GraphicsOverlay _waypointOverlay;

        // Track the start and end point for route calculation.
        private MapPoint _startPoint;
        private MapPoint _endPoint;

        protected override void OnCreate(Bundle bundle)

            Title = "Mobile map (search and route)";


        private async void Initialize()
            // Get the path to the package on disk.
            string filePath = DataManager.GetDataFolder("260eb6535c824209964cf281766ebe43", "SanFrancisco.mmpk");

            // Open the map package.
            MobileMapPackage package = await OpenMobileMapPackage(filePath);

            // Populate the list of maps.
            foreach (Map map in package.Maps)
                await map.LoadAsync();

            // Show the first map by default.
            _myMapView.Map = _maps.First();

            // Get the locator task from the package.
            _packageLocator = package.LocatorTask;

            // Create and add an overlay for showing a route.
            _routeOverlay = new GraphicsOverlay();
            _routeOverlay.Renderer = new SimpleRenderer
                Symbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Blue, 3)

            // Create and add an overlay for showing waypoints/stops.
            _waypointOverlay = new GraphicsOverlay();

            // Enable tap-to-reverse geocode and tap-to-route.
            _myMapView.GeoViewTapped += MapView_Tapped;

            // Show list of maps in the UI.

        private async Task<MobileMapPackage> OpenMobileMapPackage(string path)
            // Open the map package.
            MobileMapPackage package = await MobileMapPackage.OpenAsync(path);

            // Load the package.
            await package.LoadAsync();

            // Return the opened package.
            return package;

        private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
            // Handle routing.
                await ProcessRouteRequest(e.Location);
            catch (Exception exception)
                new AlertDialog.Builder(this).SetMessage("Couldn't geocode or route.").SetTitle("Error").Show();

        private async Task ShowGeocodeResult(MapPoint tappedPoint)
            // Reverse geocode to get an address.
            IReadOnlyList<GeocodeResult> results = await _packageLocator.ReverseGeocodeAsync(tappedPoint);

            // Process the address into usable strings.
            string address = results.First().Label;

            // Show the address in a callout.
            _myMapView.ShowCalloutAt(tappedPoint, new CalloutDefinition(address));

        private async Task ProcessRouteRequest(MapPoint tappedPoint)
            // Clear any existing overlays.

            // Return if there is no network available for routing.
            if (_networkDataset == null)
                await ShowGeocodeResult(tappedPoint);

            // Set the start point if it hasn't been set.
            if (_startPoint == null)
                _startPoint = tappedPoint;

                await ShowGeocodeResult(tappedPoint);

                // Show the start point.
                _waypointOverlay.Graphics.Add(await GraphicForPoint(_startPoint));


            if (_endPoint == null)
                await ShowGeocodeResult(tappedPoint);

                // Show the end point.
                _endPoint = tappedPoint;
                _waypointOverlay.Graphics.Add(await GraphicForPoint(_endPoint));

                // Create the route task from the local network dataset.
                RouteTask routingTask = await RouteTask.CreateAsync(_networkDataset);

                // Configure route parameters for the route between the two tapped points.
                RouteParameters routingParameters = await routingTask.CreateDefaultParametersAsync();
                List<Stop> stops = new List<Stop> { new Stop(_startPoint), new Stop(_endPoint) };

                // Get the first route result.
                RouteResult result = await routingTask.SolveRouteAsync(routingParameters);
                Route firstRoute = result.Routes.First();

                // Show the route on the map. Note that symbology for the graphics overlay is defined in Initialize().
                Polyline routeLine = firstRoute.RouteGeometry;
                _routeOverlay.Graphics.Add(new Graphic(routeLine));


            // Reset graphics and route.
            _startPoint = null;
            _endPoint = null;

        private async Task<Graphic> GraphicForPoint(MapPoint point)
            // Get current assembly that contains the image.
            Assembly currentAssembly = Assembly.GetExecutingAssembly();

            // Get image as a stream from the resources.
            // Picture is defined as EmbeddedResource and DoNotCopy.
            Stream resourceStream = currentAssembly.GetManifestResourceStream(

            // Create new symbol using asynchronous factory method from stream.
            PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream);
            pinSymbol.Width = 60;
            pinSymbol.Height = 60;
            // The image is a pin; offset the image so that the pinpoint
            //     is on the point rather than the image's true center.
            pinSymbol.LeaderOffsetX = 30;
            pinSymbol.OffsetY = 14;
            return new Graphic(point, pinSymbol);

        private void Map_Selected(Map selectedMap)
            // Clear existing overlays.

                // Show the map in the view.
                _myMapView.Map = selectedMap;

                // Get the transportation network if there is one. Will be set to null otherwise.
                _networkDataset = selectedMap.TransportationNetworks.FirstOrDefault();
            catch (Exception exception)
                new AlertDialog.Builder(this).SetMessage(exception.ToString()).SetTitle("Couldn't select map").Show();

        private async void configureMapsButtons()
            foreach (Map map in _maps)
                Button mapButton = new Button(this);
                if (map.TransportationNetworks.Any())
                    mapButton.Text = $"{map.Item.Title} (✔)";
                    mapButton.Text = $"{map.Item.Title}";

                mapButton.Background = Drawable.CreateFromStream(await map.Item.Thumbnail.GetEncodedBufferAsync(), "");
                mapButton.Click += (o, e) => { Map_Selected(map); };

                LinearLayout.LayoutParams lparams = (LinearLayout.LayoutParams)mapButton.LayoutParameters;
                lparams.SetMargins(5, 5, 0, 5);
                mapButton.LayoutParameters = lparams;

        private void CreateLayout()
            // Create a new vertical layout for the app.
            var layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Add a help label.
            TextView helpLabel = new TextView(this);
            helpLabel.Text = "Tap to show address. If a network is available, you can show a route between tapped points. Maps with networks are denoted with ✔.";

            // Add space for adding options for each map.
            _mapListView = new LinearLayout(this) { Orientation = Orientation.Horizontal };

            // Add the map view to the layout.
            _myMapView = new MapView(this);

            // Show the layout in the app.

Xamarin Forms Android

Example Name: FindRoute

Display directions for a route between two points.

Code example screen shot.

// Copyright 2017 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.Tasks.NetworkAnalysis;
using Esri.ArcGISRuntime.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
using Colors = System.Drawing.Color;

namespace ArcGISRuntime.Samples.FindRoute
        name: "Find route",
        category: "Network analysis",
        description: "Display directions for a route between two points.",
        instructions: "For simplicity, the sample comes loaded with a start and end stop. You can tap on the Find Route button to display a route between these stops. Once the route is generated, turn-by-turn directions are shown in a list.",
        tags: new[] { "directions", "driving", "navigation", "network", "network analysis", "route", "routing", "shortest path", "turn-by-turn" })]
    public partial class FindRoute : ContentPage
        // List of stops on the route ('from' and 'to')
        private List<Stop> _routeStops;

        // Graphics overlay to display stops and the route result
        private GraphicsOverlay _routeGraphicsOverlay;

        // URI for the San Diego route service
        private Uri _sanDiegoRouteServiceUri = new Uri("");

        // URIs for picture marker images
        private Uri _checkedFlagIconUri = new Uri("");

        private Uri _carIconUri = new Uri("");

        public FindRoute()

            // Create the map, graphics overlay, and the 'from' and 'to' locations for the route

        private void Initialize()
            // Define the route stop locations (points)
            MapPoint fromPoint = new MapPoint(-117.15494348793044, 32.706506537686927, SpatialReferences.Wgs84);
            MapPoint toPoint = new MapPoint(-117.14905088669816, 32.735308180609138, SpatialReferences.Wgs84);

            // Create Stop objects with the points and add them to a list of stops
            Stop stop1 = new Stop(fromPoint);
            Stop stop2 = new Stop(toPoint);
            _routeStops = new List<Stop> { stop1, stop2 };

            // Picture marker symbols: from = car, to = checkered flag
            PictureMarkerSymbol carSymbol = new PictureMarkerSymbol(_carIconUri);
            PictureMarkerSymbol flagSymbol = new PictureMarkerSymbol(_checkedFlagIconUri);

            // Add a slight offset (pixels) to the picture symbols.
            carSymbol.OffsetX = -carSymbol.Width / 2;
            carSymbol.OffsetY = -carSymbol.Height / 2;
            flagSymbol.OffsetX = -flagSymbol.Width / 2;
            flagSymbol.OffsetY = -flagSymbol.Height / 2;

            // Set the height and width.
            flagSymbol.Height = 60;
            flagSymbol.Width = 60;
            carSymbol.Height = 60;
            carSymbol.Width = 60;

            // Create graphics for the stops
            Graphic fromGraphic = new Graphic(fromPoint, carSymbol) { ZIndex = 1 };
            Graphic toGraphic = new Graphic(toPoint, flagSymbol) { ZIndex = 1 };

            // Create the graphics overlay and add the stop graphics
            _routeGraphicsOverlay = new GraphicsOverlay();

            // Get an Envelope that covers the area of the stops (and a little more)
            Envelope routeStopsExtent = new Envelope(fromPoint, toPoint);
            EnvelopeBuilder envBuilder = new EnvelopeBuilder(routeStopsExtent);

            // Create a new viewpoint apply it to the map view when the spatial reference changes
            Viewpoint sanDiegoViewpoint = new Viewpoint(envBuilder.ToGeometry());
            MyMapView.SpatialReferenceChanged += (s, e) => MyMapView.SetViewpoint(sanDiegoViewpoint);

            // Add a new Map and the graphics overlay to the map view
            MyMapView.Map = new Map(Basemap.CreateStreets());

        private async void SolveRouteClick(object sender, EventArgs e)
                // Create a new route task using the San Diego route service URI
                RouteTask solveRouteTask = await RouteTask.CreateAsync(_sanDiegoRouteServiceUri);

                // Get the default parameters from the route task (defined with the service)
                RouteParameters routeParams = await solveRouteTask.CreateDefaultParametersAsync();

                // Make some changes to the default parameters
                routeParams.ReturnStops = true;
                routeParams.ReturnDirections = true;

                // Set the list of route stops that were defined at startup

                // Solve for the best route between the stops and store the result
                RouteResult solveRouteResult = await solveRouteTask.SolveRouteAsync(routeParams);

                // Get the first (should be only) route from the result
                Route firstRoute = solveRouteResult.Routes.First();

                // Get the route geometry (polyline)
                Polyline routePolyline = firstRoute.RouteGeometry;

                // Create a thick purple line symbol for the route
                SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Purple, 8.0);

                // Create a new graphic for the route geometry and add it to the graphics overlay
                Graphic routeGraphic = new Graphic(routePolyline, routeSymbol) { ZIndex = 0 };

                // Get a list of directions for the route and display it in the list box
                DirectionsListBox.ItemsSource = firstRoute.DirectionManeuvers.Select(direction => direction.DirectionText);
            catch (Exception ex)
                await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK");

        private void ResetClick(object sender, EventArgs e)
            // Clear the list of directions
            DirectionsListBox.ItemsSource = null;

            // Remove the route graphic from the graphics overlay (only line graphic in the collection)
            int graphicsCount = _routeGraphicsOverlay.Graphics.Count;
            for (int i = graphicsCount; i > 0; i--)
                // Get this graphic and see if it has line geometry
                Graphic g = _routeGraphicsOverlay.Graphics[i - 1];
                if (g.Geometry.GeometryType == GeometryType.Polyline)
                    // Remove the graphic from the overlay

        private void ShowHideDirectionsList(object sender, EventArgs e)
            // Show the directions frame if it's hidden; hide if it's shown
            DirectionsFrame.IsVisible = !DirectionsFrame.IsVisible;
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""
            <RowDefinition Height="Auto"/>
        <esriUI:MapView x:Name="MyMapView"/>
        <Frame x:Name="DirectionsFrame" 
               BackgroundColor="WhiteSmoke" Opacity=".85"
                HorizontalOptions="FillAndExpand" VerticalOptions="Start"
                Margin="5" Padding="5">
                <Label Text="Route directions:" 
                           Margin="0,0,0,2" />
                <ListView x:Name="DirectionsListBox"
        <StackLayout Grid.Row="1"
            <Button x:Name="SolveRouteButton"
                        Text="Solve Route"
            <Button x:Name="ResetButton"
            <Button x:Name="ShowHideDirectionsButton"
See Also
Additional Examples
Hyperlink to ExampleDescription
FindRouteDisplay directions for a route between two points.
MobileMapSearchAndRouteDisplay maps and use locators to enable search and routing offline using a Mobile Map Package.
NavigateRouteUse a routing service to navigate between points.
NavigateRouteReroutingNavigate between two points and dynamically recalculate an alternate route when the original route is unavailable.
OfflineRoutingSolve a route on-the-fly using offline data.
RouteAroundBarriersFind a route that reaches all stops without crossing any barriers.