[OpenLayers-Users] Combo Box for layers

Todd Fagin tfagin at coordinatesolutions.com
Tue May 27 09:59:02 PDT 2014


Thanks to Robert for this excellent suggestion. Nonetheless, I am still
having problems getting this to work. For the life of me, I cannot figure
out what I am doing wrong.

Here is a sample of what I am trying to do:
http://biosurvey.ou.edu/purple_martin/Simplified_Dropwdown_to_Share.html

If anyone would kindly look at the code and point out where I have gone
astray, it would be greatly appreciated.

Many thanks in advance,

Todd

Todd Fagin

Coordinate Solutions, Inc.
2804 NW 18th St.
Oklahoma City, OK 73107
405.740.4324
www.coordinatesolutions.com

-----Original Message-----
From: Robert Sanson [mailto:Robert.Sanson at asurequality.com] 
Sent: Sunday, May 25, 2014 4:51 PM
To: Todd Fagin; openlayers-users at lists.osgeo.org
Subject: Re: [OpenLayers-Users] Combo Box for layers

Hi Todd

Suppose you have some HTML for the combo box:

 <p><select name="Layer" id="layer">
    <option value="layer1">Layer 1</option>
    <option value="layer2">Layer 2</option>
    <option value="layer3">Layer 3</option>
  </select>

Then you have a Javascript function:

function showoverlay() {
  var overl = document.getElementById('layer').value;
  if overl == layer1 {
    l1.setVisibility(true);
    l2.setVisibility(false);
    l3.setVisibility(false);
  }
  else if overl == layer2 {
    l1.setVisibility(false);
    l2.setVisibility(true);
    l3.setVisibility(false);
  }
  else if overl == layer3 {
    l1.setVisibility(false);
    l2.setVisibility(false);
    l3.setVisibility(true);
  }
}

where l1, l2, l3 are the overlay layers that have been added to the map.

Regards,

Robert
   

>>> Todd Fagin <tfagin at coordinatesolutions.com> 23/05/2014 7:41 a.m. >>>
Greetings OpenLayer users,

 

I have what I assume is a fairly simple question, one that has likely been
addressed previously. However, I have been unable to find the solution
online. To add insult to injury, I am not a programmer. I can look at
existing code and often modify it to my needs, but if I start with a blank
slate, I usually end with a blank slate.

 

So, here is my problem in a nutshell:

 

I have a simple OpenLayers application that displays WMS layers from
GeoServer plus several base layers (Google, Bing, etc.). Currently, it is
configured with the standard LayerSwitcher. However, I would like to have a
combo box from which users can select the overlay to display. It would be
nice to have a default overlay set, then users could select from the
dropdown list which overlay to display (for my purpose at hand, it is not
necessary to display more than one overlay at a time-at least the overlays I
wish to include in the combo box).

 

Surely (I assume), this is something many individuals have done before.

 

Keep in mind what I said above: I am not a programmer. So, if someone has
some sample code I could cannibalize, I will be forever in your debt (well,
maybe not forever, but.)

 

Many thanks in advance,

 

Todd 

 

Todd Fagin

 

Coordinate Solutions, Inc.

2804 NW 18th St.

Oklahoma City, OK 73107

405.740.4324

www.coordinatesolutions.com 

 




This email and any attachments are confidential and intended solely for the
addressee(s). If you are not the intended recipient, please notify us
immediately and then delete this email from your system.

This message has been scanned for Malware and Viruses by Websense Hosted
Security.
www.websense.com



More information about the Users mailing list