Create an empty layer and where should i save it? Javascript API

108
1
04-09-2021 01:36 AM
Labels (1)
MarcusBrostrm
New Contributor

Hello! Me and my friend are currently working on project using JS with Arcgis API and have two questions.

1. How do you create a completely new empty layer that you can add geometries to in Arcgis js api?

2. Where should this new layer be saved? Is it a database or something like a catalog that i've read about?

Really enjoying the project so far and want to thank in advance for the help! 🙂

0 Kudos
1 Reply
DavidBlanchard
Esri Contributor

Hi Marcus,

If you goal is to allow someone to draw new features (e.g. lines, polygons, or points) on the map, you would need to add either a GraphicsLayer or a Feature Layer to your map. The following samples will likely help you get started:

However, if your goal is to save them, the easiest option is to create a Hosted Feature Layer in ArcGIS Online. You can then read and save your changes to this Hosted Feature Layer.

To do this, you will need an ArcGIS Online account. If you do not already have such an account, you can sign-up for a free developer account at https://developers.arcgis.com/ which will provide you with a small amount of storage to get started.

Once on the developer site with an account, you can create a hosted feature layer by going to the Layers section, then + Create data and choosing the New hosted layer (Feature layer) option. The page will then walk you through creating a new hosted feature layer.

DavidBlanchard_0-1618240146076.png

Once you have a hosted feature layer, you can follow this tutorial to add it to your ArcGIS API for JavaScript map: Add a feature layer.

If you want to allow the end user to edit the features (e.g. add a new polygon), you will find instructions in the Edit feature data tutorial.

Best of luck and have fun!

David

0 Kudos