+ Start a Discussion
EXRADMEXRADM 

Microsoft Virtual Earth inside a Visualforce page?

Has anybody had any success getting a MS Virtual Earth map to display on a visualforce page?  I have some code on a regular HTML page that loads my map without any trouble.  All of the code is strictly html and javascript, so it should theoretically show up on a visualforce page, however, it doesn't.  When I bring up the page, you can see the space (div) I've defined for the map, but nothing shows up in it.  Pertinent code:
 
Code:
        <script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx—v=6.2&s=1"></script>
        <script type="text/javascript">
         var map = null;
         
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'h' ,false);
         }   

            window.onload = GetMap();
         </script>
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>

 


Message Edited by EXRADM on 12-16-2008 01:20 PM
dchasmandchasman
Here is a working example inside of VF. BTW if I were you I would move this code into a custom component as soon as possible.

Code:
<apex:page>
    <apex:includeScript value="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"/>

    <script type="text/javascript">
    var map = null;
    
    function getMap() {
        map = new VEMap('myMap');
        map.LoadMap(new VELatLong(37.793736, -122.394776), 15, 'h', false);
  } var currentOnload = window.onload; window.onload = function() { if (currentOnload) { currentOnload(); } getMap() } </script> <div id='myMap' style="position:relative; width:400px; height:400px;"></div> </apex:page>




Message Edited by dchasman on 12-16-2008 08:27 PM