views:

625

answers:

2

Preface

I'm using the newly released Microsoft Virtual Earth SDK v6.2 which has built-in support for pushpin clustering. I realize there are custom ways of doing clustering where my question is easy to answer, but I'd like to leverage the built-in support as much as possible, so this question is specifically related to using the clustering feature of the VE 6.2 SDK.

The Problem

After enabling the built-in clustering (via VEShapeLayer.SetClusteringConfiguration), the clusters are created as expected, however, they have the default information in them which says something like "X items located here - zoom in to see details". In the app I'm working on, I need to display more information than that - I either need to allow the user to click on the pushpin and VE will automatically zoom in so that the points are now distinct OR display the names of the points in the infobox attached to the cluster pushpin. The catch is that cluster shape that VE creates for me does not appear to be editable until after all of the clustering logic has run...at that point, I don't know what original pushpins belong to that particular cluster. Is there a way to make this happen without resorting to creating a custom clustering implementation?

+1  A: 

In case others have this same issue, the answer was just posted over in the MSDN forum for VE:

http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/d55090e2-2f5c-459c-9ecd-c3f32f0505b3/

Adam Byram
A: 

We're doing precicely what I think you are asking for... Try this

// Create your map
var MapCtl = new VEMap('MapContainer');

// Create a layer for your pins
MapPinLayer = new VEShapeLayer();

// Add a callback that gets called every time the cluster config changes
var clusteringOptions = new VEClusteringOptions();
clusteringOptions.Callback = clusterCallback;

MapPinLayer.SetClusteringConfiguration(VEClusteringType.Grid, clusteringOptions);

// your cluster callback method
function clusterCallback(clusters) {
    for (var i = 0; i < clusters.length; ++i) {
        var cluster = clusters[i];
        var clusterShape = cluster.GetClusterShape();

        var clusterSize = cluster.Shapes.length;

        clusterShape.SetTitle('Some Title');
        clusterShape.SetDescription('There's ' + clusterSize + ' shops in this area');
    }
}
Markus Olsson