Map not displaying

Jun 25, 2008 at 7:36 AM
Hi, I deployed the Google Map solution for sharepoint and it would not display the map. Thanks to the source code download I was able to get it working. I found a problem in the javascript control template "GoogleMapsFieldControl.ascx" in function "showAddress()".
The array of input objects is using () instead of [] "Address = objs(i).value;"
I replaced the code with this and I'm now up and running. 

    <script type="text/javascript">
      
 var WStarGoogleMaps =
 {
  Canvas : null,
  Map : null,
  GeoCoder : null,
     init : function ()
  {
        if (GBrowserIsCompatible())
   {
    WStarGoogleMaps.Canvas = document.getElementById("map_canvas");
          WStarGoogleMaps.Map = new GMap2(WStarGoogleMaps.Canvas);
          WStarGoogleMaps.Map.setCenter(new GLatLng(37.4419, -122.1419), 13);

    var mapTypeControl = new GMapTypeControl();
    var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
          var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
          WStarGoogleMaps.Map.addControl(mapTypeControl, topRight);
    GEvent.addListener(WStarGoogleMaps.Map, "dblclick", function()
    {
     WStarGoogleMaps.Map.removeControl(mapTypeControl);
     WStarGoogleMaps.Map.addControl(new GMapTypeControl(), bottomRight);
    });
    WStarGoogleMaps.Map.addControl(new GSmallMapControl());

    WStarGoogleMaps.GeoCoder = new GClientGeocoder();

    WStarGoogleMaps.showAddress("72 Formation St, WACOL, QLD, Australia, 4076"); // Western Star Trucks, Where I work.
    
    WStarGoogleMaps.findSPAddress();
        }
     },
        showAddress : function (address)
  {
        if (WStarGoogleMaps.GeoCoder)
   {
          WStarGoogleMaps.GeoCoder.getLatLng(
             address,
             function(point)
     {
               if (!point)
      {
       WStarGoogleMaps.Map = null;
       WStarGoogleMaps.Canvas.style.display = 'none';
       document.getElementById("map_notfound").style.display = '';
       document.getElementById("map_notfound").innerHTML = 'No Google Map found for address [ ' + address + ' ] ';
               }
      else
      {
                  WStarGoogleMaps.Map.setCenter(point, 13);
                  var marker = new GMarker(point);
                  WStarGoogleMaps.Map.addOverlay(marker);
                  marker.openInfoWindowHtml(address);
               }
             }
          );
        }
     },
  findSPAddress : function ()
  {
   var objs = document.body.getElementsByTagName('input');
   for(var i=0; i<objs.length;i++)
   {
    if (objs(i).id.indexOf('hidAddress') > 0)
    {
     WStarGoogleMaps.showAddress(objs[i].value);
    }
   }   
  }
 }
 window.onload=WStarGoogleMaps.init;
    </script>
   <div id="map_canvas" style="width: 500px; height: 300px"></div>
   <div id="map_notfound" style="display:none"></div>
   <input runat="server" type="hidden" id="hidAddress" name="hidAddress" value="Nijverheidsstraat 308 1800 Vilvoode Belgique" />

Coordinator
Jun 27, 2008 at 8:30 AM
Thank you very much for this comment.
I will update the sources ASAP.

Best regards,

Ludovic,
Jun 27, 2008 at 8:52 AM
It seems that there is still an error in the code :)


 if (objs(i).id.indexOf('hidAddress') > 0)
    {
     WStarGoogleMaps.showAddress(objs[i].value);
    }


In the if statement :)

Cheers
Jun 29, 2008 at 10:48 PM

Hi Stephane,

Thanks for spotting that. I'll make the changes in my code.

Cheers
Chayne

Coordinator
Jul 3, 2008 at 1:25 PM
Ok i've juste release a version with this problem fix.

thanks for your help

Ludovic,

Chayne wrote:

Hi Stephane,

Thanks for spotting that. I'll make the changes in my code.

Cheers
Chayne