VEMap.Dispose Method

You are not viewing the latest version of the AJAX control. Bing Maps AJAX V7 is the recommended JavaScript control for Bing Maps. If you need this documentation, it is available in as a CHM or PDF download.

Deletes the VEMap object and releases any associated resources.

VEMap.Dispose();

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>

      <script type="text/javascript">
         var map = null;
         var selStyle = VEMapStyle.Aerial;
         var selMode = VEMapMode.Mode2D;
         var zoom = 4;
     
         // Demonstrate LoadMap, with a UI for trying out all of the parameters.
         function GetMap()
         {
            var latLon = new VELatLong(document.getElementById('txtLat').value, document.getElementById('txtLong').value); 
                
            if (document.getElementById('txtZoom').value > 0 && document.getElementById('txtZoom').value <= 19)
            {
               zoom = document.getElementById('txtZoom').value;
            }
            else
            {
               alert("Enter a value between 1 and 19.");
            }
         
            if (chkFixed.checked)
            {
               fixed=1;
            }
            else
            {
               fixed=0;
            }
         
            if (chkShowSwitch.checked)
            {
               showSwitch=1;
            }
            else
            {
               showSwitch=0; 
            }

            map = new VEMap('myMap'); 
            map.LoadMap(latLon, zoom, selStyle, fixed, selMode, showSwitch);

            map.AttachEvent("onobliqueenter", SetObliqueRadio);
            map.AttachEvent("onobliqueleave", SetObliqueRadio);
         }   
     
         function SetStyle(s)
         {
            selStyle = s;
         }
     
         function SetMode(m)
         {
            if (modeRadios.mode[0].Checked)
            {
               selMode = VEMapMode.Mode2D;
            }
            else
            {
               selMode = VEMapMode.Mode3D;
            }
         }
     
         function SetObliqueRadio(event)
         {
            if (event.eventName == "onobliqueenter")
            {
               styleRadios.style[3].disabled=null;
            }
            else if (event.eventName == "onobliqueleave")
            {
               styleRadios.style[3].disabled="disabled";
            }
         }

         function DisposeMap()
         {
            if(map != null)
            {
              map.Dispose();
            }
         }
      </script>
   </head>
   <body onload="GetMap();" onunload="DisposeMap();" style="font-family:Arial">
      <div id='myMap' style="position: relative; width: 400px; height: 400px;">
      </div>
      <input id="btnLoad" type="button" onclick="GetMap()" value="Load A Map" />
      <br />
      Lat: <input id="txtLat" value="36.13371559517861" />
      <br />
      Lon: <input id="txtLong" value="-115.16238212585449" />
      <br />
      Zoom Level (1-19): <input id="txtZoom" value="9" style="width: 50px" />
      <br />
      Fixed: <input id="chkFixed" type="checkbox" /> (check to prevent user interaction)
        <br />
      Show Switch: <input id="chkShowSwitch" type="checkbox" checked="checked"/> 
      (show the map mode switch on the dashboard control)

      <table width="400px">
         <tr>
            <td align="left" width="60%">
               <form id="styleRadios">
                  Road: <input name="style" type="radio" onclick="SetStyle('r')" /> | 
                  Aerial: <input name="style" type="radio" onclick="SetStyle('a')" checked="checked" />
                  <br />
                  Hybrid: <input name="style" type="radio" onclick="SetStyle('h')" /> | 
                  Oblique: <input name="style" type="radio" onclick="SetStyle('o')" disabled="disabled"/>
               </form>
            </td>
            <td align="left">
               <form id="modeRadios">
                  2D: <input name="mode" type="radio" onclick="SetMode()" checked="checked" />
                  <br />
                  3D: <input name="mode" type="radio" onclick="SetMode()" />
               </form>
            </td>
         </tr>
      </table>


   </body>
</html>

See Also

Reference

VEMap Constructor