1
votes

I'm using the BM REST geocoding service, to obtain the Lat/Lng values for determined addresses. But, for some reason, the API returns sometimes incorrect values. For example, let's take this address: 1310 Prairie St Houston Texas United States.

If I put this address in https://www.bing.com/maps, shows a correct pushpin and this lat/lng: 29.758762, -95.359230.

If I call the REST api using: http://dev.virtualearth.net/REST/v1/Locations?addressLine=1310%20Prairie%20St%20Houston%20Texas%20United%20States&o=json&jsonp=PointCallback&key=MYKEY, the API returns a completely incorrect value, very, very far from the correct coordinates.

39.443256378173828 -98.95733642578125

Even, I tried adding 'clues' to the URL, but nothing: http://dev.virtualearth.net/REST/v1/Locations?CountryRegionIso2=US&adminDistrict=TX&adminDistrict2=Harris&addressLine=1310%20Prairie%20St%20Houston%20Texas%20United%20States&o=json&jsonp=PointCallback&key=MYKEY

If I try this same address, but using the google geocoding API: https://maps.googleapis.com/maps/api/geocode/xml?address=1310+Prairie+St+Houston+Texas+United+States&key=MYKEY, the returned value is correct.

Any ideas what I'm doing wrong here?

1
Why is this tagged google-maps-api-3?geocodezip
I added the google-maps-api-3 tag because I have referenced inside the question code for the google geocoding API v3.BernieSF
But your question doesn't involve that tag at all, it is the "working reference", or did I misunderstand?geocodezip
Yes, is a working reference. Tag removed.BernieSF

1 Answers

1
votes

The addressLine value is for the street address part of an address, not the full address. If you want to pass in a full address as a single string you have to use the query parameter instead. The reason for this is that the individual address parameters will be used as is against the geocoder, where as the query parameter is parsed into its individual parts. Here is a modified version of your query:

http://dev.virtualearth.net/REST/v1/Locations?query=1310%20Prairie%20St%20Houston%20Texas%20United%20States&incl=queryParse&key=Your_Bing_Maps_Key

You can also find documentation on this here: http://msdn.microsoft.com/en-us/library/ff701711.aspx

Also, just a point for best practices, you should use commas in your address like the following as that's the correct format according to the US postal service to format an address as a single string. "1310 Prairie St, Houston, Texas, United States".

I also recommend checking out this blog post on best practices when using the REST services: http://blogs.bing.com/maps/2013/02/14/bing-maps-rest-service-tips-tricks/