[OpenLayers-Users] Question on having multiple layers
Gregor Mosheh
gregor at hostgis.com
Wed Aug 8 11:43:35 EDT 2007
Ali Khan wrote:
> Is there anyway one can make a select box on the page and on change have
> it reference the appropriate layer to show in OpenLayers?
Sure. While loading your layers in a loop (that's how I like doing it)
store the layers into an associative array so they can be referenced by
name. Give the HTML checkboxes a onClick handler to fetch and layer and
toggle it.
Should look something like this:
<input type="checkbox" name="toggle[]" value="Oceans"
onClick="toggleLayer('Oceans');"/> Oceans
<script>
function toggleLayer(layername) {
var l = ALL_LAYERS[layername]; if (!l) return;
l.setVisibility(! l.getVisibility() );
}
</script>
> Also for each layer we want to have a seperate getFeatureinfo query as
> each layer contains different data. How do we do this? can we do
> layer.events.register instead of map.events.register for instance so
> that each layer has its own on click event?
I experimented with that a month ago using WFS layers, and found that
only one layer can use click-to-query at a time. I may be wrong about
that...
--
Gregor Mosheh / Greg Allensworth
System Administrator, HostGIS cartographic development & hosting services
http://www.HostGIS.com/
"Remember that no one cares if you can back up,
only if you can restore." - AMANDA
More information about the Users
mailing list