locked
Best Practices - 2 questions RRS feed

  • Question

  • I read through the very helpful Best Practices post and I have 2 questions:

    1. Can I use DOCTYPE Strict instead of Transitional? What possible complications could this cause?

    2. I have successfully disabled the 3D button, but I don't know how to disable the "3" hotkey. Can you make some suggestions on how to do this?

    Thanks very much.

    -MCM

    Thursday, February 11, 2010 4:49 PM

Answers

  • You have to use the onkeydown event to disable the functionality of the 3 key:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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 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( null,null,null,null,null,false);
    		
    		map.AttachEvent('onkeydown', function(event) {
    			if (event.keyCode == 51) //ASCII key code 51 == #3
    			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
    • Marked as answer by MCM14 Wednesday, February 17, 2010 11:58 PM
    Monday, February 15, 2010 11:22 PM
    Moderator
  • I have seen mixed results when using other DOCTYPEs. However, I have not encountered any issues using Strict. The best would be to experiment and see what differences you notice. The main reason the DOCTYPE is needed is to stop browsers from rendering in "Quirks" mode.
    • Marked as answer by MCM14 Thursday, February 18, 2010 4:47 PM
    Thursday, February 18, 2010 3:36 PM

All replies

  • can you tell me how you disabled the "3D" button on the dashboard? I asked this question a while back but didn't get a response.

    thanks
    sanjay
    Thursday, February 11, 2010 5:49 PM
  • http://msdn.microsoft.com/en-us/library/bb412546.aspx

    VEMap.LoadMap(VELatLong, zoom, style, fixed, mode, showSwitch, tileBuffer, mapOptions);

    Set "showSwitch" to false.
    Thursday, February 11, 2010 6:42 PM
  • For 2 just handle the maps keyboard event:


    and check for the 3 key being pressed, if it is pressed simply return "true" and the event should not propagate any future 

    Brian @ Earthware - UK interactive mapping web developers http://www.earthware.co.uk/blog | http://www.twitter.com/earthware | Windows Live Developer MVP
    Thursday, February 11, 2010 8:51 PM
    Moderator
  • My handler is getting called - I tested it using a simple alert. But even though it is returning true, 3D is still being activated.

    var map;
    var KEY_3 = 51;
    var NORTHAMERICA = { 'lat': 43.75, 'lon': -99.71, 'zoom': 4 };
    
    map = new VEMap('map');
    map.SetCredentials(_Key);
    map.onLoadMap = function() {
        map.SetMouseWheelZoomToCenter(false);
        map.EnableShapeDisplayThreshold(false);
        map.AttachEvent('onkeypress', function(event) {
            if (event.keyCode == KEY_3) return true;
        });
    };
    var options = new VEMapOptions();
    options.EnableBirdseye = false;
    map.LoadMap(new VELatLong(NORTHAMERICA.lat, NORTHAMERICA.lon), NORTHAMERICA.zoom, VEMapStyle.Road, false, VEMapMode.Mode2D, false, 1, options);
    
    Friday, February 12, 2010 2:22 PM
  • Anyone have any suggestions on either disabling the 3 hotkey like I have tried to do above or on the Strict DOCTYPE?
    Monday, February 15, 2010 5:12 PM
  • You have to use the onkeydown event to disable the functionality of the 3 key:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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 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( null,null,null,null,null,false);
    		
    		map.AttachEvent('onkeydown', function(event) {
    			if (event.keyCode == 51) //ASCII key code 51 == #3
    			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
    • Marked as answer by MCM14 Wednesday, February 17, 2010 11:58 PM
    Monday, February 15, 2010 11:22 PM
    Moderator
  • That did the trick for the hotkey. Thanks.

    What about Strict DOCTYPE? Any potential pitfalls there?
    Wednesday, February 17, 2010 11:59 PM
  • I have seen mixed results when using other DOCTYPEs. However, I have not encountered any issues using Strict. The best would be to experiment and see what differences you notice. The main reason the DOCTYPE is needed is to stop browsers from rendering in "Quirks" mode.
    • Marked as answer by MCM14 Thursday, February 18, 2010 4:47 PM
    Thursday, February 18, 2010 3:36 PM
  • Ok. Thanks. I've found that Strict prevents quirks mode across the widest variety of browsers, so hopefully that should be good.

    Thursday, February 18, 2010 4:49 PM