-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
viewer.js
509 lines (500 loc) · 17.9 KB
/
viewer.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
define([
'esri/units',
'esri/layers/ImageParameters',
'dojo/sniff'
], function (units, ImageParameters, has) {
// helper function returning ImageParameters for dynamic layers
// example:
// imageParameters: buildImageParameters({
// layerIds: [0],
// layerOption: 'show'
// })
function buildImageParameters (config) {
config = config || {};
var ip = new ImageParameters();
//image parameters for dynamic services, set to png32 for higher quality exports
ip.format = 'png32';
for (var key in config) {
if (config.hasOwnProperty(key)) {
ip[key] = config[key];
}
}
return ip;
}
return {
// used for debugging your app
isDebug: true,
//default mapClick mode, mapClickMode lets widgets know what mode the map is in to avoid multipult map click actions from taking place (ie identify while drawing).
defaultMapClickMode: 'identify',
// map options, passed to map constructor. see: https://developers.arcgis.com/javascript/jsapi/map-amd.html#map1
mapOptions: {
basemap: 'streets',
center: [-96.59179687497497, 39.09596293629694],
zoom: 5,
sliderStyle: 'small'
},
layout: {
map: 'mapViewDiv'
},
panes: {
bottom: {
type: 'titlePane',
title: 'Tables',
iconClass: 'fas fa-fw fa-table',
open: false,
showInMenu: true,
content: '<div id="attributesContainer"></div>'
}
},
// custom titles
titles: {
header: 'CMV with Calcite Maps',
subHeader: 'make it your own',
pageTitle: 'CMV with Calcite Maps'
},
// operationalLayers: Array of Layers to load on top of the basemap: valid 'type' options: 'dynamic', 'tiled', 'feature'.
// The 'options' object is passed as the layers options for constructor. Title will be used in the legend only. id's must be unique and have no spaces.
// 3 'mode' options: MODE_SNAPSHOT = 0, MODE_ONDEMAND = 1, MODE_SELECTION = 2
operationalLayers: [{
type: 'feature',
url: 'https://services.arcgis.com/doC3DvW5p9jGtDST/arcgis/rest/services/RestaurantInspections_April2018/FeatureServer/0/',
title: 'Restaurants',
options: {
id: 'restaurants',
opacity: 1.0,
visible: true,
outFields: ['*'],
featureReduction: has('phone') ? null : {
type: 'cluster',
clusterRadius: 10
},
mode: 0
},
editorLayerInfos: {
disableGeometryUpdate: false
},
legendLayerInfos: {
exclude: false,
layerInfo: {
title: 'Restaurants'
}
},
layerControlLayerInfos: {
layerGroup: 'Grouped Feature Layers'
}
}, {
type: 'feature',
url: 'https://sampleserver6.arcgisonline.com/ArcGIS/rest/services/SF311/FeatureServer/0',
title: 'SF 311 Incidents',
options: {
id: 'sf311Incidents',
opacity: 1.0,
visible: true,
outFields: ['req_type', 'req_date', 'req_time', 'address', 'district'],
mode: 0
},
layerControlLayerInfos: {
layerGroup: 'Grouped Feature Layers'
}
}, {
type: 'dynamic',
url: 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyOperationalLayers/MapServer',
title: 'Louisville Public Safety',
options: {
id: 'louisvillePubSafety',
opacity: 1.0,
visible: true,
imageParameters: buildImageParameters({
layerIds: [0, 2, 4, 5, 8, 10, 12, 21],
layerOption: 'show'
})
},
identifyLayerInfos: {
layerIds: [2, 4, 5, 8, 12, 21]
},
layerControlLayerInfos: {
layerIds: [0, 2, 4, 5, 8, 9, 10, 12, 21]
},
legendLayerInfos: {
layerInfo: {
hideLayers: [21]
}
}
}, {
type: 'dynamic',
url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/MapServer',
title: 'Damage Assessment',
options: {
id: 'damageAssessment',
opacity: 1.0,
visible: true,
imageParameters: buildImageParameters()
},
legendLayerInfos: {
exclude: true
},
layerControlLayerInfos: {
swipe: true,
metadataUrl: true,
expanded: true
}
}],
// set include:true to load. For titlePane type set position the the desired order in the sidebar
widgets: {
growler: {
include: true,
id: 'growler',
type: 'domNode',
path: 'gis/dijit/Growler',
srcNodeRef: 'growlerDijit',
options: {}
},
overviewMap: {
include: true,
id: 'overviewMap',
type: 'map',
path: 'esri/dijit/OverviewMap',
options: {
map: true,
attachTo: 'bottom-right',
color: '#0000CC',
height: 100,
width: 125,
opacity: 0.30,
visible: false
}
},
scalebar: {
include: true,
id: 'scalebar',
type: 'map',
path: 'esri/dijit/Scalebar',
options: {
map: true,
attachTo: 'bottom-left',
scalebarStyle: 'line',
scalebarUnit: 'dual'
}
},
mapInfo: {
include: true,
id: 'mapInfo',
type: 'domNode',
path: 'gis/dijit/MapInfo',
srcNodeRef: 'mapInfoDijit',
options: {
map: true,
mode: 'dms',
firstCoord: 'y',
unitScale: 3,
showScale: true,
xLabel: '',
yLabel: '',
minWidth: 286
}
},
homeButton: {
include: true,
id: 'homeButton',
type: 'domNode',
path: 'esri/dijit/HomeButton',
srcNodeRef: 'homeButton',
options: {
map: true
}
},
locateButton: {
include: true,
id: 'locateButton',
type: 'domNode',
path: 'gis/dijit/LocateButton',
srcNodeRef: 'locateButton',
options: {
map: true,
publishGPSPosition: true,
highlightLocation: true,
useTracking: true,
geolocationOptions: {
maximumAge: 0,
timeout: 15000,
enableHighAccuracy: true
}
}
},
search: {
include: true,
type: 'domNode',
srcNodeRef: 'searchNavDiv',
path: 'esri/dijit/Search',
options: {
map: true,
visible: true,
enableInfoWindow: false,
enableButtonMode: true,
expanded: false
}
},
searchMenu: {
include: true,
type: 'titlePane',
path: 'esri/dijit/Search',
title: 'Search',
visibilityClass: 'visible-xs',
iconClass: 'fas fa-fw fa-search',
position: 0,
options: {
map: true,
visible: true,
enableInfoWindow: false
}
},
basemaps: {
include: true,
id: 'basemaps',
type: 'domNode',
path: 'gis/dijit/Basemaps',
srcNodeRef: 'basemapsDijit',
options: 'cmvConfig/basemaps'
},
layerControl: {
include: true,
id: 'layerControl',
type: 'titlePane',
path: 'gis/dijit/LayerControl',
title: 'Layers',
iconClass: 'fas fa-fw fa-th-list',
open: false,
position: 0,
options: {
map: true,
layerControlLayerInfos: true,
separated: true,
vectorReorder: true,
overlayReorder: true
}
},
legend: {
include: true,
id: 'legend',
type: 'titlePane',
path: 'gis/dijit/Legend',
title: 'Legend',
iconClass: 'far fa-fw fa-images',
open: false,
position: 1,
options: {
map: true,
legendLayerInfos: true
}
},
bookmarks: {
include: true,
id: 'bookmarks',
type: 'titlePane',
path: 'gis/dijit/Bookmarks',
title: 'Bookmarks',
iconClass: 'fas fa-fw fa-bookmark',
open: false,
position: 2,
options: 'cmvConfig/bookmarks'
},
find: {
include: true,
id: 'find',
type: 'titlePane',
canFloat: true,
path: 'gis/dijit/Find',
title: 'Find',
iconClass: 'fas fa-fw fa-search',
open: false,
position: 3,
options: 'cmvConfig/find'
},
draw: {
include: true,
id: 'draw',
type: 'titlePane',
canFloat: true,
path: 'gis/dijit/Draw',
title: 'Draw',
iconClass: 'fas fa-fw fa-paint-brush',
open: false,
position: 4,
options: {
map: true,
mapClickMode: true
}
},
measure: {
include: true,
id: 'measurement',
type: 'titlePane',
canFloat: true,
path: 'gis/dijit/Measurement',
title: 'Measure',
iconClass: 'fas fa-fw fa-expand',
open: false,
position: 5,
options: {
map: true,
mapClickMode: true,
defaultAreaUnit: units.SQUARE_MILES,
defaultLengthUnit: units.MILES
}
},
print: {
include: true,
id: 'print',
type: 'titlePane',
canFloat: true,
path: 'gis/dijit/Print',
title: 'Print',
iconClass: 'fas fa-fw fa-print',
open: false,
position: 6,
options: {
map: true,
printTaskURL: 'https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task',
copyrightText: 'Copyright 2014',
authorText: 'Me',
defaultTitle: 'Viewer Map',
defaultFormat: 'PDF',
defaultLayout: 'Letter ANSI A Landscape'
}
},
directions: {
include: true,
id: 'directions',
type: 'titlePane',
path: 'gis/dijit/Directions',
title: 'Directions',
iconClass: 'fas fa-fw fa-map-signs',
open: false,
position: 7,
options: {
map: true,
mapRightClickMenu: true,
options: {
routeTaskUrl: 'https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route',
routeParams: {
directionsLanguage: 'en-US',
directionsLengthUnits: units.MILES
},
active: false //for 3.12, starts active by default, which we dont want as it interfears with mapClickMode
}
}
},
editor: {
include: true,
id: 'editor',
type: 'titlePane',
path: 'gis/dijit/Editor',
title: 'Editor',
iconClass: 'fas fa-fw fa-pencil-alt',
open: false,
position: 8,
options: {
map: true,
mapClickMode: true,
editorLayerInfos: true,
settings: {
toolbarVisible: true,
showAttributesOnClick: true,
enableUndoRedo: true,
createOptions: {
polygonDrawTools: ['freehandpolygon', 'autocomplete']
},
toolbarOptions: {
reshapeVisible: true,
cutVisible: true,
mergeVisible: true
}
}
}
},
streetview: {
include: true,
id: 'streetview',
type: 'titlePane',
canFloat: true,
position: 9,
path: 'gis/dijit/StreetView',
title: 'StreetView',
iconClass: 'fas fa-fw fa-street-view',
paneOptions: {
resizable: true,
resizeOptions: {
minSize: {
w: 250,
h: 250
}
}
},
options: {
map: true,
mapClickMode: true,
mapRightClickMenu: true
}
},
identify: {
include: true,
id: 'identify',
type: 'titlePane',
path: 'gis/dijit/Identify',
title: 'Identify',
iconClass: 'fas fa-info-circle',
open: false,
position: 3,
preload: true,
options: 'cmvConfig/identify'
},
locale: {
include: true,
id: 'locale',
type: 'titlePane',
position: 100,
path: 'gis/dijit/Locale',
title: 'Locale',
iconClass: 'fas fa-fw fa-flag',
options: {
style: 'margin-left: 30px;'
}
},
calciteStyler: {
include: true,
id: 'calcite-styler',
type: 'titlePane',
path: 'widgets/CalciteStyler',
position: 100,
title: 'Calcite Styler',
open: false,
iconClass: 'fas fa-fw fa-cog',
options: {}
},
about: {
include: true,
type: 'floating',
position: 100,
path: 'dijit/layout/ContentPane',
title: 'Using CMV with Calcite Maps',
menuTitle: 'About CMV',
open: true,
iconClass: 'fas fa-fw fa-info',
options: {
className: 'text-center',
style: 'max-height:90%;',
content: [
'<div class="text-center" style="min-width:260px;font-size:60px;vertical-align:middle;width:90%;white-space:no-break;">',
'<a href="https://cmv.io/" target="_blank"><image style="height:60px;margin-top:-18px;" src="https://cmv.io/images/rocket-logo.png"></a>',
'<span class="fa fa-fw fa-plus"></span>',
'<a href="http://esri.github.io/calcite-maps/" target="_blank" class="esri-icon esri-icon-map-pin"style="color:#0079c1;text-decoration:none !important;"></a>',
'</div>',
'<h5>This is a demonstration of using <a href="https://cmv.io/" target="_blank">CMV</a> with Esri\'s <a href="http://esri.github.io/calcite-maps/" target="_blank">Calcite Maps</a>. You can use the styler widget to explore the different colors, styles and layouts. When you are done, apply the CSS styles and classes to your own apps.</h5>',
'<br/>',
'<button type="button" class="btn btn-success btn-lg" data-dismiss="modal">Get Started</a>'
].join('')
}
}
}
};
});