Hi,
I am trying to change the background layers on the preview map of Geonetwork 3.0.x, from map quest, osm, and bing aerial to something else (custom WMS maps).
I identified that the list of layers presented on the drop-down menu, is defined on config-viewer.xml, so I added my layer at the bottom (type:somelayer):
<ows-context:ResourceList>
<ows-context:Layer name="{type=mapquest}"
group="Background layers"
hidden="false"
opacity="1">
<ows:Title>MapQuest</ows:Title>
</ows-context:Layer>
<ows-context:Layer name="{type=osm}"
group="Background layers"
hidden="true"
opacity="1">
<ows:Title>OpenStreetMap
</ows:Title>
</ows-context:Layer>
<ows-context:Layer name="{type=bing_aerial}"
group="Background layers"
hidden="true"
opacity="1">
<ows:Title>Bing Aerial</ows:Title>
</ows-context:Layer>
<ows-context:Layer name="{type=somelayer}"
group="Background layers"
hidden="true"
opacity="1">
<ows:Title>Some Layer</ows:Title>
</ows-context:Layer>
</ows-context:ResourceList>
Then I noticed that the type is defined in mapService.js, in function createLayerForType, so I instantiated my new type (“somelayer”) there:
createLayerForType: function(type, opt) {
switch (type) {
case 'mapquest':
return new ol.layer.Tile({
style: 'Road',
source: new ol.source.MapQuest({layer: 'osm'}),
title: 'MapQuest'
});
case 'osm':
return new ol.layer.Tile({
source: new ol.source.OSM(),
title: 'OpenStreetMap'
});
case 'bing_aerial':
return new ol.layer.Tile({
preload: Infinity,
source: new ol.source.BingMaps({
key: 'Ak-dzM4wZjSqTlzveKz5u0d4I' +
'Q4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3',
imagerySet: 'Aerial'
}),
title: 'Bing Aerial'
});
case ’somelayer':
return new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://demo.boundlessgeo.com/geoserver/wms’,
params: {'LAYERS': 'topp:states', 'TILED': true},
serverType: 'geoserver'
}),
title: 'Some Layer'
});
Finally there is a reference to the background layers on OwsContextService.js . Here, a loop iterates through all these layers and inspects the source, in order to detect the type. I am not completely sure, but I think that the source in my case would be an instance of TileWMS:
if (source instanceof ol.source.OSM) {
name = '{type=osm}';
} else if (source instanceof ol.source.MapQuest) {
name = '{type=mapquest}';
} else if (source instanceof ol.source.BingMaps) {
name = '{type=bing_aerial}';
} else if (source instanceof ol.source.TileWMS) {
name = '{type=somelayer}';
Unfortunately this code does not produce any visible changes on the map. The dropdown list remains unchanged; even if I am able to remove layers from it, by commenting them out of config-viewer.xml, it seems there is something missing in order to add them. Am I missing some configuration file, some reference to the background layers somewhere else? Or maybe the code on OwsContextService.js is failing to detect the layer?
Thanks in advance for your help, or for any comments/suggestions to could point me to right direction.
Vriendelijke groeten / Kind regards,
Joana Simoes
Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664