[mapguide-users] Set existing layers visible
Jim O'Leary
jo at pat.ca
Sat Feb 9 23:24:18 EST 2008
I want to programmatically loop through existing layers in my map and set
them visible and display their label in the layers pane according to some
flag. I know this works with new layers that you programmatically make, but
it doesn't work with existing layers. My code is the same as for new layers:
$layer->SetVisible(true);
$layer->SetLegendLabel($layerName);
$layer->SetDisplayInLegend(true);
$layer->ForceRefresh();
$map->Save($resourceService);
In the case of an existing layer, this code sets the layer visible in the
map, but does not display it in the legend. Adding a JavaScript
mapFrame.Refresh()
does not help. In fact, you don't have to do that with an existing layer, it
becomes visible anyway.
After executing this code, I can call
$visible = $layer->GetDisplayInLegend();
$layerName = $layer->GetName();
print "visible for $layerName is $visible<br>";
...and it shows me that the layer is set as visible in the legend. However,
it does not show up in the legend.
Thanks.
-----
Jim O’Leary
Technical
Consultant
Pacific Alliance
Technologies
2nd Floor, 24 East 4th Ave, Vancouver
BC, Canada
V5T1E8
TEL 604.676.6000 TOL 877.691.9171 FAX 604.682.0962
WEB http://www.pat.ca/ www.pat.ca
--
View this message in context: http://www.nabble.com/Set-existing-layers-visible-tp15393217s16610p15393217.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list