Friday, September 10, 2010

VE – accessing the shapes with a list

Posted by david on 7. December 2008 16:55

I know it’s possible to access shapes and layers directly using Map.ShapeLayer and ShapeLayer.Shape, but I wanted to pull them into separate constructs – the Lists – to work with them hopefully more quickly. 

This took a while to figure out and all along the way I kept wondering whether I should have just figured out how to do what I want directly. 

I don’t have an answer for that yet … but I learned more general c# by taking this path. 

The last task was to get the map layers into a List object that I could iterate through, accessing the layer properties & displaying them on the page.  The ultimate application will not be so crude, but now that I’m able to do this I will be able to make the page more interactive – hopefully I’ll also be able to speed things up. 

The coolest part, for me, is that I haven’t done a bit of javascript yet.  When we first started the divesite project, we were able to access the layer/shape info in javascript functions – but my goal was to get all this done in c# code behind.  So far so good.

Now that I have a List of ShapeLayer objects, I will iterate through the layers & access their shapes.  The problem, atm, is that a shape doesn’t appear to know what layer it belongs to.  Mulidimensional array?  Lists are 1 dimensional.  googling this problem indicates that creating a class, where the ShapeList is a property of a Layer is one option. 

That’s a little over my head atm ….

My immediate goal here is to write out the shape information.  I create a method that accepts a ShapeLayer object & returns a stringbuilder.  I iterate through the layers, as above, calling this shape method inside the loop.  That works.

Part of my output, here, is the ShapeLayer ID … & it turns out that the layerID is is built into the shape id:

LayerID: msftve_1001

has shapes:

ShapeID: msftve_1001_200009 Title: Andrew 08/19/92 06:00 Description: Tropical Storm, 45 mph, 1002 mb
ShapeID: msftve_1001_200010 Title: Andrew 08/19/92 12:00 Description: Tropical Storm, 45 mph, 1005 mb

So, I can parse out the layer ID from a shape.  Wonder how consistent that ID naming is … but id’s are assigned at the server, they do not result from the kml or georss or the like.

----------------

The page is working perfectly in IE, but it is breaking a little in firefox .. firebug shows an error when hitting update footer … but pressing it again gets the data

Same in Chrome … the initial press of update footer does nothing …  but a reClick fires it correctly.

Comments

Add comment


 

biuquote
Loading