jeremyeastburn


We are calling map.ImportShapeLayerData() several times to add multiple layers imported from a GeoRSS file.

I am looking for a way to loop through all layers, and then for each layer, loop through all the shapes/pinpoints and retrieve the GeoRSS latitude and longitude coordinates and store them in an array.

Any ideas on how to loop through every layer and then every shape in that layer Thanks!




Re: Loop through all layers and then loop through all shapes in layer

Earthware


Hi

Looping through the shapes in a shapelayer is easy enough, Im not aware of a way to loop through the shapelayers of a map though. You could just add each shapelayer to a js array as you load it and refer back to this array when you need to loop all the shapelayers.

Anywhere here is how to loop through the shapes for a given shapelayer

for(i=0;i<myshapelayer.GetShapeCount();i++){

var myshape = myshapelayer.GetShapeByIndexIdea;

}

Thats it, see the SDK for complete reference of a shapelayer:

http://msdn2.microsoft.com/en-us/library/bb412413.aspx

Brian Norman

www.earthware.co.uk






Re: Loop through all layers and then loop through all shapes in layer

Derek Chan

If you need to get the layers on the map, you can do the following:

1) Get the number of layers by using:

Code Snippet
var layerCount = map.GetShapeLayerCount();


2) get the layers by index:

Code Snippet
map.GetShapeLayerByIndex(currentLayerIndex);


Where currentLayerIndex is a counter that goes through layerCount.

Hope that helps,