Find service area

View inMAUIUWPWPFWinUIView on GitHub

Find the service area within a network from a given point.

Image of find service area

Use case

A service area shows locations that can be reached from a facility based off a certain impedance, such as travel time or distance. Barriers can increase impedance by either adding to the time it takes to pass through the barrier or by altogether preventing passage.

You might calculate the region around a hospital in which ambulances can service in 30 min or less.

How to use the sample

In order to find any service areas at least one facility needs to be added to the map view.

  • To add a facility, click the facility button, then click anywhere on the map.
  • To add a barrier, click the barrier button, and click multiple locations on map. Hit the barrier button again to finish drawing barrier. Hitting any other button will also stop the barrier from drawing.
  • To show service areas around facilities that were added, click show service areas button.
  • The reset button clears all graphics and resets the service area task.

How it works

  1. Create a new ServiceAreaTask from a network service.
  2. Create default ServiceAreaParameters from the service area task.
  3. Set the parameters to return polygons (true) to return all service areas.
  4. Add a ServiceAreaFacility to the parameters.
  5. Get the ServiceAreaResult by solving the service area task using the parameters.
  6. Get any ServiceAreaPolygons that were returned.
  7. Display the service area polygons as graphics in a GraphicsOverlay on the MapView.

Relevant API

  • PolylineBarrier
  • ServiceAreaFacility
  • ServiceAreaParameters
  • ServiceAreaPolygon
  • ServiceAreaResult
  • ServiceAreaTask

Tags

Routing and Logistics, barriers, facilities, impedance

Sample Code

FindServiceArea.xamlFindServiceArea.xamlFindServiceArea.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<UserControl x:Class="ArcGIS.UWP.Samples.FindServiceArea.FindServiceArea"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri1="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esri1:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Button Name="PlaceFacilityButton"
                        Grid.Row="0" Grid.Column="0"
                        Margin="5,5,5,5"
                        Content="Place facility"
                        Click="PlaceFacilityButton_Click"
                        HorizontalAlignment="Stretch"
                        Width="Auto"/>
                <Button Name="DrawBarrierButton"
                        Grid.Row="0" Grid.Column="1"
                        Margin="5,5,5,5"
                        Content="Draw barrier"
                        Click="DrawBarrierButton_Click"
                        HorizontalAlignment="Stretch"/>
                <Button Name="ShowServiceAreasButton"
                        Grid.Row="3"
                        Grid.ColumnSpan="2"
                        Margin="5,5,5,5"
                        Content="Show service areas"
                        Click="ShowServiceAreasButton_Click"
                        HorizontalAlignment="Stretch"/>
                <Button Name="ResetButton"
                        Grid.Row="4"
                        Grid.ColumnSpan="2"
                        Margin="5,5,5,5"
                        Content="Reset"
                        Click="Reset_Click"
                        HorizontalAlignment="Stretch"/>
            </Grid>
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.