Create a feature layer using code

791
4
Jump to solution
09-17-2013 11:06 AM
ChiranjeeviGK
New Contributor III
Hi

as in thetutorial we can create a feature layer thorugh code itself, and we can add the fetature on those.

my question is how i can save these feature layer in my online arcgis server, any API or REST or SOAP API's for this?

-Chiru
0 Kudos
1 Solution

Accepted Solutions
KenBurcham
Occasional Contributor
Hi Chiru,

  Like ZachLiu said, you'll need to create an empty feature class and publish it as a map service in order to be able to create features and save them as edits. 

One way you could make something that works like mapsengine would be to add a field to your new feature class called something like "EngineLayerId".  Then when your user creates a new layer, what you do is just add a query ("definition expression") to the feature service for the new EngineLayerId that would return just the features marked for that sort of "virtual" layer.  (I would also create another table called "EngineLayer" where you track these id's and most likely give them a name and associate them with your users, etc.).  This way, you are only showing a specific set of features at a time, which to your users would be very much like their own layer. 

Here's the FeatureLayer.setDefinitionExpression docs: https://developers.arcgis.com/en/javascript/jsapi/featurelayer-amd.html#setdefinitionexpression

There are probably other ways to do it, but making virtual layers with a query from a single feature service would be simple and might do just what you want.

Good luck!

ken.

View solution in original post

0 Kudos
4 Replies
ZachLiu1
Occasional Contributor II
Not very sure if this is what you want. It looks like you want to save a collection of features generated in the application.

Possible solution:

You can publish an empty feature service, add it to your app as a feature layer, and then save the features you want to
the service using featureLayer.applyEdit() method.
0 Kudos
ChiranjeeviGK
New Contributor III
i want to do somthing like map engine when i go to that page it will create default layer and we can add the points on it.

if we need another layer we can create by add layer button

So i dont want to make a empty layer from Online arcGIS, or else i need to make a empty layer from the code.

Thanks
Chiru
0 Kudos
KenBurcham
Occasional Contributor
Hi Chiru,

  Like ZachLiu said, you'll need to create an empty feature class and publish it as a map service in order to be able to create features and save them as edits. 

One way you could make something that works like mapsengine would be to add a field to your new feature class called something like "EngineLayerId".  Then when your user creates a new layer, what you do is just add a query ("definition expression") to the feature service for the new EngineLayerId that would return just the features marked for that sort of "virtual" layer.  (I would also create another table called "EngineLayer" where you track these id's and most likely give them a name and associate them with your users, etc.).  This way, you are only showing a specific set of features at a time, which to your users would be very much like their own layer. 

Here's the FeatureLayer.setDefinitionExpression docs: https://developers.arcgis.com/en/javascript/jsapi/featurelayer-amd.html#setdefinitionexpression

There are probably other ways to do it, but making virtual layers with a query from a single feature service would be simple and might do just what you want.

Good luck!

ken.
0 Kudos
ChiranjeeviGK
New Contributor III
This is good idea,

i will try this thank you ..
0 Kudos