-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathselect.js
97 lines (91 loc) · 3.59 KB
/
select.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* select layers and perform actions on selected features
*/
import '../../components/select-widget/select-widget';
import 'spectre-canjs/sp-form/fields/sp-text-field/sp-text-field';
import stache from 'can-stache';
import swal from 'sweetalert2';
import 'sweetalert2/dist/sweetalert2.css';
const layerUrl = 'https://services1.arcgis.com/6bXbLtkf4y11TosO/arcgis/rest/services/Restaurants/FeatureServer/0';
export default {
title: 'Use the search icon widget to select features',
debug: true,
// viewOptions - options to be passed to view constructor
viewOptions: {
center: [-93.28697204589844, 44.294471740722656],
zoom: 12
},
// mapOptions - options to be passed to map constructor
// layers are special and are passed to their designated layer constructor
// before map is created
mapOptions: {
basemap: 'gray',
layers: [{
// you can use "type" for a short hand version of the layer path
// see [types](can-arcgis/util/createLayers.js) for all the types
// or you can provide the full path, like this:
// path: 'esri/layers/FeatureLayer',
type: 'feature',
options: {
url: layerUrl,
id: 'resteraunts',
outFields: ['*']
}
}]
},
widgets: [{
parent: 'expand',
type: 'renderer',
renderer: stache(`<select-widget
layers:from="layers"
view:from="view"
actions:from="actions" />`),
parentOptions: {expanded: true, expandIconClass: 'esri-icon-search', expandTooltip: 'Expand/collapse search widget'},
options: {
layers: {
'Resteraunts': {
// url to a feature layer
url: layerUrl,
// an array of query objects
queries: [{
value: 'name',
label: 'Establishment Name',
fields: [{name: 'name', placeholder: 'Example: KFC'}],
queryTemplate: 'EstablishmentName LIKE \'%{name}%\''
}, {
value: 'riskType',
label: 'Risk Type',
queryTemplate: 'RiskType = {risk}',
fields: [{
name: 'risk',
alias: 'Risk Type',
editTag: 'sp-select-field',
options: [{
value: 1,
label: 'Inspected one time per year'
}, {
value: 2,
label: 'Inspected two times per year'
}, {
value: 3,
label: 'Inspected three times per year'
}]
}]
}]
}
},
actions: [{
label: 'Log Selected Features',
iconClass: 'esri-icon-announcement',
onClick (graphics) {
swal({
title: 'Features',
html: '<ul class="menu">' + graphics.map((graphic) => {
return `<li class="menu-item">${graphic.attributes.EstablishmentName || 'Unknown'}</li>`;
}).join('') + '</ul>'
});
}
}]
}
}]
};