Fetching Zipcodes falling in between the routes Final and End destination using MapQuest API

131 Views Asked by At

I need to fetch zipcodes falling all along the route using MapQuest API.Plz suggest i tried to find on mapquest forum as well as on stack .I also did google but can't manage to find appropriate solution.

Ex : Suppose i define a Route from point A to Point B. Now i need to fetch all zipcodes falling in between this route.

1

There are 1 best solutions below

0
On

You'll want to look at the Corridor Search, which is part of the Search API Web Service. You have two options; you can either pass in the shapePoints that make up the route (corridor) that you want to search along, or you can use the Directions API to calculate a route and then use the sessionId from the Directions API response as input into the Search request.

Here's an example using the Directions API in conjunction with the Search API:

  1. Use the Directions API to calculate a route between two points. In this example, I'm calculating a route between Denver, CO and Aurora, CO: http://www.mapquestapi.com/directions/v2/route?key=YOUR-APP-KEY-GOES-HERE&from=Denver,CO&to=Aurora,CO

  2. Locate the sessionId parameter in the response.

  3. Use the Search API to perform a corridor search on the uspostalcodes table. I'm also filtering the results from the table to include just the name of the postal code and none of the other info that is available in the table. http://www.mapquestapi.com/search/v2/corridor?key=YOUR-APP-KEY-GOES-HERE&sessionId=YOUR-SESSION-ID-GOES-HERE&width=1&buffer=0&hostedData=mqap.uspostalcodes|||POSTCODE

You can adjust the width/buffer options as well to refine your search. Hope this helps!