Using ImportShapeLayerData and Custom Icons

I have a layer of pushpins that is working fine but I am uncertain of how to change the icons for these pushpins.

Should it be stored in the XML or is it set globally for the layer?

-Chris

[207 byte] By [Athfar] at [2008-1-4]
# 1
Chris,

There's a thread that discusses this here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1692076&SiteID=1

In particular, I've posted up a general guideline on how to do this here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1664041&SiteID=1

Hope that helps,

DerekChan at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 2

hrmmm... Just out of curiosity is there some limitation to how many push pins that should be used with a regular VEShape call?

I have about 100 pushpins so far to map but there could be alot more than that.

Athfar at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 3

I'm lost as to what has to happen in the Callback function...

Here's what I have:

Code Snippet

function drawPins()
{
var existingLayer = new VEShapeLayer();
var veLayerSpec = new VEShapeSourceSpecification(VEDataType.GeoRSS, 'url', 'existingLayer');

existingLayer.Hide();
map.ImportShapeLayerData(veLayerSpec, onFeedLoad, 1);
existingLayer.Show();
}

function onFeedLoad()
{
Shape.SetCustomIcon(Shape.IconId);
}

I know the callback isn't right I don't think...

Athfar at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 4
The pushpin limit is endless although once you get around 200+ it just eats up too much memory and slows to a crawl depending on CPU performance.
DerekChan at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 5

Try something like this:

Code Snippet

function onFeedLoad(layer)
{
layer.Hide();
var numShapes = layer.GetShapeCount();
for(var i=0; i < numShapes; ++i)
{
var s = layer.GetShapeByIndex(i);

s.SetCustomIcon("<div class='pin'></div>");
}
layer.Show();
}

Basically, you're looping through all of the shapes you just added. Mine removes the pushpin, but yours can do whatever you'd like.
jhofker at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...

Windows Live Developer Forums

Site Classified