Select to view content in your preferred language

How to add shapefile on basemap without open file dialog

4705
2
Jump to solution
01-06-2015 01:35 PM
MarilynGambone
Deactivated User

Hi,

I'm trying to modify the JavaScript for adding shapefile to a basemap (script found here:  Add shapefile | ArcGIS API for JavaScript ).  However, I'm trying to get this functionality on my website whereby user specifies the shapefile's filename; then behind the scene, the script retrieves the shapefile from a folder in the website and adds the specified shapefile to the basemap.

 

How do I do this?  Been trying but unsuccessful.  I have an HTML button that I want the user to click and (without navigating to the location of the shapefile--since it's a website), the shapefile is added.  So, I'm trying to achieve something like the following for the button:

 

 

<button type="submit" id="btnAddShp" name="Command" value="Add Shapefile" class="btn btn-cyan2 btn-sm" onclick="addShapefile()">Add Shapefile</button>

 

Appreciate any help.

0 Kudos
1 Solution

Accepted Solutions
PaulCrickard
Deactivated User

It sounds like you are trying to load a shapefile that already exists on the server, is that correct? The example uploads a shapefile from the users computer to the server then loads it.

If you already have the file on the server, better just serve it up as a service. If you don't have arcserver, convert it to KML or something easier to work with. Looks like no way to just load a shapefile in the API. Pretty sad on ESRIs part considering they the only ones who use .shp.

You could also upload the shapefile to arcgis online then save the map and load it.

View solution in original post

0 Kudos
2 Replies
PaulCrickard
Deactivated User

It sounds like you are trying to load a shapefile that already exists on the server, is that correct? The example uploads a shapefile from the users computer to the server then loads it.

If you already have the file on the server, better just serve it up as a service. If you don't have arcserver, convert it to KML or something easier to work with. Looks like no way to just load a shapefile in the API. Pretty sad on ESRIs part considering they the only ones who use .shp.

You could also upload the shapefile to arcgis online then save the map and load it.

0 Kudos
MarilynGambone
Deactivated User

Hi,

Yes. The shapefiles already exist on the server.  I guess I really need to install the ArcGIS Server version in our production server because there are thousands of shapefiles that the user can select from (it's going to be quite a task to convert each one to KML).  I still don't have the ArcGIS Server; so I'm trying to see if the JavaScript API can work without using a service.  I guess not.

Thanks for your reply.

0 Kudos