How to show esri shapefile on top of a map using arcgis javascript api

8510
13
03-24-2012 12:59 AM
SolidSmoke
New Contributor
Please advise me how to upload a esri shapefile and show it on top of a map using arcgis javascript api. I ve seen this doing using silverlight api and esrcontrib. Is ther anything like this available for esri javascript api.
0 Kudos
13 Replies
derekswingley1
Frequent Contributor
Upload your shapefile to ArcGIS.com, save your webmap and create your JS API map from the ArcGIS.com webmap that uses your shapefile.
0 Kudos
SolidSmoke
New Contributor
My client wants a Geospatial web application in which they need a facility to upload their shape file and view the same on top of map. So uploading the shapefile in ArcGIS.com will not work in my case. So please advise me how I can create the same functionality of ArcGIS.com using ArcGIS api for javascript.
0 Kudos
JeffPace
MVP Alum
My client wants a Geospatial web application in which they need a facility to upload their shape file and view the same on top of map. So uploading the shapefile in ArcGIS.com will not work in my case. So please advise me how I can create the same functionality of ArcGIS.com using ArcGIS api for javascript.


As far as I know this is not possible.  If it were, you would not need to purchase ArcGIS Server licenses.
0 Kudos
JamesVillanueva
New Contributor III
Take a look at this library: http://badassjs.com/post/845509816/r...ith-javascript

and the HTML5 CSV drag and drop example: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm

Combining the two together can provide you with the solution you need. Of course this assuming that you can use HTML5 in you're development.

The issues you'll find later: IE  - you're going to need a different solution as it doesn't support the file API, Safari will require a file input control as they don't support drag and drop, your going to be limited to newer browsers with html5 support, and your code will need to be written to support asynchronous file loading as you will need to wait for the dbf and shp files to both be loaded.
0 Kudos
StephenLead
Regular Contributor III
Along similar lines to James's approach, you could convert the shapefile to JSON then create a feature layer from the feature collection.
0 Kudos
SwapnaGogineni1
New Contributor
Hi Solid Smoke,

Did you ever find a solution for adding shapefiles using javascript api??

Thanks,
-Swapna
0 Kudos
HemingZhu
Occasional Contributor III
Hi Solid Smoke,

Did you ever find a solution for adding shapefiles using javascript api??

Thanks,
-Swapna


One approach i would give a try is to develop a GP tool where you could upload the shape file to a featurelayer on a map service.
0 Kudos
JeffPace
MVP Alum
There is no direct way.  You will have to either script or convert the data.
0 Kudos
Charles__Jamie_Phillips
New Contributor III
It can be done.  It would be easier as json/geojson/csv, but it is doable.  Here is a library that was written in js to do it:  https://github.com/RandomEtc/shapefile-js.

Basically, you are going to have to read it and make graphics from the data in the shapefile.  It may run a little slowly and will probably cause issues in IE if it is not fast enough since the javascript engine does not have the performance of the other browsers.  Hope this helps.
0 Kudos