[mapguide-internals] Viewer API GetLayers(onlyVisible, onlySelectable)

doggybs james.slater at keynetix.com
Thu Jun 25 09:25:51 EDT 2009


In the Viewer API documentation for GetLayers(onlyVisible, onlySelectable)
it say:

"onlyVisible - set to true to return only the layers visible at the current
scale; set to false to ignore layer visibility."

The current scale aspect of this does not work. In that it will always
return layers that are turned on in the legend even thought they are not
visible due to the layers scale styling.

I have worked around the problem by modifing function DoGetLayers(nodes,
layers, onlyVisible, onlySelectable) in the legendui.templ file in the web
extensions, by adding a check on the curScale property.

function DoGetLayers(nodes, layers, onlyVisible, onlySelectable)

	for(var i=0; i < nodes.length; i++)
		var node = nodes[i];
        if(node.type == 0)
            if(onlyVisible && (!node.visible || node.curScale == -1))
            if(node.children != null && node.children.length > 0)
                DoGetLayers(node.children, layers, onlyVisible,
        else if(node.type == 1)
            if(onlyVisible && (!node.visible || node.curScale == -1))
            if(onlySelectable && !node.selectable)
            layers.push(new Layer(node.legend, node.name, node.objectId));

Can you please let me know if this is a sensible fix or will it cause any

Many Thanks


View this message in context: http://n2.nabble.com/Viewer-API-GetLayers%28onlyVisible%2C-onlySelectable%29-tp3154987p3154987.html
Sent from the MapGuide Internals mailing list archive at Nabble.com.

More information about the mapguide-internals mailing list