[GeoNetwork-users] Changing the Background Layers on the GN3 Map

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

Hi,

I am going to answer to my own question, in case anybody faces the same problem in the future.

The approach I mentioned on my last email was correct. The issue was that the cache was not enabling the changes in the config-viewer.xml to come through.
To get it working, I add to disable both, the cache of the web browser and the cache of GN.

Another interesting detail, is that to in order to show the background layers (rather than a default countries map), this has to be enabled in the JSON map/config settings.

Vriendelijke groeten / Kind regards,

Joana Simoes

Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664 <tel:+31318416664>

On 25 Feb 2016, at 21:15, Joana Simoes <joana.simoes@anonymised.com> wrote:

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

<GeoCat.png>

Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664

Hi,

Just add your WMS layers in the context, and set their group to "Background
layers".

On Tue, Mar 1, 2016 at 5:32 PM, Joana Simoes <joana.simoes@anonymised.com>
wrote:

Hi,

I am going to answer to my own question, in case anybody faces the same
problem in the future.

The approach I mentioned on my last email was correct. The issue was that
the cache was not enabling the changes in the config-viewer.xml to come
through.
To get it working, I add to disable both, the cache of the web browser and
the cache of GN.

Another interesting detail, is that to in order to show the background
layers (rather than a default countries map), this has to be enabled in the
JSON map/config settings.

Vriendelijke groeten / Kind regards,

Joana Simoes

Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664 <tel:+31318416664>
> On 25 Feb 2016, at 21:15, Joana Simoes <joana.simoes@anonymised.com> wrote:
>
> 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’ <
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
>
>
> <GeoCat.png>
>
> Veenderweg 13
> 6721 WD Bennekom
> The Netherlands
> T: +31 (0)318 416664
>

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
GeoNetwork-users mailing list
GeoNetwork-users@lists.sourceforge.net
geonetwork-users List Signup and Options
GeoNetwork OpenSource is maintained at
GeoNetwork - Geographic Metadata Catalog download | SourceForge.net

--
*camptocamp*
INNOVATIVE SOLUTIONS
BY OPEN SOURCE EXPERTS

*Florent Gravin*
0479444492