Changing the height of the map from a button

Last post 4/11/2009 5:24:55 PM by Medwyn. 2 replies. << Back to Web.Maps.VE v2.0 General
4/10/2009 4:58:18 PM
Medwyn

Changing the height of the map from a button

I've currently got a map on the screen. What i'd like to do is change the height of the map when the user clicks on a button.

I can set the .Height property of the map in the c# code behind the button but this doesn't seem to have any effect.

Anyone know of an easy way this can be accomplished?

Cheers,

Medwyn

4/10/2009 8:16:50 PM
Chris Pietschmann

Re:Changing the height of the map from a button

The current version (v2.00.03) and earlier doesn't have the ability built in to resize the map from within server-side code. The ability to do this will be in the next update release (v2.00.04) of the control.

Below are a couple JavaScript methods that demonstrate how to resize the Map. The first example shows how to resize a Map using v2.00.03 and the second example show how to do it using the next v2.00.04 update release.

// Using Version 2.00.03 and earlier
function increaseMapSize() {
    // Get a reference to the Simplovation.Web.Maps.VE.Map
    // JavaScript Object
    var map = $find("<%=Map1.ClientID %>");

    // Get a reference to the main DIV that makes up and contains
    // the entire Simplovation.Web.Maps.VE.Map control.
    // This DIV is the container for the Virtual Earth Map.
    var mapContainerDiv = map.get_element();

    // Get the Current Size of the Map
    var mapHeight = mapContainerDiv.offsetHeight;
    var mapWidth = mapContainerDiv.offsetWidth;

    // Increase the desire height and width values
    mapHeight += 200;
    mapWidth += 200;

    // Resize the Virtual Earth Map itself
    map.Resize(mapWidth, mapHeight);
   
    // Resize the entire Map Control (aka DIV that
    // contains the Virtual Earth Map)
    mapContainerDiv.style.height = mapHeight + "px";
    mapContainerDiv.style.width = mapWidth + "px";
}

// Using Version 2.00.04 and later
function increaseMapSize() {
    // Get a reference to the Simplovation.Web.Maps.VE.Map
    // JavaScript Object
    var map = $find("<%=Map1.ClientID %>");

    // Get the Current Size of the Map
    var mapHeight = map.GetHeight();
    var mapWidth = map.GetWidth();

    // Increase the desire height and width values
    mapHeight += 200;
    mapWidth += 200;

    // Resize the Virtual Earth Map itself
    map.Resize(mapWidth, mapHeight);
}

4/11/2009 5:24:55 PM
Medwyn

Re:Changing the height of the map from a button

Thanks.

That worked perfectly.