Tile layers on and off and a bug?

Last post 3/14/2009 12:25:20 AM by Chris Pietschmann. 1 replies. << Back to Web.Maps.VE v2.0 General
2/20/2009 1:55:01 PM
spont

Tile layers on and off and a bug?

Here are a few comments and queries.
1.Is it possible to turn tile layers on and off  on the server side?
I have found a way of turning tile lyers of and on on the client side using
 map.HideTileLayer(mapnam) and  map.ShowTileLayer(mapnam) where mapnam is the ID of the TileSourceSpecification.
But I can't seem to do this from the server side. In G.I.S. applications turning on and off layers is quite important in order to give clarity to the back-ground  mapping.

2. Opacity of tile layers ?
when creating a tile layer one can set the opacity - is it possible to change the opacity after loading the tiles? - this code seems to set the opacity on the client side but has no effect on the map
var tilee = $find("<%=TileLayerExtender1.ClientID%>");
 tilee.tilesources(0).Opacity=0.1
 on the server side the code
TileLayerExtender1.TileSources(0).Opacity=0.1 sets the value but no effect on the screen.
(same for maxzoom and minzoom)

Possible bug?
using Map1.LatLong to center from a button works once but if you scroll the map and press the button again the Map1.LatLong is ignored. the only solution seems to be a zoom command before the Map1.LatLong command.

3/14/2009 12:25:20 AM
Chris Pietschmann

Re:Tile layers on and off and a bug?

1) The Web.Maps.VE control doesn't currently support the HideTileLayer and ShowTileLayer methods directly. However, it does only require a tiny amount of JavaScript to be written to Show/Hide TileLayers from the Server on an Asynchronous Postback.

Just place these JavaScript methods in the Page:

function HideTileLayer(tileLayerID) {
    var map = $find("<%=Map1.ClientID%>").get_Map();
    map.HideTileLayer(tileLayerID);
}
function ShowTileLayer(tileLayerID) {
    var map = $find("<%=Map1.ClientID%>").get_Map();
    map.ShowTileLayer(tileLayerID);
}

Then you can call these methods from server-side code during an asynchronous postback using the following lines of code:

System.Web.UI.ScriptManager.RegisterStartupScript(
    this, this.GetType(),
    "myScriptKey",
    "HideTileLayer('TilerLayerID')",
    true);

System.Web.UI.ScriptManager.RegisterStartupScript(
    this, this.GetType(),
    "myScriptKey",
    "ShowTileLayer('TilerLayerID')",
    true);

2) The Virtual Earth JavaScript API itself actually doesn't support changing the TileLayer Opacity after the TileLayer has already been added to the Map. This is actually the reason this feature hasn't been added to Web.Maps.VE.

However, there is a small work around using JavaScript that you can do by Deleting the TileLayer and then re-Adding with a different Opacity value set. Below is some example code of how to do this using a tiny amount of JavaScipt code.

Place this JavaScript method in the Page:

function SetTileLayerOpacity(tileLayerID, opacityValue) {
    // Get a reference to the VEMap object that's within the Web.Maps.VE control
    var map = $find("<%=Map1.ClientID%>").get_Map();
   
    // Get TileLayer
    var layer = map.GetTileLayerByID(tileLayerID);

    // Set new Opacity Value
    layer.Opacity = opacityValue;

    // Delete Existing TileLayer from Map
    map.DeleteTileLayer(tileLayerID);

    // Re-Add the TileLayer with new Opacity
    map.AddTileLayer(layer);
}

Then use this code during an Asynchronous Postback to Change the TileLayer's Opacity:

System.Web.UI.ScriptManager.RegisterStartupScript(
    this, this.GetType(),
    "myScriptKey",
    "SetTileLayerOpacity('TilerLayerID', 1.0)",
    true);


Possible Bug with Map.LatLong


I'm not sure what your saying is the bug. I've fully tested (and double checked for this post) setting the Map.LatLong to change the Map's center point during an asynchronous postback, and everything works as expected. If I'm not understanding what your issue is, please re-explain it further.

Thanks, Let me know if you have any further questions.