[mapguide-users] Legend Doesn't Refresh
Greg
gbneff at cid.utah.gov
Tue Mar 1 19:07:44 EST 2011
I am using the basic layout viewer.
When I add the layer as shown below the layer is added. I am trying to
refresh the legend so the new layer appears but it doesn't happen until I
manually refresh the legend by right clicking and hitting refresh. I am
probably trying to refresh things wrong but can't find my error. I am not
adding the layer to a group. Don't know if it makes a difference.
//add layer to map if it doesn't already exist (copy from repository
to session)
String strTruckRouteLayerResID =
"Library://layers/truck_route.LayerDefinition";
String strLayerName = "truck_route";
String strLegendLabel = "Unit" + strUnitNo + " " + strDate;
MgResourceIdentifier layerRes = new
MgResourceIdentifier(strTruckRouteLayerResID);
MgLayer layerTruck = new MgLayer(layerRes, resService);
layerTruck.SetName(strLayerName);
layerTruck.SetVisible(true);
layerTruck.SetLegendLabel(strLegendLabel);
layerTruck.SetDisplayInLegend(true);
//add layer to map if it doesn't already exist
MgLayerCollection layers = map.GetLayers();
if (!layers.Contains(strLayerName))
{
layers.Insert(0, layerTruck);
}
map.Save(resService);
%>
<script type="text/javascript">
function mapRefresh()
{
var map = document.GetMapFrame();
var legend = map.GetLegendCtrl();
legend.Refresh();
map.Refresh();
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Find Truck Route Result</title>
<link rel="stylesheet" type="text/css" href="cid_style.css" />
</head>
<body onload="mapRefresh">
</body>
</html>
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Legend-Doesn-t-Refresh-tp6079198p6079198.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list