-
Notifications
You must be signed in to change notification settings - Fork 0
/
s4-details-nearest-plugin.xml
65 lines (51 loc) · 2.3 KB
/
s4-details-nearest-plugin.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0" encoding="UTF-8"?>
<!-- Creates a Find nearest section in detail view -->
<!-- Do not customize this tool. Make a copy of the tool and create your own tool -->
<!-- Look for Customize HERE -->
<tool type="plugin">
<requires>
[if: ModuleDefined("s4") ]
<include src="[module:s4.dir]/tools/s4-requires.xml" nodes="/tool/requires/*" mustexist="true"/>
[endif]
</requires>
<jssrc/>
<src><![CDATA[
[if: ModuleDefined("s4") ]
if (_s4Params.indexsearcher && _s4Params.indexsearcher.enabled){
var datasources = this.jsonConfig.datasources ? this.jsonConfig.datasources : "*";
// Hvad skal der søges i?
// Tilret datasources så der kun vises de nærmeste typer som du ønsker
var nearestHandler = new Septima.Search.S4NearestHandler({
datasources: datasources,
s4IndexSearcher: _s4Params.indexsearcher.searcher,
buttonText: "Nærmeste"
})
//Skal der vises rute?
//OBS: Der findes kun rute mellem punkter
var routeToken = this.jsonConfig.route && this.jsonConfig.route.token ? this.jsonConfig.route.token : cbKort.getSession().getParam("module.route.token");
if (routeToken) {
var routeProfile = this.jsonConfig.route && this.jsonConfig.route.profile ? this.jsonConfig.route.profile : "bicycle";
//'car','bicycle' eller 'foot'
var routeProvider = new Septima.Search.RouteProvider({
fields: ["route.distance", "route.geometry", "route.time"],
routeApiKey: routeToken,
routeProfile: routeProfile
})
nearestHandler.addDetailHandlerDef(routeProvider)
}
//Hvornår skal der søges?
var targets = this.jsonConfig.targets ? this.jsonConfig.targets : ["husnummer", "matrikelnummer", "virksomhed"];
if (_s4Params.dawasearcher && _s4Params.dawasearcher.enabled && targets.includes("husnummer")){
_s4Params.dawasearcher.searcher.addDetailHandlerDef(nearestHandler);
}
if (_s4Params.geosearcher && _s4Params.geosearcher.enabled && targets.includes("matrikelnummer")){
_s4Params.geosearcher.searcher.addDetailHandlerDef(nearestHandler);
}
if (_s4Params.cvrsearcher && _s4Params.cvrsearcher.enabled && targets.includes("virksomhed")){
_s4Params.cvrsearcher.searcher.addDetailHandlerDef(nearestHandler);
}
}
[endif]
]]>
</src>
</tool>