3

I want to calculate distance between two zip code by bing map API. Is there any possible way to do this I tried this link but this is not for two zip code. Is there any way to do this.

I Pass ZIP1- 34481 and ZIP2- 34705 and want result 70.9 in miles i calculate this direct from bing map. Thanks for your response

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
A.Goutam
  • 3,422
  • 9
  • 42
  • 90

1 Answers1

0

From reading the article, the example as stands will give you a GEOGRAPHY point object (although not sure if your inputs are valid, it seems it require a street address). Anyway, call it twice then to determine the distance between the points returned use something like

Point1.STDistance(Point2)

Here's the BOL reference https://msdn.microsoft.com/en-us/library/bb933808.aspx

Alternatively, see this question for a Bing Routes API answer. How to calculate the driving distance between two points?

If you still need to geocode the approx centre of a zipcode, you might be better off importing the data yourself. I did this recently for the Australian GNAF data (https://www.rednotebluenote.com/2016/04/importing-psma-geocoded-national-address-file-g-naf-to-sql-server/ ) which you might find useful background reading. For US I believe http://census.gov/ makes something similar available.

Hope this is of use.

Community
  • 1
  • 1
Liesel
  • 2,929
  • 2
  • 12
  • 18
  • i have lat and long for the zip 1 and zip 2 and want driving distance what what will the api i need to call – A.Goutam Jul 11 '16 at 12:08
  • See the How to Calculate Driving Distance link. – Liesel Jul 11 '16 at 12:22
  • i m using Route API of bing my request is for service is `http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0=0.5871776,-1.472574&wp.1=0.5742378,-1.490571&avoid=minimizeTolls&distanceUnit=mi&o=xml&key=mykey` but i m getting `404` what i m doing mistake in this request – A.Goutam Jul 12 '16 at 09:57