Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am new to using the ArcGIS JavaScript API. I am currently trying to develop an application but I am having troubles with it.

The application I am developing uses a .csv file with a bunch of locations. The fields for each location are the address, zipcode, county, city, and state. It then geocodes each location and returns another .csv file with all the the address, zipcode, county, city, state, latitude, and longitude.

Using a .csv file to geocode the addresses isn't the important part, I could convert the .csv file into something else if necessary, what I am having trouble with is with the geocoding.

I looked at the samples online and the tutorials but did not find any that would geocode multiple addresses and that would return a file instead of just placing a mark on the map.

Could anyone please give me an idea of how this could be accomplished using the API? Tutorials/Samples would be extremely helpful.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Check out this answer also for some info What ArcGIS 10 geoprocessing tools support exporting tabular data to CSV?

Once you have a locator service, locator.addressesToLocations(options) is the API call to the locator http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/locator.html . However, none of the Esri sample servers let you batch geocode. You would need to set this up on your own ArcGIS Server. If you have a paid ArcGIS Online account you could do it there also.

As far as returning a csv file, one solution is to create your own geoprocessing service that wraps geocoding and places the finished file in the public output directory for download. You can then send the app the url of the file for a user to download.

Alternately, you could use flex or silverlight to receive the locator response, parse the json and save a csv file locally.

//this locator address is what it would look like, but you can't batch geocode (see above)
//var locator = new esri.tasks.Locator("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Geocode_USA/GeocodeServer");

var addresses = [{
  "OBJECTID": 0,
  "STREET": "440 Arguello Blvd",
  "ZONE": "94118"
}, {
  "OBJECTID": 1,
  "STREET": "100 Arguello Blvd",
  "ZONE": "94118"
}];

locator.outSpatialReference = map.spatialReference;

var options = {
  addresses: addresses
}

locator.addressesToLocations(options);

The addressesToLocations(options) will return an array of AddressCandidates. You can do whatever you like with them. You don't have to place on map. http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/addresscandidate.html

share|improve this answer
    
Thank you! I now know in what direction I should go to start my application. –  Emryss Apr 16 '13 at 1:48
1  
Btw, forgot to mention -- I've successfully used the jquery based DataTables library to create a very functional data grid, located here datatables.net. Relevant to your requirements, DataTables has a plugin called TableTools that can save table data as a CSV file among other things -- it includes a tiny flash plugin for the local file saving. It has worked well for me. You could potentially put json geometry into a column. See this post for a sample gis.stackexchange.com/questions/54442/… –  awesomo Apr 16 '13 at 17:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.