Adding layers dynamically
Now that we have a basic layer tree, it's time to add some logic when adding layers. In this example, called ch03_addlayer
, we will extend our code so far with some layer requesting and WMS metadata fetching capabilities. We will add every additional method to the object's prototype for the sake of clarity and performance.
Creating the interface
To keep things simple, we first hard code some forms in the HTML part. We will be able to add layers by filling out and submitting these forms. This will only need some event listeners in the JavaScript code. As these forms are quite verbose, we will only discuss the most important parts here. You can see the full code in the example's HTML file:
<div id="addwms" class="toggleable" style="display: none;"> <form id="addwms_form" class="addlayer"> [...] <td><input id="wmsurl" name="server" type="text" required="required" value="http://demo.opengeo.org/geoserver...