I need to add an extra layer dynamically. The layer need to be visible at the layermenu also. How do I approach this?
The be more specific I do have an example:
Problem #1: layer isn't displayed on the map. What do I wrong? There are no javascript errors.
Problem #2: how can I add the layer on the layermenu?
createG4U('#g4u-map', 'conf/client.commented.json', 'conf/layers.commented.json').then(function (map) {
map.asSoonAs('ready', true, function () {
var openSeaMap_layer = new ol.layer.Tile({
title: 'OpenSeaMap',
name: 'OpenSeaMap',
code: 'OpenSeaMap',
datalayer: 'N',
source: new ol.source.OSM({
crossOrigin: null,
url: 'http://t1.openseamap.org/seamark/{z}/{x}/{y}.png'
})
});
alert('Visibility: ' + openSeaMap_layer.getVisible());
map.get('api').addLayer(openSeaMap_layer);
});
});
Thanks in advance!
Kind regards,
Sam