Skip to content

Commit b230423

Browse files
committed
feat: method getLayer
1 parent 65b1b9d commit b230423

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/GEOComp.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { geoContext } from './GEOContext';
2727
import { layersControl } from './LayersControl';
2828
// @ts-ignore
2929
import Notification from 'ol-ext/control/Notification'
30-
import { object } from 'prop-types';
30+
import { findLayer } from './vendors/helpers';
3131

3232
/**
3333
* Array of style configuration objects for styling the component.
@@ -653,7 +653,24 @@ GEOComp = withMethodExposing(GEOComp, [
653653
if (map) return map.getView().getZoom()
654654
return 0
655655
}
656-
}
656+
},
657+
{
658+
method: {
659+
name: "getLayer",
660+
description: "Get a layer by name",
661+
params: [
662+
{
663+
name: "name",
664+
type: "string",
665+
},
666+
667+
]
668+
},
669+
execute: async (comp: any, params: any) => {
670+
var map = comp.exposingValues.events['map:init']
671+
return findLayer(map, params[0])
672+
}
673+
},
657674
]);
658675

659676

0 commit comments

Comments
 (0)