Skip to content

Commit

Permalink
include layer options on catalag for maps in dahsboards
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed Mar 23, 2023
1 parent ce8bc5a commit 5000365
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion web/client/api/catalog/WMS.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const recordToLayer = (record, {
map = {},
layerBaseConfig,
localizedLayerStyles,
allowUnsecureLayers
allowUnsecureLayers,
service
} = {}) => {
if (!record || !record.references) {
// we don't have a valid record so no buttons to add
Expand Down Expand Up @@ -103,6 +104,7 @@ const recordToLayer = (record, {
allowedSRS: allowedSRS,
catalogURL,
...layerBaseConfig,
...service?.layerOptions,
...record.layerOptions,
localizedLayerStyles: !isNil(localizedLayerStyles) ? localizedLayerStyles : undefined,
...(!isEmpty(formats) && {imageFormats: formats.imageFormats, infoFormats: formats.infoFormats}),
Expand Down
5 changes: 3 additions & 2 deletions web/client/epics/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ export default (API) => ({
const text = layers[i];
return Rx.Observable.defer(() =>
API[format].textSearch(url, startPosition, maxRecords, text, {...layerOptions, ...service}).catch(() => ({ results: [] }))
).map(r => ({ ...r, format, url, text, layerOptions }));
).map(r => ({ ...r, format, url, text, layerOptions, service }));
});
return Rx.Observable.forkJoin(actions)
.switchMap((results) => {
if (isArray(results) && results.length) {
return Rx.Observable.of(results.map(r => {
const { format, url, text, layerOptions, ...result } = r;
const { format, url, text, layerOptions, service, ...result } = r;
const locales = currentMessagesSelector(state);
const records = API[format].getCatalogRecords(result, layerOptions, locales) || [];
const record = head(records.filter(rec => rec.identifier || rec.name === text)); // exact match of text and record identifier
Expand All @@ -183,6 +183,7 @@ export default (API) => ({
const layerBaseConfig = {}; // DO WE NEED TO FETCH IT FROM STATE???
const authkeyParamName = authkeyParamNameSelector(state);
const layer = API[format].getLayerFromRecord(record, {
service,
removeParams: authkeyParamName,
catalogURL: format === 'csw' && url
? url + "?request=GetRecordById&service=CSW&version=2.0.2&elementSetName=full&id=" + record.identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import API from '../../../api/catalog';
export const toLayer = (r, service) => ["tms", "wfs"].includes(service?.type) // for tms and wfs the layer is ready
? r
// the type wms is default (for csw and wms), wmts have to be passed. // TODO: improve and centralize more
: API[service?.type || 'wms'].getLayerFromRecord(r);
: API[service?.type || 'wms'].getLayerFromRecord(r, { service });

// checks for tms wmts in order to addSearch() to skip addSearch
export const addSearchObservable = (selected, service) => ["tms", "wmts"].includes(service?.type) ? Rx.Observable.of(toLayer(selected, service)) : addSearch(toLayer(selected, service));
Expand Down

0 comments on commit 5000365

Please sign in to comment.