I'm simply trying to add new layers with each as their own variable so I can turn them on and off, instead of just stacking all the layers under the variable layers
.
See script below
<script>
var layers = [
new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'osm'})
}),
];
var poly1 = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://localhost:8080/geoserver/wms',
params: {'LAYERS': 'sample:sample', 'TILED': true},
serverType: 'geoserver',
})
});
var map = new ol.Map({
layers: poly1, layers,
target: 'map',
view: new ol.View({
center: [lat, lon],
zoom: 4
})
});
</script>
For some reason when add more than one layer to the layers line of code here
var map = new ol.Map({
layers: poly1, layers,
they both will not display, if I have one of the other they work, but can't get more than one variable working... I assume this is a simple syntax error but has me stumped and cannot seem to get it working.