View on GitHub Sample viewer app
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

Add features to a feature layer.

Image of adding features

Use case

An end-user performing a survey may want to add features to the map during the course of their work.

How to use the sample

Click on a location on the map to add a feature at that location.

How it works

  1. Create and load a
    with a feature service URL.
  2. Get the
    from the service geodatabase.
  3. Create a
    from the service feature table.
  4. Create a
    with attributes and a location using the
    .
  5. Add the
    to the
    .
  6. Apply edits to the
    by calling
    , which will upload the new feature to the online service.

Relevant API

  • Feature
  • FeatureEditResult
  • FeatureLayer
  • ServiceFeatureTable
  • ServiceGeodatabase

Tags

edit, feature, online service

Sample Code

module-info.java module-info.java AddFeaturesSample.java
/*
* Copyright 2022 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.
*/
module com.esri.samples.add_features {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
exports com.esri.samples.add_features;
}