locked
How to geocode multiple address concurrently . RRS feed

  • Question

  • Here is the Scenario:

    I have around 50 addresses in a list, I want to geocode them and then display them on map. But to do the same, we use rest api in Ajax control to geocode, but then how to handle multiple callback functions which return the geocoordinates.

    In the code for Ajax API V7

    var geocodeRequest1 = http://dev.virtualearth.net/REST/v1/Locations/India?output=json&jsonp=GeocodeCallback&key=bingmapkey

    ......

    which calls the callback function "Geocodecallback" for returning the result.

    But if i make request calls in a loop, the callback is asynchronous and there will be multiple callbacks at same time and I won't be able to match the callback to the request. (Means address to the corresponding geo-coordinate).

    And If I had to wait for each request to be completed it will take too much time for geocoding all addresses.

    Can anyone please help me regarding the issue. And what is the best solution

    Thanks,

    Jitendra


    Thanks, Jitendra
    • Moved by Ricky_Brundritt Friday, March 9, 2012 6:30 PM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, July 12, 2011 3:23 PM

Answers

  • Pass a jsonso state object value to match up requests with responses: http://msdn.microsoft.com/en-us/library/ff701701.aspx
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:57 PM
    Tuesday, July 12, 2011 6:43 PM
  • There are two ways to go about this. The first is to make recursive calls to the geocoding service which will then ensure that the addresses are geocoded in sequence. The second is to geocode your data ahead of time (this is a best practice and is highly recommended).
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:57 PM
    Wednesday, July 13, 2011 12:42 AM

All replies

  • Pass a jsonso state object value to match up requests with responses: http://msdn.microsoft.com/en-us/library/ff701701.aspx
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:57 PM
    Tuesday, July 12, 2011 6:43 PM
  • Thanks a lot :)
    Thanks, Jitendra
    Tuesday, July 12, 2011 7:12 PM
  • There are two ways to go about this. The first is to make recursive calls to the geocoding service which will then ensure that the addresses are geocoded in sequence. The second is to geocode your data ahead of time (this is a best practice and is highly recommended).
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:57 PM
    Wednesday, July 13, 2011 12:42 AM
  • Hello 

    can you send me the code for above solution i tried but it is not working.

    thanks

    Krishna deepika

    Tuesday, October 23, 2018 11:34 AM