Local Server feature layer

View on GitHub
Sample viewer app

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

screenshot

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 the Local Server.

    • LocalServer::instance creates the Local Server.
    • LocalServer::start() starts the server asynchronously.
  2. Wait for server to be in the LocalServerStatus::Started state.

    • LocalServer::statusChanged() fires whenever the running status of the Local Server changes.
  3. Create and run a local service. For example, to run a LocalMapService:

    • new LocalFeatureService(Url) creates a local feature service with the given URL path to the map package (mpkx file).
    • LocalFeatureService::start() starts the service asynchronously.
    • The service is added to the Local Server automatically.
  4. Wait for feature service to be in the LocalServerStatus::Started state.

    • LocalFeatureService::statusChanged() signal fires whenever the status of the Local Service changes.
  5. Create a feature layer from local feature service.

    • Create a ServiceFeatureTable(Url) from local feature service URL, LocalFeatureService::url().
    • Create a FeatureLayer using the service feature table.
    • Add the feature layer to the map's operational layers.
    • Connect to the feature layer's LoadStatusChanged signal.
    • When the feature layer's status is Loaded, set the map view's extent to the layer's full extent.

Relevant API

  • FeatureLayer
  • LocalFeatureService
  • LocalFeatureService::statusChanged
  • LocalServer
  • LocalServerStatus

Offline Data

Read more about how to set up the sample's offline data here.

Link Local Location
PointsOfInterest Pro Map Package <userhome>/ArcGIS/Runtime/Data/mpkx/PointsofInterest.mpkx

Additional information

Local Server can be downloaded for Windows and Linux platforms. Local Server is not supported on macOS.

Tags

feature service, local, offline, server, service

Sample Code

LocalServerFeatureLayer.qmlLocalServerFeatureLayer.cppLocalServerFeatureLayer.h
                                
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
// [WriteFile Name=LocalServerFeatureLayer, Category=LocalServer]
// [Legal]
// 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
// http://www.apache.org/licenses/LICENSE-2.0

// 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.
// [Legal]

import QtQuick 2.6
import Esri.Samples 1.0

LocalServerFeatureLayerSample {
    id: localServerFeatureLayerSample
    width: 800
    height: 600

    // Create MapQuickView here, and create its Map etc. in C++ code
    MapView {
        anchors.fill: parent
        objectName: "mapView"
        // set focus to enable keyboard navigation
        focus: true
    }
}

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