Problems uploading object in MapGoogle

Jul 2, 2009 at 3:04 PM

Hello...

I am having trouble loading the trail in my GoogleMap
The problem occurs occasionally while between 10 visits 2 errors.
I have a JavaScript that adds an object in GoogleMap, and sometimes this JavaScript runs before the GoogleMap is loaded.
Where the error because GoogleMap happens is not loaded completely

I'm doing as follows ...
***********************************************************************************
<body OnLoad="OnLoad();" >
 //Page codes
<cc1:GoogleMap ID="gmTrajeto" runat="server" Width="550" Height="393" enableServerEvents="True">
</cc1:GoogleMap>
</body>
<script language="javascript">  
    function Load() {
            var map = <%= gmTrajeto.ClientID %>;
            if (map.Markers != null && map.Markers.length > 0) {
            var otherOpts = {
            buttonStartingStyle: {opacity: 10.0, paddingTop: '5px', paddingLeft: '5px'},
            buttonHTML: '<img title="Arrastar zoom em" src="img/zoomout.gif">',
            buttonStyle: {width:'25px', height:'23px'},
            buttonZoomingHTML: '<font face="Verdana" size="2">Arraste uma região do mapa.</font>',
            backButtonHTML: '<img title="Menos zoom" src="img/zoomin.gif">', 
            backButtonStyle: {display:'none',marginTop:'5px',width:'25px', height:'23px'},
            backButtonEnabled: true,
            overlayRemoveTime: 200}
            // G_ANCHOR_TOP_RIGHT, G_ANCHOR_BOTTOM_RIGHT  G_ANCHOR_TOP_LEFT, G_ANCHOR_BOTTOM_LEFT
            map.addControl(new DragZoomControl({}, otherOpts, {}), new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10,15)));
          
            }
        }
</script>

***********************************************************************************

I tried to do as follows ...

***********************************************************************************
<body >
 //Page codes
<cc1:GoogleMap ID="gmTrajeto" runat="server" Width="550" Height="393" enableServerEvents="True" OnLoad="OnLoad();">
</cc1:GoogleMap>
</body>
<script language="javascript">  
    function Load() {
            var map = <%= gmTrajeto.ClientID %>;
            if (map.Markers != null && map.Markers.length > 0) {
            var otherOpts = {
            buttonStartingStyle: {opacity: 10.0, paddingTop: '5px', paddingLeft: '5px'},
            buttonHTML: '<img title="Arrastar zoom em" src="img/zoomout.gif">',
            buttonStyle: {width:'25px', height:'23px'},
            buttonZoomingHTML: '<font face="Verdana" size="2">Arraste uma região do mapa.</font>',
            backButtonHTML: '<img title="Menos zoom" src="img/zoomin.gif">', 
            backButtonStyle: {display:'none',marginTop:'5px',width:'25px', height:'23px'},
            backButtonEnabled: true,
            overlayRemoveTime: 200}
            // G_ANCHOR_TOP_RIGHT, G_ANCHOR_BOTTOM_RIGHT  G_ANCHOR_TOP_LEFT, G_ANCHOR_BOTTOM_LEFT
            map.addControl(new DragZoomControl({}, otherOpts, {}), new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10,15)));
          
            }
        }
</script>
***********************************************************************************


More time opening page gives an error
Compiler error message: BC32022: 'Public Event Load(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

Someone can help me to work around this problem ...

Coordinator
Jul 7, 2009 at 11:28 AM

Hi,

Try using OnClientMapLoad to trigger you JS instead of OnLoad server-side event.
You code sould look like:

<cc1:GoogleMap ID="gmTrajeto" runat="server" Width="550" Height="393" enableServerEvents="True" OnClientMapLoad="OnLoad">

Regards