Find the service area within a network from a given point.
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
- Create a new
ServiceAreaTask
from a network service. - Create default
ServiceAreaParameters
from the service area task. - Set the parameters to return polygons (true) to return all service areas.
- Add a
ServiceAreaFacility
to the parameters. - Get the
ServiceAreaResult
by solving the service area task using the parameters. - Get any
ServiceAreaPolygons
that were returned. - Display the service area polygons as graphics in a
GraphicsOverlay
on theMapView
.
Relevant API
- PolylineBarrier
- ServiceAreaFacility
- ServiceAreaParameters
- ServiceAreaPolygon
- ServiceAreaResult
- ServiceAreaTask
Tags
barriers, facilities, impedance, logistics, routing
Sample Code
<UserControl x:Class="ArcGISRuntime.WPF.Samples.FindServiceArea.FindServiceArea"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri: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"
Click="PlaceFacilityButton_Click"
Content="Place facility" />
<Button Name="DrawBarrierButton"
Grid.Row="0"
Grid.Column="1"
Margin="5,5,5,5"
Click="DrawBarrierButton_Click"
Content="Draw barrier" />
<Button Name="ShowServiceAreasButton"
Grid.Row="3"
Grid.ColumnSpan="2"
Margin="5,5,5,5"
Click="ShowServiceAreasButton_Click"
Content="Show service areas" />
<Button Name="ResetButton"
Grid.Row="4"
Grid.ColumnSpan="2"
Margin="5,5,5,5"
Click="Reset_Click"
Content="Reset" />
</Grid>
</Border>
</Grid>
</UserControl>