1

I am currently building a simple web application with the Boundless OpenGeoSuite SDK ol3view (Openlayer3 viewer) and I was able to get one layer to show up from my geoserver instance but I would like to know how to show more than just one layer. This is the code in the app.js that I have so far of the layer showing right now. The other layers are in the same workspace on geoserver with varying geometry field types.

// ========= config section ================================================
var url = '/geoserver/ows?';
var featurePrefix = 'Campus'; //workspace
var featureType = 'Basemap'; //layer name
var featureNS = 'Campus1'; //namespace
var srsName = 'EPSG:900913'; //projection
var geometryName = 'the_geom'; //geometry type
var geometryType = 'MultiLineString'; //field type
var fields = ['layer']; //columns
var layerTitle = 'layer';
var infoFormat = 'application/vnd.ogc.gml/3.1.1'; // can also be 'text/html'
var center = [-10764594.758211, 4523072.3184791];
var zoom = 3;

// =========================================================================

Does anyone have an example in the code for the app.js that would show how to add multiple layers and or a group layer?

1

You will need to repeat some of the code to get more than 1 layer, such as:

1) create another ol.source.TileWMS and set your layer name in the params (https://github.com/boundlessgeo/suite/blob/master/sdk/src/main/resources/client/ol3view/src/app/app.js#L42:L47)

2) create another ol.layer.Tile and link to your source from step 1 (https://github.com/boundlessgeo/suite/blob/master/sdk/src/main/resources/client/ol3view/src/app/app.js#L117:L120)

If you want GetFeatureInfo to work on multiple layers you will need to do some additional work, this has been discussed on ol3-dev (https://groups.google.com/forum/#!searchin/ol3-dev/getfeatureinfo/ol3-dev/a0c1L3-92nY/VM6ehW5jIMQJ and https://gist.github.com/bartvde/43a3b8c9cf8798e16748)

0

Another simple option is to make a " layer group " in Geoserver and consume that . In this method you don't have to declare multiple layer .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.