Posted by david on 7. December 2008 20:41
CSS Anchor styles [The right way to do it]
#topBar a:link, a:visited
{
color: #00CCFF;
text-decoration: none;
font-size: small;
font-family: 'Lucida Sans Unicode';
}
#topBar a:hover
{
color: #66FFFF;
text-decoration: none;
font-size: small;
font-family: 'Lucida Sans Unicode';
}
Comments: 23
Filed Under:
Tags:
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.
Posted by david on 7. December 2008 15:11
Success!
iterates through the layers on the map, adding each ShapeLayer to a List. Then iterates through the ShapeLayer Collection, spitting out the ID of the each layer to the footer.
StringBuilder newBuilder = new StringBuilder();
// define the layer list
List<ShapeLayer> layerList = new List<ShapeLayer>();
// get the count of the layers on the map
int layercount = ScubaMap.GetShapeLayerCount();
// iterate through the map layers, adding the layers to layerList
for (int i = 0; i < layercount; i++)
{
layerList.Add(ScubaMap.GetShapeLayerByIndex(i));
}
// iterate through the layerList, appending the ID of the layerList element
// to a string
for (int i = 0; i < layerList.Count; i++)
{
newBuilder.Append(i.ToString());
newBuilder.Append(" ");
newBuilder.AppendLine(layerList[i].ID.ToString());
}
// print content of stringbuilder to the footer
txtLayerInfo.Text = newBuilder.ToString();
the same pattern should hold for the shapes …
Also, I’ve got a empty text box in which a kml url can go … hit the button & it shows up .. woot
some kml files
dsc.discovery.com/utilities/googleearth/nationalparks/nationalparks.kml
www.communitywalk.com/xml/kml/1074
Posted by david on 3. December 2008 23:07
Made a new copy of the latest version … was trying to clean up unused css divs but screwed up the page somehow
So after futzing with it for a while, I just recopied. & slowly renamed the divs. Think the problem might have been renaming divs on the css side first?
looks fine in IE, breaks in Firefox fk fk fk fk fk
a very sweet VE site: Fresh Logic Studios - Atlas
Virtual Earth Control 100% height problem - Solved! Well almost at Earthware Blog
could never get the dynamic width/height thing working across browsers. Worked fine in IE, pretty ugly in Firefox.
So I gave up, specified a size for the map, and got busy on making it look nice …
inspired by the aforementioned Fresh Logic Atlas – used absolute positioning to lay a transparent column over the map, to contain the buttons & it looks pretty sweet
I broke my count update somewhere along the way, but I think it’s a minor glitch because the error occurs in all browsers.
Posted by david on 2. December 2008 22:50
Solved the mystery of the extra empty layers
I was following instructions from - well I can’t remember where I saw it – but for whatever reason, I was doing the geoRss import in three steps:
ShapeLayer aGeoRSSLayer = new ShapeLayer();
ScubaMap.AddShapeLayer(aGeoRSSLayer);
ScubaMap.ImportShapeLayerData(new ShapeSourceSpecification(DataType.GeoRSS, "http://david.egerton.info/Storage/1992hurricaneandrew.xml", aGeoRSSLayer), "", true);
the second step was adding an empty layer – somewhere someone said you had to add an empty layer in which you would import the shapes … however what actually happens is that in the third step, a new layer is added with the shapes. At the end of the shapesourcespec, the previously created layer is named but the control seems to ignore that & just add another layer. So how does one add or delete a shape from existing layer ??
Anyway, knocking out that 2nd step stopped the empty layers being added
get counts at the layer level – code below
to work around the delay between initiating the layer add, add a timed update to the counts & text area
Matt Berseth Using the AJAX Timer Control as an UpdatePanel Trigger
ASP.NET AJAX The Timer Control Introduction to the Timer Control
ASP.NET Ajax Update Panel
this worked … dropped a timer inside of the left bar update panel. @ 15 sec, refreshes, calling the updateLitInfo method which updates the counts in the left bar and the text box below. Cool.
Work on the display … I viewed the page @ K’s and the map got dropped below the left bar.
Narrow the left bar … currently 175 pixels.
loosen up the sizing on the map
worked – help on the fluid layout from here
things moving very very slowly … not sure whether my net connection is hanging or what …
Here is the result
private void UpdateLayerTextInfoLit()
{
int layercount = ScubaMap.GetShapeLayerCount();
StringBuilder builder = new StringBuilder();
for (int i = 1; i <= layercount; i++)
{
builder.Append(" Layer count ");
builder.Append(i.ToString());
builder.Append(" of ");
builder.Append(layercount.ToString());
builder.Append(";");
builder.Append(" ID is: ");
builder.Append(ScubaMap.GetShapeLayerByIndex(i - 1).ID);
builder.Append(";");
builder.Append(" Shapecount is: ");
int currentShapecount = ScubaMap.GetShapeLayerByIndex(i - 1).GetShapeCount();
builder.AppendLine(currentShapecount.ToString());
}
string testString = builder.ToString();
txtLayerInfo.Text = testString;
//builder.ToString();
}
Posted by david on 2. December 2008 19:25
out of nowhere, it seems, I am having problems with the Microsoft.Live.ServerControls
error: “Could not load file or assembly ‘Microsoft.Live.ServerControls.VE’ or one of its dependencies. The system cannot find the file specified.” all code references to the map controls are underlined
googling around, see advice to make sure “Microsoft.Live.ServerControls.VE.dll” is in the bin folder. I check, the file is shown, but updating reference causes an error, something like file not found.
Tried a repair installation of the Live Controls SDK, from my installation file. Didn’t immediately help. Trying a restart of VS08.
Deleted the file & page is now broken.
Build Page .. same errors, was hoping it would auto add the file. So, wtf is that file located?
Close project, open up an VE Sample project. see if I can get it from there.
found a reference file path: ….\Visual Studio 2008\WebSites\VESamples\VirtualEarthASPNETSamples\bin\Microsoft.Live.ServerControls.VE.dll
open up divesite again & manually add the dll to the bin …
failed – couldn’t find the path specified, even though I browsed to the file.
Successfully added the dll to the root of the site, rather than to the bin.
Copied from root to the bin, got a warning saying it already exists, OK’d that then got “Cannot add the file vs83e0.tmp to the local cache. The system cannot find the path specified.”
Refreshed the bin folder … file appears … but a rebuild of the page still can’t find the control dll
added a reference, a copy of the dll was sitting in root, so chose that one. That fixed it., though I’m still seeing the “Could not load” errors, however all the map references are not underlined anymore.
closed & rebuild the page. it works now. whew.