Search code examples
javascriptdom-eventsvirtual-earthmappoint

Virtual Earth adding pushpins by address - events firing out of order


I’ve been working on a mapping project to display service orders for a utility company but I’m having some issues getting the numbering on my pins and the info boxes. The following is a small segment of the page I’m working with to demonstrate the issue.
http://www.evocommand.com/junk_delete_me/virtual_earth_testing/VirtualEarthTest.html

Once you open it there is a link at the top for “Test Pins” that will render 5 pushpins to the screen.

I believe the problem lies is in the order of events. The pins are generated by address lookups using the map.Find() within a function called AddPushpinByAddress(). The problem is all 5 calls to AddPushpinByAddress() are firing before in begins to fire the callback functions from the final parameter of Map.Find() -- which is where the pins are actually created. The end result is that all 5 pins in the example get rendered with the pin number, title and description of the last pin rendered. Any suggestions?


Solution

  • using a local or global "var" or multiple instances was unsuccessful.

    I eventually gave up and used "setTimeout()" in javascript to force a delay and allow virtual earth to find the location before it received input on the next pushpin. I'm sure there are better methods, but practicality in the name of progress won out of perfection/accuracy.