<head>
<script language=javascript>
var initTimer;
var viewer;
var legend;
function InitDocument()
{
//wait for map to be fully initialized
//then initialize the legend control
initTimer = setInterval(DelayedInit, 200);
}
function DelayedInit() {
try {
viewer = parent.viewer.mapFrame;
if(viewer.mapInit) {
//map has been initialized
clearInterval(initTimer);
// load this legend control
legend = frames["LegendCtrl"];
legend.location.href = "LegendCtrl.php?SESSION=" + viewer.GetSessionId() + "&MAPNAME=" + encodeURIComponent(viewer.GetMapName()) + "&MAPFRAME=parent.parent.viewer.mapFrame";
//wait for the legend to be initialized
initTimer = setInterval(DelayedCtrlInit, 200);
}
}
catch(e) {}
}
function DelayedCtrlInit() {
try {
if(legend.InternalStateComplete()) {
//legend tree is now initialized
clearInterval(initTimer);
legend.SetScale(viewer.GetScale());
//have AJAX viewer notifications directed to this control
viewer.legendCtrl = legend;
}
}
catch(e) {}
}
</script>
</head>
<body onload="InitDocument()">
<iframe id="LegendCtrl" width=300 height=500 src=""></iframe>
</body>