[OpenLayers-Users] Question on having multiple layers
Ali Khan
akhan at unfpa.org
Wed Aug 8 12:04:41 EDT 2007
Thanks for the info...For the second part though about multiple event
clicks..When one chooses a new layer to display, can the javascript
update the url being used for the query some how to reflect the
appropriate layer?
Gregor Mosheh wrote:
> 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...
>
More information about the Users
mailing list