[OpenLayers-Users] Layerswitcher and adding code directly.

Stephen Woodbridge woodbri at swoodbridge.com
Fri Mar 30 11:53:08 EDT 2012


On 3/30/2012 10:32 AM, Bob Basques wrote:
> All,
>
>
> I was wondering if there was a method to add in a chunk of RAW code to
> the layer switcher, such that I could build some layers based on a DB
> query.
>
>
> My business need: I need to only list out the moving vehicles on a map
> (based on SQL time index) and have controls bound to each vehicle, which
> also periodically checks the list via the same SQL, such as Zoom-TO,
> More info, open in new map, etc.
>
>
> Is there a way to use MapServer (my choice of poison) templates top
> populate the Layerswitcher in some fashion?
>
>
> Where we're al now on things:
> /http://pwultra5.ci.stpaul.mn.us/cp_tiles/OpenLayers/OL.AVL.10-rlb.html/
>

Bob,

You are thinking about the problem the wrong way.
If you were developing a server side application, then you would 
configure the layer switch this way. But with a Web 2.0 application like 
OpenLayers, you would issue and Ajax request to get some information and 
then have the response handler to that request update the web application.

So you probably need to build a custom layer switch that you can inject 
data from your ajax request that will then cause it to update itself 
based on that information.

If you choose to use a mapserver template as your ajax service that is 
fine, have it return json or xml and so your javascript handler can 
parse it and do whatever you need.

-Steve


More information about the Users mailing list