AbhiRoczz...
AbhiRoczz...

Reputation: 252

Bing maps 7.0 Geocode Rest service Callback functions not called

Hi I am using a bing maps 7.0 ajax api to display map. I have several addresses which i geocode to get latitude and longitude using rest services in javascript. I have setup up a GeocodeCallback method in the geocode request.

geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?"+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&jsonso="+mapDataAddress[0]+"&key="+credentials; CallRestService(geocodeRequest);

When the address are found i get a response in my GeocodeCallback function but for few address i dont get a response. How to figure out this status and error.

Upvotes: 0

Views: 1127

Answers (2)

rbrundritt
rbrundritt

Reputation: 17954

Also take a look at the Tips and Tricks for using the Bing Maps REST services listed here: http://www.bing.com/blogs/site_blogs/b/maps/archive/2013/02/14/bing-maps-rest-service-tips-amp-tricks.aspx

Upvotes: 0

austinrf
austinrf

Reputation: 38

I figured this out. So basically you need to do two things.

  • You need to change your URL structure. I have found out that sometimes if I have weird address, bing will return a 400.
  • use the suppressStatus parameter and set it to true. I can't find the docs at this moment but basically I have found that if bing returns a 400,404,etc it won't actually call the callBack function. So supressstatus says that no matter what, always return a 200.

Orignially you have:

http://dev.virtualearth.net/REST/v1/Locations?"+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&jsonso="+mapDataAddress[0]+"&key="+credentials;

So you want to do this:

http://dev.virtualearth.net/REST/v1/Locations?addressLine="+mapDataAddress[1]+"&output=json&jsonp=GeocodeCallback&suppressStatus=true&jsonso="+mapDataAddress[0]+"&key="+credentials;

Upvotes: 2

Related Questions