dynamically create a feature layer - in javascript

3377
8
08-09-2011 08:23 PM
MuraliUppala
New Contributor
Hi,

I am creating an application, where the user has to upload a csv file(from browser)and visualize it on the map.

Can we dynamically create a feature layer(or editable layer) and save it on server?, so that the user can view the data in future and edit data.

I have seen this use case on arcgis.com(in maps tab). Creating a editable layer and save it. Does any one have an idea, how they implemented it?

Please let me know. Its very urgent :(.

Thanks in advance.

Thank you,
Murali
0 Kudos
8 Replies
StephenLead
Regular Contributor III
Can we dynamically create a feature layer(or editable layer) and save it on server?, so that the user can view the data in future and edit data.


I don't know about making it editable, but you can create a feature layer from a feature collection (which you could generate from your CSV file).

See the example here for some pointers.

Good luck,
Steve
0 Kudos
MuraliUppala
New Contributor
I don't know about making it editable, but you can create a feature layer from a feature collection (which you could generate from your CSV file).

See the example here for some pointers.

Good luck,
Steve


Thanks for the quick reply Steve.

That sample really helped me. But can I save it in backend(as layer or something) for future use? so that the user need not upload each time?

Thanks,
Murali
0 Kudos
StephenLead
Regular Contributor III
can I save it in backend(as layer or something) for future use? so that the user need not upload each time?


I'm not sure, but I don't think this is possible within the ArcGIS Server JSAPI.

You might be able to automate something using an external process, by saving the values at the end of a session, storing them somewhere, and re-loading them when the next session starts.

How to actually do this is totally beyond my knowledge, but hopefully someone can help. You could also try posting the question on http://gis.stackexchange.com

Good luck,
Steve
0 Kudos
MuraliUppala
New Contributor
I'm not sure, but I don't think this is possible within the ArcGIS Server JSAPI.

You might be able to automate something using an external process, by saving the values at the end of a session, storing them somewhere, and re-loading them when the next session starts.

How to actually do this is totally beyond my knowledge, but hopefully someone can help. You could also try posting the question on http://gis.stackexchange.com

Good luck,
Steve


Thanks for the help Steve.

I will post the question there.

Thanks,
Murali
0 Kudos
HaroldBostic
Occasional Contributor II
If I had this requirement, I would look to creating a geoprocess to handle the input.  For faster response, you could take and parse the text on the client and create a graphics layer.  In the background you could send a request to a gp service and pass it the graphics.  The gp service could then "copy_features" those graphics into your gdb.  your gdb could already have a featureclass ready to be added to.

That same featureclass could then be added to a mapservice and published to arcgiserver.  that service can be loaded as a feature layer when the app starts so all previous session data will be available moving forward
0 Kudos
MuraliUppala
New Contributor
If I had this requirement, I would look to creating a geoprocess to handle the input.  For faster response, you could take and parse the text on the client and create a graphics layer.  In the background you could send a request to a gp service and pass it the graphics.  The gp service could then "copy_features" those graphics into your gdb.  your gdb could already have a featureclass ready to be added to.

That same featureclass could then be added to a mapservice and published to arcgiserver.  that service can be loaded as a feature layer when the app starts so all previous session data will be available moving forward


Hi Harold,

Can we create a mapservice and publish on arcgisserver dynamically(on the fly)?
I am pretty much new to arcgis, so I am not sure if that is valid question.

Thank for the reply,

Thanks,
Murali
0 Kudos
HaroldBostic
Occasional Contributor II
I am not aware of anyway to do that at this time, at least with python/out of the box gp tools.  If you are familiar with ArcObjects, there may by an Interface their that provides that capability.  If so, you could create a Server Object Extension and publish that to ArcGIS Server
0 Kudos
KenMorefield
Occasional Contributor
You could look at this sample for one idea:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/exp/exp_localstorage.html

This will allow the user to save edits on their own computer, but it will only work with some browsers. 

A better way to go would be to set up a geoprocessing service that appends graphics (created from your .csv file) into a feature class on the server.  I do this in some of my applications, when I want to allow bulk uploads of data from the user to a mapservice.  There was a sample that ESRI put out (it might have been Sterling Quinn) which included sample data as well as a sample model for publishing to a geoprocessing service.  I use this particular sample for many editing tasks, allowing me to edit the FILE GEODATABASE that my data is contained in.  It is not the quickest process to run, but if you are appending dozens or hundreds of features at one time, it may end up being quicker than editing one record at a time the built in editing capabilities of the api.

Ken
0 Kudos