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.
Solved! Go to Solution.
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.
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.
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.