locked
Questions on Bing Maps AJAX control hosted in .NET WebBrowser control RRS feed

  • Question

  • I'm an absolute beginner to MapPoint and I'm experimenting with the AJAX version of Bing Maps right now.

    A couple of things don't seem to work the way they should. Can someone please enlighten me on the following issues:
    • I don't use a <div> element, instead I'm using the <body> element to have the map get all available space without any pre-configuration. However, if I resize my .NET application window and, thus, the WebBrowser control, the map is still displayed at a fixed width of, I don't know, say 600*600 pixels.

      Is this common behaviour?

      How can I have the AJAX control automatically fit into its containers dimensions?

      Weird: The Bing logo and the scale are drawn correctly at the bottom of the web content.
    • I cannot right-click into the map in order to zoom-out of the map. Whether I set the IsWebBrowserContextMenuEnabled property to True or False, right-clicking into the map doesn't have any effect.
    • I tried to avoid getting that click noise sounded off by the WebBrowser control everytime a new URL is loaded by using this trick . Unfortunately Bing Maps doesn't seem to load if the HTML has been given using the webBrowser.Document.OpenNew().Write(...) method.

      What am I doing wrong?

    Here's the HTML I'm using:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
        <head>
            <title>Map File</title>
            <script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=de-DE"></script>
            <script type="text/javascript">
                function InitMap()
                    {var map=new VEMap('myMap');
                    map.LoadMap();}
            </script>
        </head>
        <body id="myMap" onload="InitMap();" style="background-color: Red;">
        </body>
    </html>

    Any help is appreciated!
    Thursday, November 26, 2009 1:45 AM

Answers

  • the right mouse click functionality to zoom out was never defined. With this said the following code example shows how to add this functionality: Note that the couble click event only gets fired with the left mouse button.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
          <title>Right Click Zoom Out</title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" /></script>
          <script>
          var map = null;
       
          function GetMap()
          {
             map = new VEMap('myMap');
             map.LoadMap();
    
    		 map.AttachEvent("onclick", shape_onclick);
    	  }
            
    	function shape_onclick(e)
    	{
    		if (e.rightMouseButton)
    		{
    			map.ZoomOut();
    
    			return true;
    		}
    	}
          </script>
       </head>
       <body onload="GetMap();">
          <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
       </body>
    </html>

    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    • Proposed as answer by EarthwareModerator Saturday, December 5, 2009 7:53 AM
    • Marked as answer by BetterToday Saturday, December 5, 2009 11:40 AM
    Sunday, November 29, 2009 4:47 PM
    Moderator

All replies

  • For the map resizing, this is normal. the map tiles are bound to the initial size you set the map to, the logo is set to the browser. To correct your issue set up an event that gets fired if the browser is resized that calls the method map.Resize();

    By default the standard api of the map does not have a context menu when you right click on the map. The only thing that happens when you right click on the map is a mouse click event gets fired, but this is only if you have attached an onmouseclick event.

    Having the map in the body tag is a big unusual. Usually it is put into a div in the body of the page and css styles are used to make the map fill the browser. Note that the position, width and height properties of the map should be specified in an inline style tag to ensure that the map performs as expected.

    I can't comment on the mouse click noise.

    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    Sunday, November 29, 2009 11:30 AM
    Moderator
  • Thank you for enlightening me.
    By default the standard api of the map does not have a context menu when you right click on the map.
    But shouldn't the map zoom-out when double-rightclicking on it? It does zoom-in when double-leftlicking on it.. Isn't this an inconsistency?


    Please also refer to my reply to your answer given here ...

    Sunday, November 29, 2009 3:20 PM
  • the right mouse click functionality to zoom out was never defined. With this said the following code example shows how to add this functionality: Note that the couble click event only gets fired with the left mouse button.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
          <title>Right Click Zoom Out</title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" /></script>
          <script>
          var map = null;
       
          function GetMap()
          {
             map = new VEMap('myMap');
             map.LoadMap();
    
    		 map.AttachEvent("onclick", shape_onclick);
    	  }
            
    	function shape_onclick(e)
    	{
    		if (e.rightMouseButton)
    		{
    			map.ZoomOut();
    
    			return true;
    		}
    	}
          </script>
       </head>
       <body onload="GetMap();">
          <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
       </body>
    </html>

    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    • Proposed as answer by EarthwareModerator Saturday, December 5, 2009 7:53 AM
    • Marked as answer by BetterToday Saturday, December 5, 2009 11:40 AM
    Sunday, November 29, 2009 4:47 PM
    Moderator
  • I see now... Great, Richard, thanks for enlightening me on this!
    Thursday, December 3, 2009 12:18 AM