Select to view content in your preferred language

Retrieve postal codes by city

705
1
05-20-2014 10:08 PM
TimKetelaars
New Contributor
Hi,

I need to find a postal code when searching for a city. I know this can of course result in multiple postal codes but I only need one. It doesn't really matter which one, but I prefer the one in the center. Does anyone know if this is possible and how? For now I can search for a city, but no postal codes are returned. Background: I need a postal code to send to another service, which returns differtent addresses which should be shown on a map.

Kind regards,
Tim
0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor
Hi Tim,

I was able to find a way to do this by passing the XY coordinates from the locator results to the locationToAddress method.  Then using the location-to-address-complete event I was able to retrieve the zip.  Take a look at this working example here.