views:

38

answers:

2

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?

A: 

You're exactly correct. Since you're using a global to hold the ID (and all other values) of the pin when it goes to write it, you'll get just the last value.

I'd create a new instance of the pushpin in your AddPushpinByAddress function and pass that pushpin to the callback to have the properties set. I have some similar code if you really need, but moving those out of globals and using either the pushpin object (or creating your own object) that you can pass will take care of this issue.

iivel
A: 

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.

jasonk