Using Leaflet and GeoServer.
Basically, I want to be able to add a new layer with a different bounding box that is user defined by selecting an area on the map. I want it to work with all layers available... so if I could just get the 'layers' name and update it when a new overlay is turned on/off
User turns on a tileLayer with many points on the map. User selects an area on the map with points. The selection area is converted to new bounding box dimensions. A new layer of the same map is added but with with the new bounding box.
I have everything except how to get the name of the current tile layer so that I can make the GeoServer call. It would look like this:
var currentLayerName;
function addGeoServerLayer(){
geoServerLayer = L.tileLayer.wms("http://12.235.22.99:8080/geoserver/ows?", {
layers: **currentLayerName**, **<<<<<<<<<<<<<<< I NEED THIS**
format: 'image/png',
transparent: false,
CQL_FILTER : 'BBOX(geom, ' + boundingBox + ')'
}).addTo(layersGroup);
}
I want to be able to pull the 'layers' field from this list of tileLayers in my project (leaflet project). this way, after the user selects an area, I can make a geoserver and return the same map with new bounding box values and I can do it no matter what layer is selected.
var layer1 = L.tileLayer.wms("http://12.235.22.99:8080/geoserver/ows?", {
layers: 'test:layer1',
format: 'image/png',
transparent: true
});
var layer2 = L.tileLayer.wms("http://12.235.22.99:8080/geoserver/ows?", {
layers: 'test:layer2',
format: 'image/png',
transparent: true,
});
var layer3 = L.tileLayer.wms("http://12.235.22.99:8080/geoserver/ows?", {
layers: 'test:layer3',
format: 'image/png',
transparent: true
});
var layer4 = L.tileLayer.wms("http://12.235.22.99:8080/geoserver/ows?", {
layers: 'test:layer4',
format: 'image/png',
transparent: true
});
var layer5 = L.tileLayer.wms("http://12.235.22.99:8080/geoserver/ows?", {
layers: 'test:layer5',
format: 'image/png',
transparent: true
});
var layer6 = L.tileLayer.wms("http://12.235.22.99:8080/geoserver/ows?", {
layers: 'test:layer6',
format: 'image/png',
transparent: true
});