Select to view content in your preferred language

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

8845
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
HemingZhu
Occasional 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.


I have done a POC for my potenial projects. I ran a GP to append a uploaded shape file to an existing feature layer in a map service where the GP layer is also located. You are looking similiar approach except you might have to truncate the featurelayer before upload the shape file.
0 Kudos
San_DiegoManagement___Monitori
New Contributor II

Hi Heming

I realize this post is very old now, but I am trying to append a shapefile to an existing feature layer also. Can you give me some more information on how you did that?

Thanks

Emily

0 Kudos
PanagiotisPapadopoulos
Esri Regular Contributor

an another option is to create a geoprocessing service on your Server to do it.

The script will have as input parameter zip file with the Shapefile contents.

the input zip will extracted and then you can load the data on a feature class.

The feature class will be output parameter in order to take the shapefile data as graphics using javascript.

here is a code example for

#extract the zip

zf = zipfile.ZipFile(inShpZip)
FeaturesPath = arcpy.env.scratchFolder + "/zipSHPExtract"
zf.extractall(FeaturesPath)

#find the shp
shpFilesFromZip = glob.glob(FeaturesPath + "/*.shp")

#copy Features 

outFeatures = arcpy.env.scratchGDB + "/outFeatures1"
arcpy.CopyFeatures_management(shpFilesFromZip[0], outFeatures)

0 Kudos
nicogis
MVP Frequent Contributor
you can use esri.request and use api arcgis portal
see sample: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/portal_addshapefile.html
0 Kudos