Discussion:
Geocodes for city/state without street address or postal code
(too old to reply)
cpsc
2009-03-25 01:20:43 UTC
Permalink
I have tried both the GeocodeService and the SearchService to obtain the
lattitude/longitude for a specific city/state. My application does not have
street address or postal code (zipcode), it only has city and state.

When providing a query string such as "Chicago, IL" the GeoCodeService does
not return the proper coordinates for the city. Instead, it attempts to use
the city as a street name and then searches alphabetally through the cities
within the state until it finds a match.

Example: "Chicago, IL" returns Chicago St, Alvin, IL 61811
40.2982629521424,-87.6056455399844

Example source code:

// Set the full address query
geocodeRequest.Query = "Chicago, IL";

// Set the options to accept low confidence results
GeocodeService.ConfidenceFilter[] filters = new
GeocodeService.ConfidenceFilter[1];
filters[0] = new GeocodeService.ConfidenceFilter();
filters[0].MinimumConfidence = GeocodeService.Confidence.Low;
GeocodeService.GeocodeOptions geocodeOptions = new
GeocodeService.GeocodeOptions();
geocodeOptions.Filters = filters;
geocodeRequest.Options = geocodeOptions;

// Make the geocode request
GeocodeService.GeocodeServiceClient geocodeService = new
GeocodeService.GeocodeServiceClient();
geocodeResponse = geocodeService.Geocode(geocodeRequest);

What is the proper way to use the GeocodeService to obtain the lat/long for
a specific city/state?
cpsc
2009-03-25 18:53:03 UTC
Permalink
The answer to this question is found here
http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/e9b6090c-08c3-4afa-ac26-d3b03658051f/

The solution is to use the Address class instead of query text. Be sure to
use PostalTown for the city value. I had tried Locality but that doesn't
work.


// Set the full address query
//geocodeRequest.Query = "Chicago, IL";
AnalystStudioLiveMap.GeocodeService.Address exactAddress = new
AnalystStudioLiveMap.GeocodeService.Address();
exactAddress.PostalTown = city;
exactAddress.AdminDistrict = state;
geocodeRequest.Address = exactAddress;
Post by cpsc
I have tried both the GeocodeService and the SearchService to obtain the
lattitude/longitude for a specific city/state. My application does not have
street address or postal code (zipcode), it only has city and state.
When providing a query string such as "Chicago, IL" the GeoCodeService does
not return the proper coordinates for the city. Instead, it attempts to use
the city as a street name and then searches alphabetally through the cities
within the state until it finds a match.
Example: "Chicago, IL" returns Chicago St, Alvin, IL 61811
40.2982629521424,-87.6056455399844
// Set the full address query
geocodeRequest.Query = "Chicago, IL";
// Set the options to accept low confidence results
GeocodeService.ConfidenceFilter[] filters = new
GeocodeService.ConfidenceFilter[1];
filters[0] = new GeocodeService.ConfidenceFilter();
filters[0].MinimumConfidence = GeocodeService.Confidence.Low;
GeocodeService.GeocodeOptions geocodeOptions = new
GeocodeService.GeocodeOptions();
geocodeOptions.Filters = filters;
geocodeRequest.Options = geocodeOptions;
// Make the geocode request
GeocodeService.GeocodeServiceClient geocodeService = new
GeocodeService.GeocodeServiceClient();
geocodeResponse = geocodeService.Geocode(geocodeRequest);
What is the proper way to use the GeocodeService to obtain the lat/long for
a specific city/state?
Loading...