Start a local feature service and display its features in a map.
Use case
For executing offline geoprocessing tasks in your ArcGIS Runtime apps via an offline (local) server.
How to use the sample
A Local Server and Local Feature Service will automatically be started. Once started then a FeatureLayer
will be created and added to the map.
How it works
- Create and run a local server with
LocalServer.Instance
. - Start the server asynchronously with
Server.StartAsync()
. - Create and run a local feature service.
- Instantiate
LocalFeatureService(Url)
to create a local feature service with the given url path to mpk file. - Start the service asynchronously with
LocalFeatureService.StartAsync()
. The service will be added to the local server automatically.
- Instantiate
- Create an event handler for the
LocalFeatureService.StatusChanged
event. This will run whenever the status of the local service has changed. - When the service's status has changed to
Started
, create a feature layer from local feature service.- Create a
ServiceFeatureTable(Url)
using the URL for the feature layer. - Create feature layer from service feature table using
new FeatureLayer(ServiceFeatureTable)
. - Load the layer asynchronously using
FeatureLayer.LoadAsync()
.
- Create a
- Add feature layer to map using
Map.OperationalLayers.Add(FeatureLayer)
.
Relevant API
- FeatureLayer
- LocalFeatureService
- LocalServer
- LocalServerStatus
- StatusChangedEvent
Offline data
This sample downloads the following items from ArcGIS Online automatically:
- PointsofInterest.mpkx - This map package is included in the ArcGIS Runtime sample data.
Additional information
Local Server can be downloaded for Windows and Linux platforms from the developers website. Local Server is not supported on macOS.
Tags
feature service, local, offline, server, service
Sample Code
<UserControl x:Class="ArcGISRuntime.WPF.Samples.LocalServerFeatureLayer.LocalServerFeatureLayer"
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" />
</Grid>
</UserControl>