Local server feature layer

View on GitHub
Sample viewer app

Start a local feature service and display its features in a map.

Image of local server feature layer

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

  1. Create and run a local server with LocalServer.Instance.
  2. Start the server asynchronously with Server.StartAsync().
  3. Create and run a local feature service.

    1. Instantiate LocalFeatureService(Url) to create a local feature service with the given url path to mpk file.
    2. Start the service asynchronously with LocalFeatureService.StartAsync(). The service will be added to the local server automatically.
  4. Create an event handler for the LocalFeatureService.StatusChanged event. This will run whenever the status of the local service has changed.
  5. When the service's status has changed to Started, create a feature layer from local feature service.

    1. Create a ServiceFeatureTable(Url) using the URL for the feature layer.
    2. Create feature layer from service feature table using new FeatureLayer(ServiceFeatureTable).
    3. Load the layer asynchronously using FeatureLayer.LoadAsync().
  6. 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:

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

LocalServerFeatureLayer.xamlLocalServerFeatureLayer.xaml.cs
             
1
2
3
4
5
6
7
8
9
10
11
12
13
<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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <esri:MapView x:Name="MyMapView"/>
    </Grid>

</UserControl>

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