Posted by david on 17. December 2008 18:40
Where I’m At:
- list collection is powering the grid view.
- Still takes a bit for a layer to update, to register … wondering if I can do something to fix that, cache the layers, make them invisible,
I just realized what is happening with the layer loads & why my baselayer title was not sticking: I was naming the title before the layer loading had completed. When i called the ShapeLayer(0).Title = “Base Layer” & then the databind, the layer was seen, but ShapeLayer.DataLoaded was still false. Whatever I wrote to that property was lost when the layer finished loading and the layer(0) defaults set.
So, knowing that there’s probably a smarter way to do this, i got it working like so:
pageload does the initial datasource statement & the first databind. Then it calls on UpdateLayerList. UpdateLayerList will be used by all other events that change the map. UpdateLayerList checks to see if layer(0) has finished loading & if it has, it changes the title - before carrying on building the layerList.
protected void updateLayerList()
{
// clear out the list
LayerList.Clear();
// get the count of layers on the map
int layercount = ScubaMap.GetShapeLayerCount();
// check to see if the baselayer is loaded
if (ScubaMap.GetShapeLayerByIndex(0).DataLoaded)
{
// if so, change the title.
ScubaMap.GetShapeLayerByIndex(0).Title = "Base Layer";
}
// iterate through the map layers, adding the layers to layerList
for (int i = 0; i < layercount; i++)
{
LayerList.Add(ScubaMap.GetShapeLayerByIndex(i));
//if (!LayerList.Contains(ScubaMap.GetShapeLayerByIndex(i)))
}
// rebind
Grid1.DataBind();
}
this is version 2008_12_17
Comments: 29
Filed Under:
Tags: