Skip to content

Commit 3e9434f

Browse files
authored
Fix map list "add to map" function (geonetwork#8774)
* Include links in saved selections index query * Add map list support for esri rest
1 parent 0034b69 commit 3e9434f

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

web-ui/src/main/resources/catalog/components/common/savedselections/SavedSelectionsDirective.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@
5959
label: "addToMap",
6060
filterFn: function (record) {
6161
var md = new Metadata(record);
62-
return md.getLinksByType("OGC:WMS").length > 0;
62+
const linkTypes = [
63+
"OGC:WMS",
64+
"ESRI REST: Map Service",
65+
"ESRI REST: Map Server"
66+
];
67+
// returns true as soon as any type has ≥1 link
68+
return linkTypes.some(type => md.getLinksByType(type).length > 0);
6369
},
6470
fn: function (uuids, records) {
6571
for (var i = 0; i < uuids.length; i++) {
@@ -95,6 +101,27 @@
95101
}
96102
});
97103
});
104+
105+
const esriLinks = [
106+
...md.getLinksByType("ESRI REST: Map Server"),
107+
...md.getLinksByType("ESRI REST: Map Service")
108+
];
109+
110+
angular.forEach(esriLinks, function (link) {
111+
if (gnMap.isLayerInMap(viewerMap, link.name, link.url)) {
112+
return;
113+
}
114+
115+
gnMap
116+
.addEsriRestLayer(viewerMap, link.url, link.name, false, md)
117+
.then(function (layer) {
118+
if (layer) {
119+
gnMap.feedLayerWithRelated(layer, link.group);
120+
}
121+
});
122+
123+
});
124+
98125
}
99126
},
100127
icon: "fa-globe"
@@ -197,7 +224,9 @@
197224
.post(
198225
"../api/search/records/_search",
199226
{
200-
_source: { includes: ["uuid", "root", "resourceTitle*", "isTemplate"] },
227+
_source: {
228+
includes: ["uuid", "root", "resourceTitle*", "isTemplate", "link"]
229+
},
201230
from: 0,
202231
size: 2000,
203232
query: {

0 commit comments

Comments
 (0)