Skip to content

Commit

Permalink
Merge pull request #348 from KaiVolland/capabilites-namefield
Browse files Browse the repository at this point in the history
Capabilites namefield
  • Loading branch information
KaiVolland authored Jan 19, 2018
2 parents d1534ff + 2ccf00a commit d847cbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Util/CapabilitiesUtil/CapabilitiesUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@ class CapabilitiesUtil {
/**
* @static getLayersFromCapabilties - parse {OlLayerTile} from capabilities object
*
* @param {Object} capabilities A capabilities object.
* @param {String} nameField Configure the field which should be set as the
* 'name' property in the openlayers layer.
* @return {OlLayerTile[]} Array of OlLayerTile
*/
static getLayersFromWmsCapabilties(capabilities) {
static getLayersFromWmsCapabilties(capabilities, nameField = 'Name') {
const wmsVersion = get(capabilities,'version');
const wmsAttribution = get(capabilities,'Service.AccessConstraints');
const layersInCapabilities = get(capabilities,'Capability.Layer.Layer');
const wmsGetMapConfig = get(capabilities, 'Capability.Request.GetMap');
const wmsGetFeatureInfoConfig = get(capabilities, 'Capability.Request.GetFeatureInfo');
const getMapUrl = get(wmsGetMapConfig,'DCPType[0].HTTP.Get.OnlineResource');
const getFeatureInfoUrl = get(wmsGetFeatureInfoConfig,'DCPType[0].HTTP.Get.OnlineResource');

return layersInCapabilities.map((layerObj) => new OlLayerImage({
opacity: 1,
title: get(layerObj, 'Title'),
name: get(layerObj, nameField),
abstract: get(layerObj, 'Abstract'),
getFeatureInfoUrl: getFeatureInfoUrl,
getFeatureInfoFormats: get(wmsGetFeatureInfoConfig, 'Format'),
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AddWmsPanel from './Container/AddWmsPanel/AddWmsPanel.jsx';
import AddWmsLayerEntry from './Container/AddWmsPanel/AddWmsLayerEntry/AddWmsLayerEntry.jsx';
import SimpleButton from './Button/SimpleButton/SimpleButton.jsx';
import ToggleButton from './Button/ToggleButton/ToggleButton.jsx';
import ToggleGroup from './Button/ToggleGroup/ToggleGroup.jsx';
Expand Down Expand Up @@ -39,6 +40,7 @@ import { mappify } from './HigherOrderComponent/MappifiedComponent/MappifiedComp
import timeLayerAware from './HigherOrderComponent/TimeLayerAware/TimeLayerAware.jsx';

export {
AddWmsLayerEntry,
AddWmsPanel,
CircleMenu,
SimpleButton,
Expand Down

0 comments on commit d847cbd

Please sign in to comment.