views:

68

answers:

0

I'm playing around a bit with Virtual Earth to see if we might be able to use it on our website.

We'll be plotting quite a bit of pins and many of them are going to be clustered using the excelent clustering abilities of VE.

I want to perform some action on the cluster shape (bouncing it, actually =) we have a custom div as the icon) when it is added to the map. I have a callback method for clustering and I use it to manipulate the icon and stuff like that. The problem is that the dom element for the shape doesn't exist until after the callback method has completed. I have not found any satisfying way of knowing when the shape has been added to the map.

// Our callback method looks a bit like this
function clusterCallback(clusters) {
    for (var i = 0; i < clusters.length; ++i) {
        var cluster = clusters[i];
        var clusterShape = cluster.GetClusterShape();

        clusterShape.SetCustomIcon('<div id="' + GetNewClusterId() + '" class="cluster">' + cluster.Shapes.length + '</div>');
    }
}

The best solution I've found so far (and I'm not happy about it) is to use setTimeout and enable the bounce effect 200ms after the cluster callback have completed...

Is there a better way? How would I go about getting notified when the shape is added to the map?