none
On v7, overloading the Microsoft.Maps.Map constructor doesnt fire on FF4 RRS feed

  • Question

  • Since the v7 changes last week, my overloaded map constructor isnt firing on Firefox 4 or Droid mobile browsers.  I know there were a lot of discussions on the ordering of events and loading the map control. Perhaps I'm not following the recommended practices. Below is a code sample. The constructor fires for IE and works fine, however it doesnt fire for FF4 or droid browsers. Any suggestions or corrections on how I am overloading the Map constructor?

    Thanks for your assistance.

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
      <title></title>
      <script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
      <script type="text/javascript">
        var map = null;
        
        Microsoft.Maps._Map = Microsoft.Maps.Map;
        Microsoft.Maps.Map = function(container, options) 
        {
          try 
          {
            alert("Map Constructor");
            var mapx = new Microsoft.Maps._Map(container, options);
            //do custom stuff, add handlers, etc
          }
          catch (ee) 
          {
            alert(ee);
          }
    
          return mapx;
        };
      </script>
    </head>
    <body onload="GetMap();">
      <div id="MapTest" style="position:absolute; top:0px; left:0px; width:100%; height:100%;"></div>
      
      <script type="text/javascript">
        function GetMap() 
        {
          alert("GetMap");
          map = new Microsoft.Maps.Map(document.getElementById("MapTest"),
          {
            credentials: 'Bing Map Key',
            center: new Microsoft.Maps.Location(35.5, -100.5),
            mapTypeId: Microsoft.Maps.MapTypeId.aerial,
            zoom: 5,
            showDashboard: true,
            showScalebar: false,
            showMapTypeSelector: false,
            useInertia: false
          });
        }
      </script>  
    </body>
    </html>
    
    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:31 PM (From:Bing Maps: Map Control and Web services Development)
    Monday, May 9, 2011 3:18 PM

Answers

  • Could you try below script. it should work on all broswsers


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
      <title></title>
      <script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
      <script type="text/javascript">
        var map = null;
      </script>
    </head>
    <body onload="GetMap();">
      <div id="MapTest" style="position:absolute; top:0px; left:0px; width:100%; height:100%;"></div>
     
      <script type="text/javascript">
        function GetMap()
        {
       
        Microsoft.Maps._Map = Microsoft.Maps.Map;
        Microsoft.Maps.Map = function(container, options)
        {
          try
          {
            alert("Map Constructor");
            var mapx = new Microsoft.Maps._Map(container, options);
            //do custom stuff, add handlers, etc
          }
          catch (ee)
          {
            alert(ee);
          }

          return mapx;
    }

          alert("GetMap");
          map = new Microsoft.Maps.Map(document.getElementById("MapTest"),
          {
            credentials: 'Bing Map Key',
            center: new Microsoft.Maps.Location(35.5, -100.5),
            mapTypeId: Microsoft.Maps.MapTypeId.aerial,
            zoom: 5,
            showDashboard: true,
            showScalebar: false,
            showMapTypeSelector: false,
            useInertia: false
          });
        }
      </script> 
    </body>
    </html>


    HemantGoyal
    Monday, May 9, 2011 5:17 PM

All replies

  • Could you try below script. it should work on all broswsers


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
      <title></title>
      <script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
      <script type="text/javascript">
        var map = null;
      </script>
    </head>
    <body onload="GetMap();">
      <div id="MapTest" style="position:absolute; top:0px; left:0px; width:100%; height:100%;"></div>
     
      <script type="text/javascript">
        function GetMap()
        {
       
        Microsoft.Maps._Map = Microsoft.Maps.Map;
        Microsoft.Maps.Map = function(container, options)
        {
          try
          {
            alert("Map Constructor");
            var mapx = new Microsoft.Maps._Map(container, options);
            //do custom stuff, add handlers, etc
          }
          catch (ee)
          {
            alert(ee);
          }

          return mapx;
    }

          alert("GetMap");
          map = new Microsoft.Maps.Map(document.getElementById("MapTest"),
          {
            credentials: 'Bing Map Key',
            center: new Microsoft.Maps.Location(35.5, -100.5),
            mapTypeId: Microsoft.Maps.MapTypeId.aerial,
            zoom: 5,
            showDashboard: true,
            showScalebar: false,
            showMapTypeSelector: false,
            useInertia: false
          });
        }
      </script> 
    </body>
    </html>


    HemantGoyal
    Monday, May 9, 2011 5:17 PM
  • Thank you HemantGoyal.

    I found a solution in your script for my issue.


    Thanks

    Wednesday, August 8, 2012 7:14 PM