Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Loading maplayers on a page load....

1 view
Skip to first unread message

Hamish

unread,
Jul 16, 2001, 10:26:50 AM7/16/01
to
Hey all I am trying to load a bunch of maps when a html page loads. My code
is:

function addLayers()


var urlCollection = map.createObject("MGCollection");
urlCollection.add("Street.mlf");
urlCollection.add("SouthEastCounties.mlf");
urlCollection.add("PropertyBoundaries.mlf");
map.addMapLayers(urlCollection);

}

function testWrite()
{
document.write("This is a test.");
}


</SCRIPT>

</HEAD>
<BODY onLoad = "addLayers()">

<INPUT TYPE="button" VALUE="Add Layers" ONCLICK="addLayers()">

When the button is pushed, the layers are loaded fine. In addition the
testWrite () function is called fine from the onLoad. Is there another
function that I need to call? Any help would be appreciated. Thanks

Hamish Richardson
REIS Inc.
Charleston, SC 29412


Ryan Luedey

unread,
Jul 17, 2001, 4:47:08 PM7/17/01
to
Hamish,
Is the addLayers function being called upon page load? You could put an
alert statement in the function to let you know if it is being called or
not. If the function is being called but the layers are not being added,
then I suspect that your problem is that the map is still in the busy state
when you call your addLayers function and as such, it will not respond to
the requests. Likely by the time you push the button, the map has left the
busy state, so it works. I would try calling your function from the
MapGuide 'onMapLoaded' event rather than from the page onload event.
Ryan

"Hamish" <d> wrote in message
news:BB03A06419241AE7...@in.WebX.maYIadrTaRb...

Hamish

unread,
Jul 19, 2001, 1:07:48 PM7/19/01
to
Cool thanks Ryan,

I will try that.


Hamish.

"Ryan Luedey" <rlu...@cgsl.com> wrote in message
news:DDB528854BF9034D...@in.WebX.maYIadrTaRb...

Hamish

unread,
Jul 19, 2001, 3:15:18 PM7/19/01
to
Ok I am using the onMapLoaded function and the alert displays but how do I
use it execute after the map has loaded so that I can call my addLayers
function. Thanks in advance....

Hamish


function getMap()
{
if (navigator.appName == "Netscape")
return document.map;
else
return window.map;
}


function initObs1()
{
getMap().setMapLoadedObserver(document.obs);
}

function onMapLoaded(map)
{
alert('Executing onMapLoaded')

if(document.displayMapLoadedEvents)
{

alert('Map Loaded\nisBusy: ' + map.isBusy());
}
}


function doAddLayer(layer)
{
var map = getMap();
map.addMapLayer(layer);


}


function addLayers()


var urlCollection = map.createObject("MGCollection");
urlCollection.add("Street.mlf");
urlCollection.add("SouthEastCounties.mlf");
urlCollection.add("PropertyBoundaries.mlf");
map.addMapLayers(urlCollection);

}


</SCRIPT>

</HEAD>

<P ALIGN="Center">
<OBJECT ID="map" WIDTH="640" HEIGHT="480" ALIGN="baseline"
CLASSID="CLSID:62789780-B744-11D0-986B-00609731A21D"
CODEBASE="ftp://ftp.autodesk.com/pub/mapguide/ver5/viewer/en/mgaxctrl.cab#Ve
rsion=5,0,0,0">

<PARAM NAME="URL" VALUE="protoreis.mwf">

<!---
<param name="Lat" value="0">
<param name="Lon" value="0">
<param name="MapScale" value="0">
<param name="MapWidth" value="0">
<param name="Units" value="M">
<param name="ToolBar" value="On">
<param name="StatusBar" value="Off">
<param name="LayersViewWidth" value="150">
<param name="URLListState" value="0">
<param name="AutoLinkDelay" value="20">
--->

<EMBED SRC="reis.mwf" ALIGN="baseline" BORDER="0" WIDTH="600" HEIGHT="300"
NAME="map" TYPE="application/x-mwf">

</OBJECT>
</P>
<SCRIPT LANGUAGE = "JavaScript">
MyMap = getMap();
onMapLoaded(MyMap);
</SCRIPT>

Ryan Luedey

unread,
Jul 24, 2001, 10:58:38 AM7/24/01
to
What exactly are you trying to do? If I understand you correctly, you want
a function to be executed upon the initial loading of your map, but also
want to be able to call the function later on in a session?
If this is what you want to do, simply call the function using a button:
<input type=button onclick="addLayers()" />
Ryan

"Hamish" <d> wrote in message

news:CB00FBE8437B2358...@in.WebX.maYIadrTaRb...

Hamish

unread,
Jul 25, 2001, 5:34:58 PM7/25/01
to
Ryan,

I really trying to start taking advantage of the event handlers but it seems
pretty complicated. Most of our users use I.E. instead of Netscape. It seems
though in the section in the MGViewer help under "Setting up the Event
Handler" , even though we will be using the ActiveX Control you still need
to set up a couple of applets that will act as observers. Is it really this
difficult to take advantage of such things as the onMapLoad event.

All we want to do is to be able to only load layers that pertain to a end
user that has logged in with out that user having to click on a button. Is
there any other alternative than the complicated set up specified in the
MGViewer help? We just want to develop for IE. Any advice would be helpful.


Hamish


"Ryan Luedey" <rlu...@cgsl.com> wrote in message

news:3580353A76D1D1BD...@in.WebX.maYIadrTaRb...

0 new messages