I am looking for an online web service to get Lat, Long values for the addresses using Arcgis Online Geocoding service. Please let me know if there is any dll or online web service to get the results using .Net Framework 4.0 and Visual Studio 2010.
Thanks for your reply.
While going through documentation, I found this link: http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates to get lat, long from the address provided. Can I use this link from .Net code?
If so, do I need to create a .Net wrapper for authentication and get token to get the results?
Yes, we have to use .Net framework 4.0 only. Is dll mandatory for using Geocoding service? Please let me know if there is any alternative way like using web services.
One option is to write the task logic by hand and access the rest endpoint from your own code. We provide existing tasks in our SDK's to communicate with the service but in some cases rolling your own implementation might be an option.
If you want to go that route, please refer ArcGIS REST API: World Geocoding Service documentation for rest spec and authentication details.
ArcGIS REST API should be good for my development purposes. As mentioned, I found following links: http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?<PARAMETERS> and https://www.arcgis.com/sharing/oauth2/token?client_id=<YOUR CLIENT ID>&grant_type=client_credentials&client_secret=<YOUR CLIENT SECRET>&f=pjson for authentication and generating token.
Can you help me out with a sample .Net code to generate token? Thanks for your help.
We also provide out-of-the-box implementations for authentication in the SDK's but for more details how to implement it, please refer authentication documentation. What comes to c# implementation, you might want to check if there are 3rd party libraries that provides implementation for OAUTH 2.0.
I am using following url to get lat, long: http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?Address=Sta... Pagar&Subregion=&Region=&CountryCode=SGP&outFields=Addr_type&maxLocations=1&forStorage=false&f=pjson and able to get the results, when Address is provided along with Country.
But for some addresses, require Lat, Long for Country only. However, when I just input country code, the result is not correct. For eg.,
http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?Address=&Ne.... Is there a way, we can get center of the Country geocodes?
I haven't had success either in getting a consistent geocode result using just a country code ("USA" seems to work, others do not).
There's an example on the developers.arcgis.com site that does this successfully (https://developers.arcgis.com/en/features/geocoding/), but uses a combination of "suggest" (to get the desired country) and "find" (to retrieve the result).
One option is to simply query a country boundary service for the geometry and find the center (of the extent, e.g.). For example:
var queryTask = new QueryTask(new Uri(queryUrl));
var queryExp = "ISO = '" + this.CountryTextBox.Text + "'"; // SG, US, DK, for example (two-letter codes)
// var queryExp = "Country ='" + this.CountryTextBox.Text + "'"; // Singapore, United States, Denmark, for example
var countryQuery = new Query(queryExp);
var result = await queryTask.ExecuteAsync(countryQuery);
if (result.FeatureSet.Features.Count > 0)
var countryExtent = result.FeatureSet.Features.Geometry.Extent as Envelope;
var countryCenter = countryExtent.GetCenter();
MessageBox.Show("Center of '" +
this.CountryTextBox.Text + "' is " +
countryCenter.X.ToString() + " : " +
MessageBox.Show("No results found for '" + this.CountryTextBox.Text + "'.");
I know this is slightly off topic, but would just like to point out that .NET 4.0 is losing support on January 12, 2016:
So you only have a few months left before you have to upgrade anyway.