1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6 |
|
7 | var React = _interopDefault(require('react'));
|
8 | var async = require('async');
|
9 | var async__default = _interopDefault(async);
|
10 | var ReactDOM = _interopDefault(require('react-dom'));
|
11 | var reactArcgis = require('react-arcgis');
|
12 | var arcgisToGeojsonUtils = require('@esri/arcgis-to-geojson-utils');
|
13 |
|
14 | function styleInject(css, ref) {
|
15 | if ( ref === void 0 ) ref = {};
|
16 | var insertAt = ref.insertAt;
|
17 |
|
18 | if (!css || typeof document === 'undefined') { return; }
|
19 |
|
20 | var head = document.head || document.getElementsByTagName('head')[0];
|
21 | var style = document.createElement('style');
|
22 | style.type = 'text/css';
|
23 |
|
24 | if (insertAt === 'top') {
|
25 | if (head.firstChild) {
|
26 | head.insertBefore(style, head.firstChild);
|
27 | } else {
|
28 | head.appendChild(style);
|
29 | }
|
30 | } else {
|
31 | head.appendChild(style);
|
32 | }
|
33 |
|
34 | if (style.styleSheet) {
|
35 | style.styleSheet.cssText = css;
|
36 | } else {
|
37 | style.appendChild(document.createTextNode(css));
|
38 | }
|
39 | }
|
40 |
|
41 | var css = ".ArcticMap_simple-form-group__1NBSl {\n margin-bottom: 1rem;\n }\n .ArcticMap_simple-text-label__sb2Ru {\n display: block;\n color: red;\n }\n .ArcticMap_simple-text-input__2vXLO {\n display: inline-block;\n margin-bottom: 0.5rem;\n font-size: 16px;\n font-weight: 400;\n color: rgb(33, 37, 41);\n }\n\n#ArcticMap_bottomleftbar__m8-8e{\n background: #fff;\n position: absolute;\n bottom: 30px;\n left: 15px;\n padding: 0px;\n font-family: 'Avenir Next W00\",\"Helvetica Neue\",Helvetica,Arial,sans-serif'\n}\n\n#ArcticMap_bottomleftbar__m8-8e p{\n padding-left: 12px;\n padding-right: 12px;\n}\n \n#ArcticMap_bottombar__2nOal {\n background: #fff;\n position: absolute;\n bottom: 30px;\n right: 15px;\n padding: 0;\n }\n\n .ArcticMap_action-button__2k3Yr {\n font-size: 16px;\n background-color: transparent;\n border: 1px solid #D3D3D3;\n color: #6e6e6e;\n height: 32px;\n width: 32px;\n text-align: center;\n box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);\n }\n\n .ArcticMap_action-button__2k3Yr:hover,\n .ArcticMap_action-button__2k3Yr:focus {\n background: #0079c1;\n color: #e4e4e4;\n }\n\n .ArcticMap_active__2g4Ex {\n background: #0079c1;\n color: #e4e4e4;\n }";
|
42 | var styles = { "simple-form-group": "ArcticMap_simple-form-group__1NBSl", "simple-text-label": "ArcticMap_simple-text-label__sb2Ru", "simple-text-input": "ArcticMap_simple-text-input__2vXLO", "bottomleftbar": "ArcticMap_bottomleftbar__m8-8e", "bottombar": "ArcticMap_bottombar__2nOal", "action-button": "ArcticMap_action-button__2k3Yr", "active": "ArcticMap_active__2g4Ex" };
|
43 | styleInject(css);
|
44 |
|
45 | var classCallCheck = function (instance, Constructor) {
|
46 | if (!(instance instanceof Constructor)) {
|
47 | throw new TypeError("Cannot call a class as a function");
|
48 | }
|
49 | };
|
50 |
|
51 | var createClass = function () {
|
52 | function defineProperties(target, props) {
|
53 | for (var i = 0; i < props.length; i++) {
|
54 | var descriptor = props[i];
|
55 | descriptor.enumerable = descriptor.enumerable || false;
|
56 | descriptor.configurable = true;
|
57 | if ("value" in descriptor) descriptor.writable = true;
|
58 | Object.defineProperty(target, descriptor.key, descriptor);
|
59 | }
|
60 | }
|
61 |
|
62 | return function (Constructor, protoProps, staticProps) {
|
63 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
64 | if (staticProps) defineProperties(Constructor, staticProps);
|
65 | return Constructor;
|
66 | };
|
67 | }();
|
68 |
|
69 | var inherits = function (subClass, superClass) {
|
70 | if (typeof superClass !== "function" && superClass !== null) {
|
71 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
72 | }
|
73 |
|
74 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
75 | constructor: {
|
76 | value: subClass,
|
77 | enumerable: false,
|
78 | writable: true,
|
79 | configurable: true
|
80 | }
|
81 | });
|
82 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
83 | };
|
84 |
|
85 | var possibleConstructorReturn = function (self, call) {
|
86 | if (!self) {
|
87 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
88 | }
|
89 |
|
90 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
91 | };
|
92 |
|
93 | var slicedToArray = function () {
|
94 | function sliceIterator(arr, i) {
|
95 | var _arr = [];
|
96 | var _n = true;
|
97 | var _d = false;
|
98 | var _e = undefined;
|
99 |
|
100 | try {
|
101 | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
102 | _arr.push(_s.value);
|
103 |
|
104 | if (i && _arr.length === i) break;
|
105 | }
|
106 | } catch (err) {
|
107 | _d = true;
|
108 | _e = err;
|
109 | } finally {
|
110 | try {
|
111 | if (!_n && _i["return"]) _i["return"]();
|
112 | } finally {
|
113 | if (_d) throw _e;
|
114 | }
|
115 | }
|
116 |
|
117 | return _arr;
|
118 | }
|
119 |
|
120 | return function (arr, i) {
|
121 | if (Array.isArray(arr)) {
|
122 | return arr;
|
123 | } else if (Symbol.iterator in Object(arr)) {
|
124 | return sliceIterator(arr, i);
|
125 | } else {
|
126 | throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
127 | }
|
128 | };
|
129 | }();
|
130 |
|
131 | var ArcticMapButton = function (_React$Component) {
|
132 | inherits(ArcticMapButton, _React$Component);
|
133 |
|
134 | function ArcticMapButton(props) {
|
135 | classCallCheck(this, ArcticMapButton);
|
136 |
|
137 | var _this = possibleConstructorReturn(this, (ArcticMapButton.__proto__ || Object.getPrototypeOf(ArcticMapButton)).call(this, props));
|
138 |
|
139 | _this.state = {
|
140 | enabled: true,
|
141 | useEsriIcon: props.esriicon !== null,
|
142 | active: props.showactive !== undefined && props.showactive === true
|
143 |
|
144 | };
|
145 |
|
146 | _this.fireclick = function (e) {
|
147 | if (this.props.onclick) {
|
148 | this.props.onclick(e);
|
149 | }
|
150 | };
|
151 |
|
152 | return _this;
|
153 | }
|
154 |
|
155 | createClass(ArcticMapButton, [{
|
156 | key: 'render',
|
157 | value: function render() {
|
158 |
|
159 | var style = {
|
160 | arcticButton: {
|
161 | padding: "5px",
|
162 | height: "32px",
|
163 | width: "32px",
|
164 | backgroundColor: "#fff",
|
165 | color: '#6e6e6e',
|
166 | border: 'none',
|
167 | display: 'flex',
|
168 | flexFlow: 'row nowrap',
|
169 | justifyContent: 'center',
|
170 | alignItems: 'center',
|
171 | cursor: 'pointer',
|
172 | '&:hover': {
|
173 | backgroundColor: "#ccc"
|
174 | }
|
175 | }
|
176 | };
|
177 |
|
178 | if (this.props.padtop) {
|
179 | style.arcticButton.marginTop = '10px';
|
180 | }
|
181 | if (this.props.padbottom) {
|
182 | style.arcticButton.marginBOttom = '10px';
|
183 | }
|
184 |
|
185 | if (this.state.useEsriIcon) {
|
186 | if (this.props.showactive && this.props.showactive === true) {
|
187 | style.arcticButton.backgroundColor = "#d4d1d1";
|
188 | } else {
|
189 | style.arcticButton.backgroundColor = "#fff";
|
190 | }
|
191 |
|
192 | var esriClassName = 'esri-icon esri-icon-' + this.props.esriicon;
|
193 |
|
194 | return React.createElement(
|
195 | 'button',
|
196 | { style: style.arcticButton, onClick: this.fireclick.bind(this), title: this.props.title },
|
197 | React.createElement('span', { style: { height: "15px", width: "15px" }, 'aria-hidden': true, className: esriClassName })
|
198 | );
|
199 | } else {
|
200 | return React.createElement('div', null);
|
201 | }
|
202 | }
|
203 | }]);
|
204 | return ArcticMapButton;
|
205 | }(React.Component);
|
206 |
|
207 | ArcticMapButton.displayName = 'ArcticMapButton';
|
208 |
|
209 | var style = {
|
210 | bg: {
|
211 | zIndex: "100",
|
212 | position: "absolute",
|
213 | top: 0,
|
214 | width: '100%',
|
215 | height: '100%',
|
216 | backgroundColor: '#5856569e'
|
217 |
|
218 | }
|
219 |
|
220 | };
|
221 | var loadingtext = {
|
222 | position: "absolute",
|
223 | top: '50%',
|
224 | left: '50%',
|
225 | transform: 'translate(-50%, -50%)',
|
226 | color: 'white'
|
227 | };
|
228 |
|
229 | var ArcticMapLoader = function (_React$Component) {
|
230 | inherits(ArcticMapLoader, _React$Component);
|
231 |
|
232 | function ArcticMapLoader(props) {
|
233 | classCallCheck(this, ArcticMapLoader);
|
234 | return possibleConstructorReturn(this, (ArcticMapLoader.__proto__ || Object.getPrototypeOf(ArcticMapLoader)).call(this, props));
|
235 | }
|
236 |
|
237 | createClass(ArcticMapLoader, [{
|
238 | key: 'render',
|
239 | value: function render() {
|
240 |
|
241 | if (this.props.loading === true) {
|
242 |
|
243 | return React.createElement(
|
244 | 'div',
|
245 | { style: style.bg },
|
246 | React.createElement(
|
247 | 'h1',
|
248 | { style: loadingtext },
|
249 | 'Working...'
|
250 | )
|
251 | );
|
252 | }
|
253 | return null;
|
254 | }
|
255 | }]);
|
256 | return ArcticMapLoader;
|
257 | }(React.Component);
|
258 |
|
259 | ArcticMapLoader.displayName = 'ArcticMapLoader';
|
260 |
|
261 | var styles$1 = {
|
262 | rightWidgetFull: {
|
263 | "position": "absolute",
|
264 | "right": "2px",
|
265 | "top": "2px",
|
266 | "bottom": "2px",
|
267 | "zIndex": "100",
|
268 |
|
269 | "minWidth": '30%',
|
270 | paddingTop: '20px'
|
271 | },
|
272 | widgetContainer: {
|
273 | position: 'realative',
|
274 | "paddingRight": "20px",
|
275 | "paddingLeft": "20px",
|
276 |
|
277 | "overflowY": 'auto',
|
278 | "maxHeight": '100%'
|
279 | }
|
280 |
|
281 | };
|
282 |
|
283 | var ArcticMapPanel = function (_React$Component) {
|
284 | inherits(ArcticMapPanel, _React$Component);
|
285 |
|
286 | function ArcticMapPanel(props) {
|
287 | classCallCheck(this, ArcticMapPanel);
|
288 |
|
289 | var _this = possibleConstructorReturn(this, (ArcticMapPanel.__proto__ || Object.getPrototypeOf(ArcticMapPanel)).call(this, props));
|
290 |
|
291 | _this.toggle = function () {
|
292 |
|
293 | var currvalue = this.state.open;
|
294 | this.setState({ open: !currvalue });
|
295 | };
|
296 | _this.toggle = _this.toggle.bind(_this);
|
297 |
|
298 | _this.mapFrame = document.getElementsByClassName('esri-view-root')[0];
|
299 | _this.renderEle = document.createElement("span");
|
300 | _this.mapFrame.appendChild(_this.renderEle);
|
301 | _this.state = {
|
302 | hidden: !_this.props.hidden ? false : true,
|
303 | open: _this.props.open || false
|
304 | };
|
305 |
|
306 | if (props.map) {
|
307 | _this.map = props.map;
|
308 | }
|
309 | if (props.view) {
|
310 | _this.view = props.view;
|
311 | _this.view.on('click', function (e) {
|
312 | _this.setState({ open: false });
|
313 | });
|
314 | }
|
315 |
|
316 | return _this;
|
317 | }
|
318 |
|
319 | createClass(ArcticMapPanel, [{
|
320 | key: 'componentDidMount',
|
321 | value: function componentDidMount() {
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 | }
|
330 | }, {
|
331 | key: 'componentDidUpdate',
|
332 | value: function componentDidUpdate() {
|
333 | this.renderPanel();
|
334 | }
|
335 | }, {
|
336 | key: 'render',
|
337 | value: function render() {
|
338 |
|
339 | return React.createElement(
|
340 | 'span',
|
341 | { visibility: this.state.hidden },
|
342 | React.createElement(ArcticMapButton, { padtop: this.props.padtop, padbottom: this.props.padbottom, esriicon: this.props.esriicon, onclick: this.toggle.bind(this), title: this.props.title })
|
343 | );
|
344 | }
|
345 | }, {
|
346 | key: 'renderPanel',
|
347 | value: function renderPanel() {
|
348 |
|
349 | if (this.state.open) {
|
350 | var ele = React.createElement('div', { className: 'esri-widget', style: styles$1.rightWidgetFull }, React.createElement('h2', { style: { "paddingLeft": "20px", marginTop: '6px', fontSize: '28px', marginBottom: '10px' } }, this.props.title), React.createElement('span', { style: { position: 'absolute', top: '20px', right: '20px' } }, React.createElement('button', {
|
351 | onClick: this.toggle,
|
352 | title: 'Close',
|
353 | style: { border: 'none', background: 'transparent', cursor: 'pointer' }
|
354 | }, React.createElement('span', {
|
355 | style: { fontSize: '28px' },
|
356 | 'aria-hidden': true,
|
357 | className: 'esri-icon esri-icon-close'
|
358 | }))
|
359 |
|
360 | ), React.createElement('div', { style: styles$1.widgetContainer }, React.createElement('div', null, this.props.children)));
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 | ReactDOM.render(ele, this.renderEle);
|
367 | } else {
|
368 | var eleempty = React.createElement('span', null);
|
369 | ReactDOM.render(eleempty, this.renderEle);
|
370 | }
|
371 | }
|
372 | }]);
|
373 | return ArcticMapPanel;
|
374 | }(React.Component);
|
375 |
|
376 | ArcticMapPanel.displayName = 'ArcticMapPanel';
|
377 |
|
378 | var style$1 = document.createElement('style');
|
379 | style$1.id = "esri-overrides";
|
380 | style$1.innerHTML = '.esri-ui-bottom-right {' + 'flex-flow: column;' + '}' + '.esri-ui-bottom-right .esri-component {' + 'margin-top: 10px;' + '}' + '.esri-layer-list { background-color: transparent; padding: 1px; }' + '.esri-layer-list__item--has-children .esri-layer-list__item { box-shadow: none; }' + '.esri-layer-list__item--has-children { border-bottom: none; box-shadow: 0px 0px 3px 0px black; border-radius: 4px; margin-bottom: 10px; }' + '.esri-basemap-gallery { position: absolute; bottom: 0; right: 0; }';
|
381 | document.head.appendChild(style$1);
|
382 |
|
383 | var ArcticMap = function (_React$Component) {
|
384 | inherits(ArcticMap, _React$Component);
|
385 |
|
386 | function ArcticMap(props) {
|
387 | classCallCheck(this, ArcticMap);
|
388 |
|
389 | var _this = possibleConstructorReturn(this, (ArcticMap.__proto__ || Object.getPrototypeOf(ArcticMap)).call(this, props));
|
390 |
|
391 | _this.state = {
|
392 | map: null,
|
393 | view: null,
|
394 | hideBasemapButton: false,
|
395 | loading: false,
|
396 | lat: props.lat,
|
397 | lng: props.lng,
|
398 | mode: props.mode || "view",
|
399 | basemap: props.basemap || "hybrid",
|
400 | sr: Number.parseInt(props.sr || "102100")
|
401 | };
|
402 |
|
403 | _this.handleMapLoad = _this.handleMapLoad.bind(_this);
|
404 | _this.handleMapClick = _this.handleMapClick.bind(_this);
|
405 | _this.layers = [];
|
406 | return _this;
|
407 | }
|
408 |
|
409 | createClass(ArcticMap, [{
|
410 | key: 'render',
|
411 | value: function render() {
|
412 | var self = this;
|
413 | var index = 0;
|
414 | this.layers = [];
|
415 |
|
416 | self.childrenElements = [];
|
417 |
|
418 | var children = React.Children.map(this.props.children, function (child) {
|
419 | if (child.type.displayName === 'ArcticMapLayer') {
|
420 | return React.cloneElement(child, {
|
421 | ref: function ref(c) {
|
422 | if (c) {
|
423 | self.layers.push(c);
|
424 | }
|
425 | }
|
426 | });
|
427 | } else if (child.type.displayName === 'ArcticMapEdit') {
|
428 |
|
429 | return React.cloneElement(child, {
|
430 | am: self
|
431 |
|
432 |
|
433 | });
|
434 | }
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 | else {
|
444 | return React.cloneElement(child, {
|
445 | am: self,
|
446 |
|
447 | map: self.state.map,
|
448 | view: self.state.view,
|
449 |
|
450 | ref: function ref(c) {
|
451 | if (c) {
|
452 | self.childrenElements.push(c);
|
453 | }return 'child-' + index++;
|
454 | }
|
455 | });
|
456 | }
|
457 | });
|
458 |
|
459 | if (children) {
|
460 | children = children.sort(function (l) {
|
461 | return l.type.displayName === 'ArcticMapEdit';
|
462 | }).reverse();
|
463 | } else {
|
464 | children = React.createElement('div', null);
|
465 | }
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 | return React.createElement(
|
474 | reactArcgis.Map,
|
475 | { 'class': 'full-screen-map',
|
476 | mapProperties: { basemap: this.state.basemap }, onLoad: this.handleMapLoad, onClick: this.handleMapClick },
|
477 | children,
|
478 | React.createElement(ArcticMapLoader, { loading: this.state.loading })
|
479 | );
|
480 | }
|
481 | }, {
|
482 | key: 'handleShowBasemaps',
|
483 | value: function handleShowBasemaps(event) {
|
484 | this.state.view.ui.add(this.basemapGallery, {
|
485 | position: 'bottom-right'
|
486 | });
|
487 |
|
488 | this.setState({ hideBasemapButton: true });
|
489 | }
|
490 | }, {
|
491 | key: 'handleMapClick',
|
492 | value: function handleMapClick(event) {
|
493 |
|
494 | }
|
495 | }, {
|
496 | key: 'createElementFromHTML',
|
497 | value: function createElementFromHTML(htmlString) {
|
498 | var div = document.createElement('div');
|
499 | div.innerHTML = htmlString.trim();
|
500 |
|
501 |
|
502 | return div.firstChild;
|
503 | }
|
504 | }, {
|
505 | key: 'setEdit',
|
506 | value: function setEdit(json, nofire, type) {
|
507 | if (nofire === null) {
|
508 | nofire = false;
|
509 | }
|
510 |
|
511 | if (type === null) {
|
512 | type = "polygon";
|
513 | }
|
514 |
|
515 | if (this.state.map.editor) {
|
516 | this.state.map.editor.setEditFeature(json, nofire, type);
|
517 | }
|
518 | }
|
519 | }, {
|
520 | key: 'setMode',
|
521 | value: function setMode(val) {
|
522 | this.setState({ mode: val });
|
523 | if (val === "identify") {
|
524 | this.state.view.cursor = "help";
|
525 | }
|
526 | if (val === "view") {
|
527 | this.state.view.cursor = "grab";
|
528 | }
|
529 | if (val === "select") {
|
530 | this.state.view.cursor = "auto";
|
531 | }
|
532 | if (val === "edit") {
|
533 | this.state.view.cursor = "crosshairs";
|
534 | }
|
535 | }
|
536 | }, {
|
537 | key: 'setJson',
|
538 | value: function setJson(json) {
|
539 | if (this.state.map.editor) {
|
540 | this.state.map.editor.setEditFeature(json, true);
|
541 | }
|
542 | }
|
543 | }, {
|
544 | key: 'handleMapLoad',
|
545 | value: function handleMapLoad(map, view) {
|
546 | var _this2 = this;
|
547 |
|
548 | this.setState({ map: map, view: view });
|
549 |
|
550 | var self = this;
|
551 | self.state.map.amlayers = [];
|
552 | var centerSplit = this.props.center.split('|');
|
553 | view.center = [parseFloat(centerSplit[1]), parseFloat(centerSplit[0])];
|
554 | view.zoom = parseInt(centerSplit[2]);
|
555 | self.cntrlIsPressed = false;
|
556 |
|
557 | reactArcgis.loadModules(['esri/widgets/Locate', 'esri/widgets/BasemapGallery', 'esri/widgets/Home', 'esri/widgets/Search', 'esri/layers/FeatureLayer',
|
558 |
|
559 | 'esri/geometry/geometryEngine', "esri/request"]).then(function (_ref) {
|
560 | var _ref2 = slicedToArray(_ref, 7),
|
561 | Locate = _ref2[0],
|
562 | BasemapGallery = _ref2[1],
|
563 | Home = _ref2[2],
|
564 | Search = _ref2[3],
|
565 | FeatureLayer = _ref2[4],
|
566 |
|
567 |
|
568 | geometryEngine = _ref2[5],
|
569 | Request = _ref2[6];
|
570 |
|
571 | window._request = Request;
|
572 | window._map = self;
|
573 | self.request = Request;
|
574 |
|
575 | if (self.state.mode === "identify") {
|
576 | self.state.view.cursor = "help";
|
577 | }
|
578 | if (self.state.mode === "view") {
|
579 | self.state.view.cursor = "grab";
|
580 | }
|
581 | if (self.state.mode === "edit") {
|
582 | self.state.view.cursor = "crosshairs";
|
583 | }
|
584 |
|
585 | if (self.state.mode === "select") {
|
586 | self.state.view.cursor = "auto";
|
587 | }
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 | view.popup.dockEnabled = true;
|
606 | view.popup.dockOptions.position = 'bottom-left';
|
607 |
|
608 |
|
609 |
|
610 |
|
611 | view.popup.watch("visible", function (visible) {
|
612 |
|
613 | if (!visible) {
|
614 | view.graphics.removeAll();
|
615 | }
|
616 | });
|
617 |
|
618 | view.popup.watch('selectedFeature', function (graphic) {
|
619 | view.graphics.removeAll();
|
620 | if (graphic) {
|
621 | var graphicTemplate = graphic.getEffectivePopupTemplate();
|
622 | graphicTemplate.actions = [{
|
623 | id: 'select-item',
|
624 | title: 'Select',
|
625 | image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDE0IDc5LjE1Njc5NywgMjAxNC8wOC8yMC0wOTo1MzowMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTQgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTQyREM3RDkwQzVGMTFFNTk4QkI4OTBEOTYzQTg5MzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTQyREM3REEwQzVGMTFFNTk4QkI4OTBEOTYzQTg5MzEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo1NDJEQzdENzBDNUYxMUU1OThCQjg5MEQ5NjNBODkzMSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo1NDJEQzdEODBDNUYxMUU1OThCQjg5MEQ5NjNBODkzMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Prb3PqgAAACTSURBVHjaYvz//z8DJYCJgVJAjgsiIyMFQBjEZgQZwMjISJJmILUXynVmIdVmqGZ9qFAe0S7AonnR8uXLk5jItBmsGSUWgIriSdUMNwCoaB6QmgulidaM7AKYgjiYIcRohkdjVFQUhmIoG69mlHSAxUYGQppRAhGo6AMoYQDxRWI1Y02JSC65SEgz3IABzY0AAQYAhIhWWCl3Pj0AAAAASUVORK5CYII="
|
626 |
|
627 | }];
|
628 |
|
629 | graphicTemplate.actions.items[0].visible = self.state.map.editor !== undefined;
|
630 | reactArcgis.loadModules(['esri/symbols/SimpleFillSymbol']).then(function (_ref3) {
|
631 | var _ref4 = slicedToArray(_ref3, 1),
|
632 | SimpleFillSymbol = _ref4[0];
|
633 |
|
634 | var symbol = new SimpleFillSymbol({
|
635 | color: [135, 206, 235, 0.5],
|
636 | style: "solid",
|
637 | outline: {
|
638 | color: [0, 191, 255],
|
639 | width: 1
|
640 | }
|
641 | });
|
642 | if (graphic) {
|
643 | graphic.symbol = symbol;
|
644 | var popupGraphic = graphic;
|
645 | view.graphics.add(popupGraphic);
|
646 | } else {
|
647 | view.graphics.removeAll();
|
648 | view.popup.content.graphic = null;
|
649 | }
|
650 | });
|
651 |
|
652 | }
|
653 | });
|
654 | view.popup.viewModel.on('trigger-action', function (event) {
|
655 | if (event.action.id === 'select-item') {
|
656 | self.state.map.editor.setEditFeature(event.target.selectedFeature, null, null, false, true);
|
657 | view.popup.close();
|
658 | }
|
659 | });
|
660 |
|
661 | window.addEventListener("keydown", function (event) {
|
662 | if (event.which == "17") self.cntrlIsPressed = true;
|
663 | });
|
664 |
|
665 | window.addEventListener("contextmenu", function (event) {
|
666 | self.contextmenuPressed = true;
|
667 | });
|
668 |
|
669 | window.addEventListener("keyup", function (event) {
|
670 | self.cntrlIsPressed = false;
|
671 | });
|
672 |
|
673 | view.on('click', function (event) {
|
674 | if (event.button == 0) {
|
675 | self.contextmenuPressed = false;
|
676 | }
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | if (self.state.hideBasemapButton && self.state.hideBasemapButton === true) {
|
684 | self.state.view.ui.remove(self.basemapGallery);
|
685 | self.setState({ hideBasemapButton: false });
|
686 | return;
|
687 | }
|
688 |
|
689 | if (self.state.mode === "view") {
|
690 | return;
|
691 | }
|
692 |
|
693 | if (self.state.map.editor && self.state.map.editor.state.editing === true) {
|
694 | return;
|
695 | }
|
696 |
|
697 | var currentmode = self.state.mode;
|
698 | if (currentmode !== 'select') {
|
699 | self.setMode("view");
|
700 | }
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 | var identresults = [];
|
707 |
|
708 | self.setState({ loading: true });
|
709 |
|
710 | var identLayers = self.layers.filter(function (layer) {
|
711 | var mapzoom = view.zoom;
|
712 |
|
713 | if (layer.props.identMaxZoom !== undefined) {
|
714 | if (Number.parseInt(layer.props.identMaxZoom, 10) > mapzoom) {
|
715 | return layer;
|
716 | } else {
|
717 | return;
|
718 | }
|
719 | }
|
720 |
|
721 | return layer;
|
722 | });
|
723 |
|
724 | identLayers = identLayers.concat(self.state.map.amlayers);
|
725 |
|
726 | async__default.eachSeries(identLayers, function (layer, cb) {
|
727 | layer.identify(event, function (results) {
|
728 | if (results) {
|
729 | results.layer = layer;
|
730 | identresults.push(results);
|
731 | }
|
732 | cb();
|
733 | });
|
734 | }, function (err) {
|
735 | var results = identresults.map(function (ir) {
|
736 | ir.results.forEach(function (res) {
|
737 | res.layer = ir.layer;
|
738 | res.acres = -1;
|
739 | if (res.feature.geometry) {
|
740 | res.acres = geometryEngine.geodesicArea(res.feature.geometry, 'acres');
|
741 | }
|
742 | });
|
743 | return ir.results;
|
744 | }) || [].reduce(function (a, b) {
|
745 | return a.concat(b);
|
746 | });
|
747 | self.setState({ loading: false });
|
748 |
|
749 | results = results.flat();
|
750 |
|
751 | results = results.sort(function (r1, r2) {
|
752 | if (r1.acres > r2.acres) {
|
753 | return 1;
|
754 | }
|
755 | return -1;
|
756 |
|
757 | });
|
758 |
|
759 | if (currentmode === "identify") {
|
760 |
|
761 |
|
762 | var popupresults = results.map(function (result) {
|
763 | var feature = result.feature;
|
764 | var layerName = result.layerName;
|
765 |
|
766 | feature.attributes.layerName = layerName;
|
767 |
|
768 | feature.popupTemplate = {
|
769 |
|
770 | title: result.layer.renderPopupTitle(feature, result),
|
771 | content: result.layer.renderPopup(feature, result),
|
772 | actions: [{ title: "Select", id: "select-action" }]
|
773 | };
|
774 |
|
775 | return feature;
|
776 | });
|
777 |
|
778 | if (popupresults.length > 0) {
|
779 | view.popup.close();
|
780 | view.popup.currentSearchResultFeature = null;
|
781 | self.state.view.popup.open({
|
782 | features: popupresults,
|
783 | location: event.mapPoint
|
784 | });
|
785 |
|
786 |
|
787 | self.state.view.popup.on('trigger-action', function (e) {
|
788 | if (e.action.id === 'select-action') ;
|
789 | });
|
790 | }
|
791 | self.setState({ loading: false });
|
792 | }
|
793 |
|
794 | if (currentmode === "select") {
|
795 | if (self.contextmenuPressed === true) {
|
796 |
|
797 | self.state.map.editor.setEditFeature(results[0].feature, null, null, false, true, true);
|
798 | } else {
|
799 |
|
800 | self.state.map.editor.setEditFeature(results[0].feature, null, null, false, true);
|
801 | }
|
802 | }
|
803 |
|
804 |
|
805 | });
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 | });
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 | if (_this2.props.locate) {
|
818 | var locateBtn = new Locate({
|
819 | view: self.state.view
|
820 | });
|
821 |
|
822 | self.state.view.ui.add(locateBtn, {
|
823 | position: 'top-right'
|
824 | });
|
825 | }
|
826 |
|
827 | _this2.basemapGallery = new BasemapGallery({
|
828 | view: self.state.view
|
829 | });
|
830 |
|
831 | _this2.basemapGallery.watch('activeBasemap', function (newValue, oldValue, property, object) {
|
832 | self.state.view.ui.remove(self.basemapGallery);
|
833 | self.setState({ hideBasemapButton: false });
|
834 | });
|
835 |
|
836 | map.on("basemap-change", function (a) {
|
837 |
|
838 |
|
839 | alert("BM CHanegd");
|
840 | });
|
841 |
|
842 |
|
843 |
|
844 | if (_this2.props.home) {
|
845 | var homeBtn = new Home({
|
846 | view: view
|
847 | });
|
848 |
|
849 |
|
850 | view.ui.add(homeBtn, 'top-right');
|
851 | }
|
852 |
|
853 | view.ui.remove('zoom');
|
854 |
|
855 | _this2.getEditFeature = function () {
|
856 | _this2.state.map.editor.state.tempGraphicsLayer.graphics.items[0];
|
857 | };
|
858 |
|
859 | setTimeout(function () {
|
860 | var evt = new Event('mapready', { bubbles: true });
|
861 | Object.defineProperty(evt, 'target', { value: self, enumerable: true });
|
862 |
|
863 | if (self.props.onmapready) {
|
864 | self.props.onmapready(evt);
|
865 | }
|
866 | }, 500);
|
867 | });
|
868 | }
|
869 | }]);
|
870 | return ArcticMap;
|
871 | }(React.Component);
|
872 |
|
873 | ArcticMap.displayName = 'ArcticMap';
|
874 |
|
875 | var ArcticMapLayer = function (_React$Component) {
|
876 | inherits(ArcticMapLayer, _React$Component);
|
877 |
|
878 | function ArcticMapLayer(props) {
|
879 | classCallCheck(this, ArcticMapLayer);
|
880 |
|
881 | var _this = possibleConstructorReturn(this, (ArcticMapLayer.__proto__ || Object.getPrototypeOf(ArcticMapLayer)).call(this, props));
|
882 |
|
883 | _this.state = {
|
884 | map: props.map,
|
885 | view: props.view,
|
886 | graphic: null,
|
887 | title: props.title,
|
888 | blockSelect: props.blockIdentSelect !== undefined
|
889 | };
|
890 | return _this;
|
891 | }
|
892 |
|
893 | createClass(ArcticMapLayer, [{
|
894 | key: 'componentWillUnmount',
|
895 | value: function componentWillUnmount() {
|
896 | this.props.view.graphics.remove(this.state.graphic);
|
897 | }
|
898 | }, {
|
899 | key: 'componentDidMount',
|
900 | value: function componentDidMount() {
|
901 | var _this2 = this;
|
902 |
|
903 | var self = this;
|
904 | reactArcgis.loadModules(['esri/Graphic', "esri/layers/FeatureLayer", "esri/layers/MapImageLayer", "esri/layers/ImageryLayer", "esri/layers/GraphicsLayer", "esri/tasks/IdentifyTask", "esri/tasks/support/IdentifyParameters", "esri/geometry/Point", "esri/symbols/SimpleMarkerSymbol", "esri/layers/GroupLayer", "esri/renderers/Renderer"]).then(function (_ref) {
|
905 | var _ref2 = slicedToArray(_ref, 11),
|
906 | Graphic = _ref2[0],
|
907 | FeatureLayer = _ref2[1],
|
908 | MapImageLayer = _ref2[2],
|
909 | ImageryLayer = _ref2[3],
|
910 | GraphicsLayer = _ref2[4],
|
911 | IdentifyTask = _ref2[5],
|
912 | IdentifyParameters = _ref2[6],
|
913 | Point = _ref2[7],
|
914 | SimpleMarkerSymbol = _ref2[8],
|
915 | GroupLayer = _ref2[9],
|
916 | Renderer = _ref2[10];
|
917 |
|
918 |
|
919 |
|
920 |
|
921 | var children = React.Children.map(_this2.props.children, function (child) {
|
922 | if (child.type.displayName === 'ArcticMapLayerPopup') {
|
923 | return child;
|
924 |
|
925 |
|
926 |
|
927 | }
|
928 | });
|
929 |
|
930 | self.layerRenderers = children;
|
931 |
|
932 | var childrenEles = [];
|
933 | if (self.props.children) {
|
934 | if (Array.isArray(self.props.children)) {
|
935 | childrenEles = self.props.children;
|
936 | } else {
|
937 | childrenEles.push(self.props.children);
|
938 | }
|
939 | }
|
940 |
|
941 | var renderers = childrenEles.filter(function (child) {
|
942 | if (child.type.displayName === 'ArcticMapLayerRenderer') {
|
943 | return child;
|
944 | }
|
945 | });
|
946 |
|
947 |
|
948 |
|
949 | if (self.props.type === "feature") {
|
950 |
|
951 | var featureLayer = new FeatureLayer({
|
952 | url: self.props.src,
|
953 | outFields: ["*"]
|
954 | });
|
955 | self.layerRef = featureLayer;
|
956 | self.state.map.add(featureLayer);
|
957 | }
|
958 |
|
959 | if (self.props.type === "group") {
|
960 | var gtrans = 1;
|
961 | if (self.props.transparency) {
|
962 | gtrans = Number.parseFloat(self.props.transparency);
|
963 | }
|
964 | var srcsplit = self.props.src.split(',');
|
965 |
|
966 | var gmaplayer = new GroupLayer({
|
967 |
|
968 | opacity: gtrans
|
969 |
|
970 | });
|
971 | if (self.props.title) {
|
972 |
|
973 | gmaplayer.title = self.props.title;
|
974 | }
|
975 |
|
976 | srcsplit.forEach(function (src) {
|
977 | var glayer = new MapImageLayer({
|
978 | url: src,
|
979 | opacity: gtrans
|
980 |
|
981 | });
|
982 | gmaplayer.layers.add(glayer);
|
983 |
|
984 | glayer.when(function () {
|
985 |
|
986 | var layerids = [];
|
987 |
|
988 | glayer.allSublayers.items.forEach(function (sublayer) {
|
989 | layerids.push(sublayer.id);
|
990 |
|
991 |
|
992 | var renderer = renderers.find(function (r) {
|
993 | if (r.props.layer === sublayer.title || r.props.layer === '' + sublayer.id) {
|
994 | return r;
|
995 | }
|
996 | });
|
997 | if (renderer !== undefined) {
|
998 |
|
999 | sublayer.renderer = renderer.props.style;
|
1000 | }
|
1001 |
|
1002 | });
|
1003 | layerids.reverse();
|
1004 |
|
1005 | self.identifyTask = new IdentifyTask(self.props.src);
|
1006 | self.params = new IdentifyParameters();
|
1007 | self.params.tolerance = 3;
|
1008 | self.params.layerIds = layerids;
|
1009 | self.params.layerOption = "visible";
|
1010 | self.params.width = self.state.view.width;
|
1011 | self.params.height = self.state.view.height;
|
1012 | self.params.returnGeometry = true;
|
1013 | self.params.returnGeometry = self.state.blockSelect;
|
1014 |
|
1015 |
|
1016 | });
|
1017 | });
|
1018 |
|
1019 | self.layerRef = gmaplayer;
|
1020 | self.state.map.add(gmaplayer);
|
1021 | }
|
1022 |
|
1023 | if (self.props.type === "dynamic") {
|
1024 |
|
1025 | var trans = 1;
|
1026 | if (self.props.transparency) {
|
1027 | trans = Number.parseFloat(self.props.transparency);
|
1028 | }
|
1029 |
|
1030 | var maplayer = new MapImageLayer({
|
1031 | url: self.props.src,
|
1032 | opacity: trans
|
1033 |
|
1034 | });
|
1035 |
|
1036 | if (self.props.childsrc) ;
|
1037 |
|
1038 | if (self.props.title) {
|
1039 |
|
1040 | maplayer.title = self.props.title;
|
1041 | }
|
1042 |
|
1043 | maplayer.on("layerview-create", function (event) {
|
1044 |
|
1045 | });
|
1046 |
|
1047 | maplayer.when(function () {
|
1048 |
|
1049 | var layerids = [];
|
1050 |
|
1051 | maplayer.allSublayers.items.forEach(function (sublayer) {
|
1052 | layerids.push(sublayer.id);
|
1053 |
|
1054 |
|
1055 | var renderer = renderers.find(function (r) {
|
1056 | if (r.props.layer === sublayer.title || r.props.layer === '' + sublayer.id) {
|
1057 | return r;
|
1058 | }
|
1059 | });
|
1060 | if (renderer !== undefined) {
|
1061 |
|
1062 | sublayer.renderer = renderer.props.style;
|
1063 | }
|
1064 |
|
1065 | });
|
1066 | layerids.reverse();
|
1067 |
|
1068 | self.identifyTask = new IdentifyTask(self.props.src);
|
1069 | self.params = new IdentifyParameters();
|
1070 | self.params.tolerance = 3;
|
1071 | self.params.layerIds = layerids;
|
1072 | self.params.layerOption = "visible";
|
1073 | self.params.width = self.state.view.width;
|
1074 | self.params.height = self.state.view.height;
|
1075 | self.params.returnGeometry = true;
|
1076 | self.params.returnGeometry = self.state.blockSelect;
|
1077 |
|
1078 |
|
1079 | });
|
1080 |
|
1081 | self.layerRef = maplayer;
|
1082 | self.state.map.add(maplayer);
|
1083 | }
|
1084 |
|
1085 | if (self.props.type === "image") {
|
1086 |
|
1087 | var imagelayer = new ImageryLayer({
|
1088 | url: self.props.src,
|
1089 | format: "jpgpng"
|
1090 | });
|
1091 | self.layerRef = imagelayer;
|
1092 | self.state.map.add(imagelayer);
|
1093 | }
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 | self.layerRef.when(function () {
|
1175 | setTimeout(function () {
|
1176 | var evt = new Event('ready', { bubbles: true });
|
1177 | Object.defineProperty(evt, 'target', { value: self, enumerable: true });
|
1178 |
|
1179 | if (self.props.onready) {
|
1180 | self.props.onready(evt);
|
1181 | }
|
1182 | }, 500);
|
1183 | });
|
1184 |
|
1185 |
|
1186 | });
|
1187 | }
|
1188 | }, {
|
1189 | key: 'zoomto',
|
1190 | value: function zoomto() {
|
1191 | if (this.layerRef.graphics) {
|
1192 | this.state.view.goTo(this.layerRef.graphics.items);
|
1193 | }
|
1194 | }
|
1195 | }, {
|
1196 | key: 'renderPopupTitle',
|
1197 | value: function renderPopupTitle(feature, result) {
|
1198 | if (result.layerId !== undefined && this.layerRenderers) {
|
1199 | var popupTitle = this.layerRenderers.find(function (l) {
|
1200 | return l.props.layerid === result.layerId.toString();
|
1201 | });
|
1202 | if (popupTitle && result.layerId == popupTitle.props.layerid) {
|
1203 | return popupTitle.props.popuptitle;
|
1204 | } else {
|
1205 | return result.layerName;
|
1206 | }
|
1207 | } else {
|
1208 | return result.layerName;
|
1209 | }
|
1210 | }
|
1211 | }, {
|
1212 | key: 'renderPopup',
|
1213 | value: function renderPopup(feature, result) {
|
1214 |
|
1215 | if (result.layerId !== undefined && this.layerRenderers) {
|
1216 | var popuprender = this.layerRenderers.find(function (l) {
|
1217 | return l.props.layerid === result.layerId.toString();
|
1218 | });
|
1219 | if (popuprender && popuprender.props.popup !== undefined) {
|
1220 | var ele = popuprender.props.popup(feature, result);
|
1221 |
|
1222 | if (ele) {
|
1223 | var workingdiv = document.createElement('div');
|
1224 | ReactDOM.render(ele, workingdiv);
|
1225 | return workingdiv;
|
1226 | }
|
1227 | }
|
1228 | }
|
1229 |
|
1230 | var popupText = "";
|
1231 | var atts = Object.getOwnPropertyNames(feature.attributes);
|
1232 | atts.forEach(function (att) {
|
1233 | if (att === 'layerName') ; else {
|
1234 | popupText += '<b>' + att + '</b> : ' + feature.attributes[att] + '<br/>';
|
1235 | }
|
1236 | });
|
1237 |
|
1238 | return popupText;
|
1239 | }
|
1240 | }, {
|
1241 | key: 'render',
|
1242 | value: function render() {
|
1243 | return null;
|
1244 | }
|
1245 | }, {
|
1246 | key: 'identify',
|
1247 | value: function identify(event, callback) {
|
1248 |
|
1249 | var self = this;
|
1250 | if (this.props.type === "geojson") {
|
1251 |
|
1252 | this.state.view.hitTest(event).then(function (htresponse) {
|
1253 |
|
1254 |
|
1255 |
|
1256 | var mapPoint = event.mapPoint;
|
1257 | var response = {
|
1258 | layer: self.layerRef,
|
1259 | results: htresponse.results.map(function (r) {
|
1260 | return { feature: r.graphic, layerName: self.layerRef.title };
|
1261 | })
|
1262 | };
|
1263 | callback(response);
|
1264 | });
|
1265 | } else {
|
1266 |
|
1267 | if (!this.params) {
|
1268 | callback(null);return;
|
1269 | }
|
1270 |
|
1271 | this.params.geometry = event.mapPoint;
|
1272 | this.params.mapExtent = this.state.view.extent;
|
1273 | this.params.returnGeometry = true;
|
1274 |
|
1275 | this.identifyTask.execute(this.params).then(function (response) {
|
1276 |
|
1277 | callback(response);
|
1278 | });
|
1279 | }
|
1280 | }
|
1281 | }]);
|
1282 | return ArcticMapLayer;
|
1283 | }(React.Component);
|
1284 |
|
1285 | ArcticMapLayer.displayName = "ArcticMapLayer";
|
1286 |
|
1287 | var css$1 = "\n#ArcticMapEdit_topbar__1GWR4 {\n background: #fff;\n \n \n padding: 2px;\n }\n\n .ArcticMapEdit_action-button__2EIsV {\n display: block;\n font-size: 16px;\n background-color: transparent;\n border: 1px solid #D3D3D3;\n color: #6e6e6e;\n height: 40px;\n width: 125px;\n text-align: center;\n box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);\n padding: 2px;\n }\n\n .ArcticMapEdit_action-button__2EIsV:hover,\n .ArcticMapEdit_action-button__2EIsV:focus {\n background: #0079c1;\n color: #e4e4e4;\n }\n\n .ArcticMapEdit_active__rGKFh {\n background: #0079c1;\n color: #e4e4e4;\n }\n\n .ArcticMapEdit_infoarea__2vzls {\n width: 300px;\n word-wrap: break-word;\n margin: 0px;\n }\n\n .ArcticMapEdit_hide_input__1Pm3t {\n width:0px;\n }\n .ArcticMapEdit_btm_primary_file__1ypOM {\n background-color: #005a70;\n padding: 7px;\n border: 1px solid #D3D3D3;\n color: #D3D3D3;\n height: 40px;\n width: 125px;\n text-align: center;\n box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);\n border-radius: 5px;\n }\n\n input[type=\"file\"]\n {\n display: none;\n }\n .ArcticMapEdit_fileUpload__r84Hl .ArcticMapEdit_upload__3WWMG \n {\n display: inline-block;\n background-color: #005a70;\n color: #e0ebeb;\n }";
|
1288 | var style$2 = { "topbar": "ArcticMapEdit_topbar__1GWR4", "action-button": "ArcticMapEdit_action-button__2EIsV", "active": "ArcticMapEdit_active__rGKFh", "infoarea": "ArcticMapEdit_infoarea__2vzls", "hide_input": "ArcticMapEdit_hide_input__1Pm3t", "btm_primary_file": "ArcticMapEdit_btm_primary_file__1ypOM", "fileUpload": "ArcticMapEdit_fileUpload__r84Hl", "upload": "ArcticMapEdit_upload__3WWMG" };
|
1289 | styleInject(css$1);
|
1290 |
|
1291 | var ArcticMapEdit = function (_React$Component) {
|
1292 | inherits(ArcticMapEdit, _React$Component);
|
1293 |
|
1294 | function ArcticMapEdit(props) {
|
1295 | classCallCheck(this, ArcticMapEdit);
|
1296 |
|
1297 | var _this = possibleConstructorReturn(this, (ArcticMapEdit.__proto__ || Object.getPrototypeOf(ArcticMapEdit)).call(this, props));
|
1298 |
|
1299 | props.map.editor = _this;
|
1300 | _this.state = {
|
1301 | map: props.map,
|
1302 | view: props.view,
|
1303 | graphic: null,
|
1304 | hideEditors: false,
|
1305 | editing: false,
|
1306 | showUploading: false,
|
1307 | hidden: !_this.props.hidden ? false : true
|
1308 | };
|
1309 |
|
1310 | _this.uploadPanel = React.createRef();
|
1311 | return _this;
|
1312 | }
|
1313 |
|
1314 | createClass(ArcticMapEdit, [{
|
1315 | key: "componentWillUnmount",
|
1316 | value: function componentWillUnmount() {
|
1317 | this.props.view.graphics.remove(this.state.graphic);
|
1318 | }
|
1319 | }, {
|
1320 | key: "componentDidMount",
|
1321 | value: function componentDidMount() {
|
1322 | var _this2 = this;
|
1323 |
|
1324 | var self = this;
|
1325 | reactArcgis.loadModules(["esri/Graphic", "esri/layers/GraphicsLayer", "esri/widgets/Sketch/SketchViewModel", "esri/geometry/Geometry", "esri/geometry/Polygon", "esri/geometry/geometryEngine"]).then(function (_ref) {
|
1326 | var _ref2 = slicedToArray(_ref, 6),
|
1327 | Graphic = _ref2[0],
|
1328 | GraphicsLayer = _ref2[1],
|
1329 | SketchViewModel = _ref2[2],
|
1330 | Geometry = _ref2[3],
|
1331 | Polygon = _ref2[4],
|
1332 | geometryEngine = _ref2[5];
|
1333 |
|
1334 | var tempGraphicsLayer = new GraphicsLayer({ title: 'Edit Layer', listMode: "hide" });
|
1335 | self.setState({ tempGraphicsLayer: tempGraphicsLayer });
|
1336 |
|
1337 | self.state.map.add(tempGraphicsLayer);
|
1338 |
|
1339 | var sketchViewModel = new SketchViewModel({
|
1340 | view: self.state.view,
|
1341 | layer: tempGraphicsLayer,
|
1342 | defaultUpdateOptions: {
|
1343 |
|
1344 | },
|
1345 | pointSymbol: {
|
1346 | type: "simple-marker",
|
1347 | style: "circle",
|
1348 | color: "yellow",
|
1349 | size: "3px",
|
1350 | outline: {
|
1351 | color: [255, 255, 255],
|
1352 | width: 3
|
1353 | }
|
1354 | },
|
1355 | polylineSymbol: {
|
1356 | type: "simple-line",
|
1357 | color: "yellow",
|
1358 | width: "3",
|
1359 | style: "solid"
|
1360 | },
|
1361 | polygonSymbol: {
|
1362 | type: "simple-fill",
|
1363 | color: "rgba(224, 206, 69, 0.8)",
|
1364 | style: "solid",
|
1365 | outline: {
|
1366 | color: "yellow",
|
1367 | width: 3
|
1368 | }
|
1369 | }
|
1370 | });
|
1371 |
|
1372 | self.setState({ tempGraphicsLayer: tempGraphicsLayer, sketchViewModel: sketchViewModel });
|
1373 |
|
1374 | self.setUpClickHandler.bind(_this2);
|
1375 |
|
1376 | sketchViewModel.on("create", function (event) {
|
1377 |
|
1378 | if (event.state === 'complete') {
|
1379 |
|
1380 | tempGraphicsLayer.graphics = [event.graphic];
|
1381 | if (_this2.props.single) {
|
1382 |
|
1383 | _this2.setState({ hideEditors: true });
|
1384 | }
|
1385 |
|
1386 | setTimeout(function () {
|
1387 |
|
1388 | self.setState({ geojson: arcgisToGeojsonUtils.arcgisToGeoJSON(event.graphic.geometry.toJSON()), datajson: event.graphic.toJSON(), editing: false });
|
1389 | self.firenewfeature();
|
1390 | }, 1000);
|
1391 | }
|
1392 | });
|
1393 |
|
1394 | sketchViewModel.on("update", function (event) {
|
1395 | self.setState({ editing: true });
|
1396 | if (event.state === 'start' && self.state.mode === 'select') {
|
1397 | return false;
|
1398 | }
|
1399 | if (event.state === 'complete' || event.state === 'cancel') {
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 | setTimeout(function () {
|
1411 | self.setState({ geojson: arcgisToGeojsonUtils.arcgisToGeoJSON(event.graphics[0].geometry.toJSON()), datajson: event.graphics[0].toJSON() });
|
1412 |
|
1413 | self.firenewfeature();
|
1414 | }, 1000);
|
1415 | }
|
1416 | });
|
1417 |
|
1418 |
|
1419 | sketchViewModel.on("update-complete", function (event) {
|
1420 | event.graphic.geometry = event.geometry;
|
1421 | tempGraphicsLayer.graphics = [event.graphic];
|
1422 |
|
1423 |
|
1424 |
|
1425 | self.state.editGraphic = null;
|
1426 | });
|
1427 |
|
1428 | _this2.top_right_node = document.createElement("div");
|
1429 | self.state.view.ui.add(_this2.top_right_node, "top-right");
|
1430 |
|
1431 | self.setState({ loaded: true });
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 | self.setEditFeature = function (feature, nofire, type, zoomto, addto, trim) {
|
1438 |
|
1439 | if (nofire === null) {
|
1440 | nofire = false;
|
1441 | }
|
1442 |
|
1443 | if (type === null) {
|
1444 | type = "polygon";
|
1445 | }
|
1446 |
|
1447 | if (zoomto === null) {
|
1448 | zoomto = true;
|
1449 | }
|
1450 |
|
1451 | if (addto === null) {
|
1452 | addto = false;
|
1453 | }
|
1454 | if (trim === null) {
|
1455 | trim = false;
|
1456 | }
|
1457 |
|
1458 | if (feature.attributes.layerName) {
|
1459 | feature.sourceLayer = feature.attributes.layerName.trim();
|
1460 | } else {
|
1461 | feature.sourceLayer = 'PLSS';
|
1462 | }
|
1463 |
|
1464 | if (!feature.geometry.type) {
|
1465 | if (type === "polygon") {
|
1466 |
|
1467 | feature.geometry = new Polygon(feature.geometry);
|
1468 | feature.geometry.type = "polygon";
|
1469 | }
|
1470 | }
|
1471 |
|
1472 | _this2.state.sketchViewModel.cancel();
|
1473 | if (!addto) {
|
1474 | _this2.state.tempGraphicsLayer.removeAll();
|
1475 | }
|
1476 | _this2.setState({ hideEditors: false, geojson: null });
|
1477 |
|
1478 | var graphic = null;
|
1479 | if (!feature.geometry.toJSON && feature.symbol) {
|
1480 | graphic = Graphic.fromJSON(feature);
|
1481 | } else {
|
1482 |
|
1483 | graphic = new Graphic({
|
1484 | geometry: feature.geometry,
|
1485 | symbol: _this2.state.sketchViewModel.polygonSymbol
|
1486 | });
|
1487 | }
|
1488 |
|
1489 | if (graphic.geometry === null) {
|
1490 | graphic.geometry = feature.geometry;
|
1491 | }
|
1492 |
|
1493 | if (trim) {
|
1494 | if (_this2.state.tempGraphicsLayer.graphics.items.length > 0) {
|
1495 |
|
1496 | var geometrys = _this2.state.tempGraphicsLayer.graphics.items.map(function (i) {
|
1497 | return i.geometry;
|
1498 | });
|
1499 |
|
1500 | var merge = geometryEngine.union(geometrys);
|
1501 | var isEqual = geometryEngine.equals(merge, graphic.geometry);
|
1502 | if (!isEqual) {
|
1503 | merge = geometryEngine.difference(merge, graphic.geometry);
|
1504 | graphic = new Graphic({
|
1505 | geometry: merge,
|
1506 | symbol: _this2.state.sketchViewModel.polygonSymbol
|
1507 | });
|
1508 | graphic.geometry.sourceLayer = feature.sourceLayer;
|
1509 | _this2.state.tempGraphicsLayer.graphics = [graphic];
|
1510 | } else {
|
1511 | _this2.state.tempGraphicsLayer.graphics = null;
|
1512 | }
|
1513 | }
|
1514 | } else {
|
1515 | _this2.state.tempGraphicsLayer.add(graphic);
|
1516 |
|
1517 | if (_this2.state.tempGraphicsLayer.graphics.items.length > 0) {
|
1518 |
|
1519 | var geometrys = _this2.state.tempGraphicsLayer.graphics.items.map(function (i) {
|
1520 | return i.geometry;
|
1521 | });
|
1522 |
|
1523 | var merge = geometryEngine.union(geometrys);
|
1524 |
|
1525 | graphic = new Graphic({
|
1526 | geometry: merge,
|
1527 | symbol: _this2.state.sketchViewModel.polygonSymbol
|
1528 | });
|
1529 | graphic.geometry.sourceLayer = feature.sourceLayer;
|
1530 | _this2.state.tempGraphicsLayer.graphics = [graphic];
|
1531 | }
|
1532 | }
|
1533 |
|
1534 | if (_this2.props.single) {
|
1535 |
|
1536 | _this2.setState({ hideEditors: true });
|
1537 | }
|
1538 |
|
1539 | if (zoomto) {
|
1540 |
|
1541 | self.state.view.goTo(graphic);
|
1542 | }
|
1543 |
|
1544 | var geometry = feature.geometry;
|
1545 | if (geometry && !geometry.toJSON) {
|
1546 | geometry = Geometry.fromJSON(geometry);
|
1547 | }
|
1548 |
|
1549 | _this2.setState({ geojson: arcgisToGeojsonUtils.arcgisToGeoJSON(geometry.toJSON()), datajson: graphic.toJSON() });
|
1550 |
|
1551 | if (nofire === true) ; else {
|
1552 | self.firenewfeature();
|
1553 | }
|
1554 | };
|
1555 |
|
1556 | self.setEditFeature = self.setEditFeature.bind(self);
|
1557 |
|
1558 | self.setGeoJson = function (geojson) {
|
1559 |
|
1560 |
|
1561 |
|
1562 | };
|
1563 | self.setGeoJson = self.setGeoJson.bind(self);
|
1564 | });
|
1565 |
|
1566 | }
|
1567 | }, {
|
1568 | key: "firenewfeature",
|
1569 | value: function firenewfeature() {
|
1570 | var self = this;
|
1571 | var evt = new Event('newfeature', { bubbles: true });
|
1572 | Object.defineProperty(evt, 'target', { value: this, enumerable: true });
|
1573 | evt.data = self.state.datajson;
|
1574 |
|
1575 | if (self.props.onnewfeature) {
|
1576 | self.props.onnewfeature(evt);
|
1577 | }
|
1578 |
|
1579 | setTimeout(function () {
|
1580 | self.setState({ editing: false });
|
1581 | }, 200);
|
1582 | }
|
1583 | }, {
|
1584 | key: "addPointClick",
|
1585 | value: function addPointClick() {
|
1586 | this.state.sketchViewModel.create("point", { mode: "click" });
|
1587 | this.setState({ editing: true });
|
1588 | }
|
1589 | }, {
|
1590 | key: "addLineClick",
|
1591 | value: function addLineClick() {
|
1592 | this.state.sketchViewModel.create("polyline", { mode: "click" });
|
1593 | this.setState({ editing: true });
|
1594 | }
|
1595 | }, {
|
1596 | key: "addPolyClick",
|
1597 | value: function addPolyClick() {
|
1598 | this.state.sketchViewModel.create("polygon", { mode: "click" });
|
1599 | this.setState({ editing: true });
|
1600 | }
|
1601 | }, {
|
1602 | key: "addRecClick",
|
1603 | value: function addRecClick() {
|
1604 | this.state.sketchViewModel.create("rectangle", { mode: "click" });
|
1605 | this.setState({ editing: true });
|
1606 | }
|
1607 | }, {
|
1608 | key: "addCircleClick",
|
1609 | value: function addCircleClick() {
|
1610 | this.state.sketchViewModel.create("circle", { mode: "click" });
|
1611 | this.setState({ editing: true });
|
1612 | }
|
1613 | }, {
|
1614 | key: "fileUploaded",
|
1615 | value: function fileUploaded(evt) {
|
1616 | var self = this;
|
1617 | var fileName = evt.target.value.toLowerCase();
|
1618 | if (fileName.indexOf(".zip") !== -1) {
|
1619 |
|
1620 | self.processShapeFile(fileName, evt.target);
|
1621 | } else if (fileName.indexOf(".kml") !== -1) {
|
1622 |
|
1623 | self.processKMLFile(fileName, evt.target);
|
1624 | } else if (fileName.indexOf(".geojson") !== -1) {
|
1625 |
|
1626 |
|
1627 | self.processGeojsonFile(fileName, evt.target);
|
1628 | } else if (fileName.indexOf(".gml") !== -1) {
|
1629 |
|
1630 |
|
1631 | self.processGMLFile(fileName, evt.target);
|
1632 | } else if (fileName.indexOf(".gpx") !== -1) {
|
1633 |
|
1634 |
|
1635 | self.processGPXFile(fileName, evt.target);
|
1636 | } else {
|
1637 | document.getElementById("upload-status").innerHTML = '<p style="color:red">Only shapefile(.zip), .gml, .gpx, .kml, or .geojson are supported</p>';
|
1638 | }
|
1639 | }
|
1640 | }, {
|
1641 | key: "readTextFile",
|
1642 | value: function readTextFile(file) {
|
1643 | return new Promise(function (res, rej) {
|
1644 | var fr = new FileReader();
|
1645 | fr.onload = function (evt) {
|
1646 | res(evt.target.result);
|
1647 | };
|
1648 | fr.readAsText(file);
|
1649 | });
|
1650 | }
|
1651 | }, {
|
1652 | key: "kmlColor",
|
1653 | value: function kmlColor(v) {
|
1654 | var color, opacity;
|
1655 | v = v || '';
|
1656 | if (v.substr(0, 1) === '#') {
|
1657 | v = v.substr(1);
|
1658 | }
|
1659 | if (v.length === 6 || v.length === 3) {
|
1660 | color = v;
|
1661 | }
|
1662 | if (v.length === 8) {
|
1663 | opacity = parseInt(v.substr(0, 2), 16) / 255;
|
1664 | color = '#' + v.substr(6, 2) + v.substr(4, 2) + v.substr(2, 2);
|
1665 | }
|
1666 | return [color, isNaN(opacity) ? undefined : opacity];
|
1667 | }
|
1668 | }, {
|
1669 | key: "processGPXFile",
|
1670 | value: function processGPXFile(fileName, form) {
|
1671 | var file = fileName.replace(/^.*[\\\/]/, '');
|
1672 | var self = this;
|
1673 | this.readTextFile(form.files[0]).then(function (text) {
|
1674 | var parser = new DOMParser();
|
1675 | var gj = self.fc();
|
1676 | var xmlDoc = parser.parseFromString(text, "text/xml");
|
1677 | var trkMember = self.get(xmlDoc, "trk");
|
1678 | for (var j = 0; j < trkMember.length; j++) {
|
1679 | gj.features = gj.features.concat(self.getTRKMember(trkMember[j]));
|
1680 | }
|
1681 | var features = [];
|
1682 | gj.features.forEach(function (f) {
|
1683 | var esrijson = arcgisToGeojsonUtils.geojsonToArcGIS(f);
|
1684 | features.push(esrijson);
|
1685 | });
|
1686 | self.addGeojsonToMap(features, file, "GPX");
|
1687 | self.uploadPanel.current.toggle();
|
1688 | });
|
1689 | }
|
1690 | }, {
|
1691 | key: "getTRKMember",
|
1692 | value: function getTRKMember(root) {
|
1693 | var geometryProperty = this.get(root, "trkseg");
|
1694 | var geomsCoord = this.getGeometry(geometryProperty[0]);
|
1695 | var feature = {
|
1696 | type: 'Feature',
|
1697 | geometry: geomsCoord.geoms.length === 1 ? geomsCoord.geoms[0] : {
|
1698 | type: 'GeometryCollection',
|
1699 | geometries: geomsCoord.geoms
|
1700 | }
|
1701 |
|
1702 | };
|
1703 | if (this.attr(root, 'id')) feature.id = this.attr(root, 'id');
|
1704 | return [feature];
|
1705 | }
|
1706 | }, {
|
1707 | key: "processGMLFile",
|
1708 | value: function processGMLFile(fileName, form) {
|
1709 | var file = fileName.replace(/^.*[\\\/]/, '');
|
1710 | var self = this;
|
1711 | this.readTextFile(form.files[0]).then(function (text) {
|
1712 | var parser = new DOMParser();
|
1713 | var gj = self.fc();
|
1714 | var xmlDoc = parser.parseFromString(text, "text/xml");
|
1715 | var Polygon = self.get(xmlDoc, "gml:Polygon");
|
1716 | var featureMember = self.get(xmlDoc, "gml:featureMember");
|
1717 | for (var j = 0; j < featureMember.length; j++) {
|
1718 | gj.features = gj.features.concat(self.getFeatureMember(featureMember[j]));
|
1719 | }
|
1720 | var features = [];
|
1721 |
|
1722 | gj.features.forEach(function (f) {
|
1723 | var esrijson = arcgisToGeojsonUtils.geojsonToArcGIS(f);
|
1724 | features.push(esrijson);
|
1725 | });
|
1726 | self.addGeojsonToMap(features, file, "GML");
|
1727 | self.uploadPanel.current.toggle();
|
1728 | });
|
1729 | }
|
1730 | }, {
|
1731 | key: "getFeatureMember",
|
1732 | value: function getFeatureMember(root) {
|
1733 | var geometryProperty = this.get(root, "ogr:geometryProperty");
|
1734 | var geomsCoord = this.getGeometry(geometryProperty[0]);
|
1735 | var feature = {
|
1736 | type: 'Feature',
|
1737 | geometry: geomsCoord.geoms.length === 1 ? geomsCoord.geoms[0] : {
|
1738 | type: 'GeometryCollection',
|
1739 | geometries: geomsCoord.geoms
|
1740 | }
|
1741 |
|
1742 | };
|
1743 | if (this.attr(root, 'id')) feature.id = this.attr(root, 'id');
|
1744 | return [feature];
|
1745 | }
|
1746 | }, {
|
1747 | key: "getGeometry",
|
1748 | value: function getGeometry(root) {
|
1749 |
|
1750 | var geotypes = ['LineString', 'Polygon', 'Point', 'Track', 'gx:Track', 'gml:Polygon', 'trkpt'];
|
1751 | var geomNode,
|
1752 | geomNodes,
|
1753 | i,
|
1754 | j,
|
1755 | k,
|
1756 | geoms = [],
|
1757 | coordTimes = [];
|
1758 | if (this.get1(root, 'MultiGeometry')) {
|
1759 | return this.getGeometry(this.get1(root, 'MultiGeometry'));
|
1760 | }
|
1761 | if (this.get1(root, 'MultiTrack')) {
|
1762 | return this.getGeometry(this.get1(root, 'MultiTrack'));
|
1763 | }
|
1764 | if (this.get1(root, 'gx:MultiTrack')) {
|
1765 | return this.getGeometry(this.get1(root, 'gx:MultiTrack'));
|
1766 | }
|
1767 | if (this.get1(root, 'trkpt')) {
|
1768 | geomNodes = this.get(root, 'trkpt');
|
1769 | coords = [];
|
1770 | for (k = 0; k < geomNodes.length; k++) {
|
1771 | coords.push([parseFloat(geomNodes[k].attributes[1].nodeValue), parseFloat(geomNodes[k].attributes[0].nodeValue)]);
|
1772 | }
|
1773 | geoms.push({
|
1774 | type: 'Polygon',
|
1775 | coordinates: [coords]
|
1776 | });
|
1777 | }
|
1778 | for (i = 0; i < geotypes.length; i++) {
|
1779 | geomNodes = this.get(root, geotypes[i]);
|
1780 | if (geomNodes) {
|
1781 | for (j = 0; j < geomNodes.length; j++) {
|
1782 | geomNode = geomNodes[j];
|
1783 | if (geotypes[i] === 'Point') {
|
1784 | geoms.push({
|
1785 | type: 'Point',
|
1786 | coordinates: this.coord1(this.nodeVal(this.get1(geomNode, 'coordinates')))
|
1787 | });
|
1788 | } else if (geotypes[i] === 'LineString') {
|
1789 | geoms.push({
|
1790 | type: 'LineString',
|
1791 | coordinates: this.coord(this.nodeVal(this.get1(geomNode, 'coordinates')))
|
1792 | });
|
1793 | } else if (geotypes[i] === 'Polygon') {
|
1794 | var rings = this.get(geomNode, 'LinearRing'),
|
1795 | coords = [];
|
1796 | for (k = 0; k < rings.length; k++) {
|
1797 |
|
1798 | coords.push(this.coord(this.nodeVal(this.get1(rings[k], 'coordinates'))));
|
1799 | }
|
1800 | geoms.push({
|
1801 | type: 'Polygon',
|
1802 | coordinates: coords
|
1803 | });
|
1804 | } else if (geotypes[i] === 'gml:Polygon') {
|
1805 | var rings = this.get(geomNode, 'gml:LinearRing'),
|
1806 | coords = [];
|
1807 | for (k = 0; k < rings.length; k++) {
|
1808 |
|
1809 | coords.push(this.coord(this.nodeVal(this.get1(rings[k], 'gml:coordinates'))));
|
1810 | }
|
1811 | geoms.push({
|
1812 | type: 'Polygon',
|
1813 | coordinates: coords
|
1814 | });
|
1815 | } else if (geotypes[i] === 'Track' || geotypes[i] === 'gx:Track') {
|
1816 | var track = this.gxCoords(geomNode);
|
1817 | geoms.push({
|
1818 | type: 'LineString',
|
1819 | coordinates: track.coords
|
1820 | });
|
1821 | if (track.times.length) coordTimes.push(track.times);
|
1822 | }
|
1823 | }
|
1824 | }
|
1825 | }
|
1826 |
|
1827 | return {
|
1828 | geoms: geoms,
|
1829 | coordTimes: coordTimes
|
1830 | };
|
1831 | }
|
1832 | }, {
|
1833 | key: "nodeVal",
|
1834 | value: function nodeVal(x) {
|
1835 | if (x) {
|
1836 | this.norm(x);
|
1837 | }
|
1838 | return x && x.textContent || '';
|
1839 | }
|
1840 | }, {
|
1841 | key: "fc",
|
1842 | value: function fc() {
|
1843 | return {
|
1844 | type: 'FeatureCollection',
|
1845 | features: []
|
1846 | };
|
1847 | }
|
1848 | }, {
|
1849 | key: "xml2str",
|
1850 | value: function xml2str(str) {
|
1851 | var serializer;
|
1852 | if (typeof XMLSerializer !== 'undefined') {
|
1853 |
|
1854 | serializer = new XMLSerializer();
|
1855 | }
|
1856 | if (str.xml !== undefined) return str.xml;
|
1857 | return serializer.serializeToString(str);
|
1858 | }
|
1859 | }, {
|
1860 | key: "okhash",
|
1861 | value: function okhash(x) {
|
1862 | if (!x || !x.length) return 0;
|
1863 | for (var i = 0, h = 0; i < x.length; i++) {
|
1864 | h = (h << 5) - h + x.charCodeAt(i) | 0;
|
1865 | }return h;
|
1866 | }
|
1867 | }, {
|
1868 | key: "get",
|
1869 | value: function get$$1(x, y) {
|
1870 | return x.getElementsByTagName(y);
|
1871 | }
|
1872 | }, {
|
1873 | key: "attr",
|
1874 | value: function attr(x, y) {
|
1875 | return x.getAttribute(y);
|
1876 | }
|
1877 | }, {
|
1878 | key: "attrf",
|
1879 | value: function attrf(x, y) {
|
1880 | return parseFloat(this.attr(x, y));
|
1881 | }
|
1882 | }, {
|
1883 | key: "get1",
|
1884 | value: function get1(x, y) {
|
1885 | var n = this.get(x, y);
|
1886 | return n.length ? n[0] : null;
|
1887 | }
|
1888 | }, {
|
1889 | key: "norm",
|
1890 | value: function norm(el) {
|
1891 | if (el.normalize) {
|
1892 | el.normalize();
|
1893 | }return el;
|
1894 | }
|
1895 | }, {
|
1896 | key: "coord1",
|
1897 | value: function coord1(v) {
|
1898 | var removeSpace = /\s*/g;
|
1899 | return this.numarray(v.replace(removeSpace, '').split(','));
|
1900 | }
|
1901 | }, {
|
1902 | key: "coord",
|
1903 | value: function coord(v) {
|
1904 | var trimSpace = /^\s*|\s*$/g;
|
1905 | var splitSpace = /\s+/;
|
1906 | var coords = v.replace(trimSpace, '').split(splitSpace),
|
1907 | o = [];
|
1908 |
|
1909 | for (var i = 0; i < coords.length; i++) {
|
1910 | o.push(this.coord1(coords[i]));
|
1911 | }
|
1912 |
|
1913 | return o;
|
1914 | }
|
1915 | }, {
|
1916 | key: "gxCoord",
|
1917 | value: function gxCoord(v) {
|
1918 | return this.numarray(v.split(' '));
|
1919 | }
|
1920 | }, {
|
1921 | key: "numarray",
|
1922 | value: function numarray(x) {
|
1923 |
|
1924 | for (var j = 0, o = []; j < x.length; j++) {
|
1925 | o[j] = parseFloat(x[j]);
|
1926 | }
|
1927 | return o;
|
1928 | }
|
1929 | }, {
|
1930 | key: "gxCoords",
|
1931 | value: function gxCoords(root) {
|
1932 | var elems = this.get(root, 'coord', 'gx'),
|
1933 | coords = [],
|
1934 | times = [];
|
1935 | if (elems.length === 0) elems = this.get(root, 'gx:coord');
|
1936 | for (var i = 0; i < elems.length; i++) {
|
1937 | coords.push(this.gxCoord(this.nodeVal(elems[i])));
|
1938 | }var timeElems = this.get(root, 'when');
|
1939 | for (var j = 0; j < timeElems.length; j++) {
|
1940 | times.push(this.nodeVal(timeElems[j]));
|
1941 | }return {
|
1942 | coords: coords,
|
1943 | times: times
|
1944 | };
|
1945 | }
|
1946 | }, {
|
1947 | key: "processKMLFile",
|
1948 | value: function processKMLFile(fileName, form) {
|
1949 | var file = fileName.replace(/^.*[\\\/]/, '');
|
1950 | var self = this;
|
1951 |
|
1952 | this.readTextFile(form.files[0]).then(function (text) {
|
1953 | var parser = new DOMParser();
|
1954 | var gj = self.fc();
|
1955 | var xmlDoc = parser.parseFromString(text, "text/xml");
|
1956 | var placemarks = self.get(xmlDoc, "Placemark");
|
1957 | var styles = self.get(xmlDoc, "Style");
|
1958 | var styleMaps = self.get(xmlDoc, "StyleMap");
|
1959 | var styleIndex = {};
|
1960 | var styleByHash = {};
|
1961 | var styleMapIndex = {};
|
1962 | for (var k = 0; k < styles.length; k++) {
|
1963 | var hash = self.okhash(self.xml2str(styles[k])).toString(16);
|
1964 | styleIndex['#' + self.attr(styles[k], 'id')] = hash;
|
1965 | styleByHash[hash] = styles[k];
|
1966 | }
|
1967 | for (var l = 0; l < styleMaps.length; l++) {
|
1968 | styleIndex['#' + self.attr(styleMaps[l], 'id')] = self.okhash(self.xml2str(styleMaps[l])).toString(16);
|
1969 | var pairs = self.get(styleMaps[l], 'Pair');
|
1970 | var pairsMap = {};
|
1971 | for (var m = 0; m < pairs.length; m++) {
|
1972 | pairsMap[self.nodeVal(self.get1(pairs[m], 'key'))] = self.nodeVal(self.get1(pairs[m], 'styleUrl'));
|
1973 | }
|
1974 | styleMapIndex['#' + self.attr(styleMaps[l], 'id')] = pairsMap;
|
1975 | }
|
1976 | for (var j = 0; j < placemarks.length; j++) {
|
1977 | gj.features = gj.features.concat(self.getPlacemark(placemarks[j]));
|
1978 | }
|
1979 |
|
1980 | var features = [];
|
1981 |
|
1982 | gj.features.forEach(function (f) {
|
1983 | var esrijson = arcgisToGeojsonUtils.geojsonToArcGIS(f);
|
1984 |
|
1985 | features.push(esrijson);
|
1986 | });
|
1987 | self.addGeojsonToMap(features, file, "KML");
|
1988 | self.uploadPanel.current.toggle();
|
1989 | });
|
1990 | }
|
1991 | }, {
|
1992 | key: "getPlacemark",
|
1993 | value: function getPlacemark(root) {
|
1994 | var geomsAndTimes = this.getGeometry(root),
|
1995 | i,
|
1996 | properties = {},
|
1997 | name = this.nodeVal(this.get1(root, 'name')),
|
1998 | address = this.nodeVal(this.get1(root, 'address')),
|
1999 | styleUrl = this.nodeVal(this.get1(root, 'styleUrl')),
|
2000 | styleIndex = {},
|
2001 | styleMapIndex = {},
|
2002 | styleByHash = {},
|
2003 | description = this.nodeVal(this.get1(root, 'description')),
|
2004 | timeSpan = this.get1(root, 'TimeSpan'),
|
2005 | timeStamp = this.get1(root, 'TimeStamp'),
|
2006 | extendedData = this.get1(root, 'ExtendedData'),
|
2007 | lineStyle = this.get1(root, 'LineStyle'),
|
2008 | polyStyle = this.get1(root, 'PolyStyle'),
|
2009 | visibility = this.get1(root, 'visibility');
|
2010 |
|
2011 | if (!geomsAndTimes.geoms.length) return [];
|
2012 | if (name) properties.name = name;
|
2013 | if (address) properties.address = address;
|
2014 |
|
2015 | if (styleUrl) {
|
2016 | if (styleUrl[0] !== '#') {
|
2017 | styleUrl = '#' + styleUrl;
|
2018 | }
|
2019 | properties.styleUrl = styleUrl;
|
2020 | if (styleIndex[styleUrl]) {
|
2021 | properties.styleHash = styleIndex[styleUrl];
|
2022 | }
|
2023 | if (styleMapIndex[styleUrl]) {
|
2024 | properties.styleMapHash = styleMapIndex[styleUrl];
|
2025 | properties.styleHash = styleIndex[styleMapIndex[styleUrl].normal];
|
2026 | }
|
2027 | var style = styleByHash[properties.styleHash];
|
2028 | if (style) {
|
2029 | if (!lineStyle) lineStyle = this.get1(style, 'LineStyle');
|
2030 | if (!polyStyle) polyStyle = this.get1(style, 'PolyStyle');
|
2031 | var iconStyle = this.get1(style, 'IconStyle');
|
2032 | if (iconStyle) {
|
2033 | var icon = this.get1(iconStyle, 'Icon');
|
2034 | if (icon) {
|
2035 | var href = this.nodeVal(this.get1(icon, 'href'));
|
2036 | if (href) properties.icon = href;
|
2037 | }
|
2038 | }
|
2039 | }
|
2040 | if (description) properties.description = description;
|
2041 | if (timeSpan) {
|
2042 | var begin = this.nodeVal(this.get1(timeSpan, 'begin'));
|
2043 | var end = this.nodeVal(this.get1(timeSpan, 'end'));
|
2044 | properties.timespan = { begin: begin, end: end };
|
2045 | }
|
2046 | if (timeStamp) {
|
2047 | properties.timestamp = this.nodeVal(this.get1(timeStamp, 'when'));
|
2048 | }
|
2049 | if (lineStyle) {
|
2050 | var linestyles = this.kmlColor(this.nodeVal(this.get1(lineStyle, 'color'))),
|
2051 | color = linestyles[0],
|
2052 | opacity = linestyles[1],
|
2053 | width = parseFloat(this.nodeVal(this.get1(lineStyle, 'width')));
|
2054 | if (color) properties.stroke = color;
|
2055 | if (!isNaN(opacity)) properties['stroke-opacity'] = opacity;
|
2056 | if (!isNaN(width)) properties['stroke-width'] = width;
|
2057 | }
|
2058 | if (polyStyle) {
|
2059 | var polystyles = this.kmlColor(this.nodeVal(this.get1(polyStyle, 'color'))),
|
2060 | pcolor = polystyles[0],
|
2061 | popacity = polystyles[1],
|
2062 | fill = this.nodeVal(this.get1(polyStyle, 'fill')),
|
2063 | outline = this.nodeVal(this.get1(polyStyle, 'outline'));
|
2064 | if (pcolor) properties.fill = pcolor;
|
2065 | if (!isNaN(popacity)) properties['fill-opacity'] = popacity;
|
2066 | if (fill) properties['fill-opacity'] = fill === '1' ? properties['fill-opacity'] || 1 : 0;
|
2067 | if (outline) properties['stroke-opacity'] = outline === '1' ? properties['stroke-opacity'] || 1 : 0;
|
2068 | }
|
2069 | if (extendedData) {
|
2070 | var datas = this.get(extendedData, 'Data'),
|
2071 | simpleDatas = this.get(extendedData, 'SimpleData');
|
2072 |
|
2073 | for (i = 0; i < datas.length; i++) {
|
2074 | properties[datas[i].getAttribute('name')] = this.nodeVal(this.get1(datas[i], 'value'));
|
2075 | }
|
2076 | for (i = 0; i < simpleDatas.length; i++) {
|
2077 | properties[simpleDatas[i].getAttribute('name')] = this.nodeVal(simpleDatas[i]);
|
2078 | }
|
2079 | }
|
2080 |
|
2081 | if (visibility) {
|
2082 | properties.visibility = this.nodeVal(visibility);
|
2083 | }
|
2084 |
|
2085 | if (geomsAndTimes.coordTimes.length) {
|
2086 | properties.coordTimes = geomsAndTimes.coordTimes.length === 1 ? geomsAndTimes.coordTimes[0] : geomsAndTimes.coordTimes;
|
2087 | }
|
2088 |
|
2089 | var feature = {
|
2090 | type: 'Feature',
|
2091 | geometry: geomsAndTimes.geoms.length === 1 ? geomsAndTimes.geoms[0] : {
|
2092 | type: 'GeometryCollection',
|
2093 | geometries: geomsAndTimes.geoms
|
2094 | },
|
2095 | properties: properties
|
2096 | };
|
2097 | if (this.attr(root, 'id')) feature.id = this.attr(root, 'id');
|
2098 | return [feature];
|
2099 | } else {
|
2100 |
|
2101 | var feature = {
|
2102 | type: 'Feature',
|
2103 | geometry: geomsAndTimes.geoms.length === 1 ? geomsAndTimes.geoms[0] : {
|
2104 | type: 'GeometryCollection',
|
2105 | geometries: geomsAndTimes.geoms
|
2106 | },
|
2107 | properties: properties
|
2108 | };
|
2109 | if (this.attr(root, 'id')) feature.id = this.attr(root, 'id');
|
2110 | return [feature];
|
2111 | }
|
2112 | }
|
2113 | }, {
|
2114 | key: "processGeojsonFile",
|
2115 | value: function processGeojsonFile(fileName, form) {
|
2116 |
|
2117 | var file = fileName.replace(/^.*[\\\/]/, '');
|
2118 | var self = this;
|
2119 |
|
2120 | this.readTextFile(form.files[0]).then(function (text) {
|
2121 |
|
2122 | var geojson = JSON.parse(text);
|
2123 | var features = [];
|
2124 |
|
2125 | geojson.features.forEach(function (f) {
|
2126 | var esrijson = arcgisToGeojsonUtils.geojsonToArcGIS(f);
|
2127 |
|
2128 | features.push(esrijson);
|
2129 | });
|
2130 |
|
2131 | self.addGeojsonToMap(features, file, "GEOJSON");
|
2132 | self.uploadPanel.current.toggle();
|
2133 | });
|
2134 | }
|
2135 | }, {
|
2136 | key: "processShapeFile",
|
2137 | value: function processShapeFile(fileName, form) {
|
2138 |
|
2139 | var self = this;
|
2140 | self.uploadPanel.current.toggle();
|
2141 | var name = fileName.split(".");
|
2142 | name = name[0].replace("c:\\fakepath\\", "");
|
2143 |
|
2144 | var parms = {
|
2145 | name: name,
|
2146 | targetSR: self.state.view.extent.spatialReference,
|
2147 | maxRecordCount: 1000,
|
2148 | enforceInputFileSizeLimit: true,
|
2149 | enforceOutputJsonSizeLimit: true
|
2150 | };
|
2151 |
|
2152 | parms.generalize = true;
|
2153 | parms.maxAllowableOffset = 10;
|
2154 | parms.reducePrecision = true;
|
2155 | parms.numberOfDigitsAfterDecimal = 0;
|
2156 | var myContent = {
|
2157 | filetype: "shapefile",
|
2158 | publishParameters: JSON.stringify(parms),
|
2159 | f: "json",
|
2160 | 'content-type': 'multipart/form-data'
|
2161 | };
|
2162 |
|
2163 | var portalUrl = "https://www.arcgis.com";
|
2164 |
|
2165 | var query = Object.keys(myContent).map(function (k) {
|
2166 | return escape(k) + '=' + escape(myContent[k]);
|
2167 | }).join('&');
|
2168 |
|
2169 | reactArcgis.loadModules(['esri/request']).then(function (_ref3) {
|
2170 | var _ref4 = slicedToArray(_ref3, 1),
|
2171 | request = _ref4[0];
|
2172 |
|
2173 | request(portalUrl + "/sharing/rest/content/features/generate", {
|
2174 | query: myContent,
|
2175 | body: new FormData(form.form),
|
2176 |
|
2177 | responseType: "json"
|
2178 | }).then(function (response) {
|
2179 | var layerName = response.data.featureCollection.layers[0].layerDefinition.name;
|
2180 | self.addShapefileToMap(response.data.featureCollection, layerName);
|
2181 | });
|
2182 | });
|
2183 | }
|
2184 | }, {
|
2185 | key: "addShapefileToMap",
|
2186 | value: function addShapefileToMap(featureCollection, layerName) {
|
2187 | var self = this;
|
2188 | reactArcgis.loadModules(['esri/Graphic', 'esri/layers/FeatureLayer', 'esri/layers/support/Field', 'esri/PopupTemplate']).then(function (_ref5) {
|
2189 | var _ref6 = slicedToArray(_ref5, 4),
|
2190 | Graphic = _ref6[0],
|
2191 | FeatureLayer = _ref6[1],
|
2192 | Field = _ref6[2],
|
2193 | PopupTemplate = _ref6[3];
|
2194 |
|
2195 | var sourceGraphics = [];
|
2196 | var layers = featureCollection.layers.map(function (layer) {
|
2197 |
|
2198 | var graphics = layer.featureSet.features.map(function (feature) {
|
2199 | var gfx = Graphic.fromJSON(feature);
|
2200 | gfx.symbol = {
|
2201 | type: "simple-fill",
|
2202 | color: "rgba(224, 206, 69, 0.8)",
|
2203 | style: "solid",
|
2204 | outline: {
|
2205 | color: "yellow",
|
2206 | width: 3
|
2207 | }
|
2208 | };
|
2209 | return gfx;
|
2210 | });
|
2211 | sourceGraphics = sourceGraphics.concat(graphics);
|
2212 | var featureLayer = new FeatureLayer({
|
2213 | title: "SHP File: " + layerName,
|
2214 |
|
2215 | source: graphics,
|
2216 | fields: layer.layerDefinition.fields.map(function (field) {
|
2217 | return Field.fromJSON(field);
|
2218 | })
|
2219 | });
|
2220 | return featureLayer;
|
2221 | });
|
2222 |
|
2223 | layers[0].title = layerName;
|
2224 |
|
2225 | self.state.map.addMany(layers);
|
2226 |
|
2227 | self.state.view.goTo(sourceGraphics);
|
2228 |
|
2229 | var props = {
|
2230 | title: "Shape File: " + layerName,
|
2231 | transparency: ".32",
|
2232 | identmaxzoom: "13",
|
2233 | blockidentselect: true,
|
2234 | type: "geojson",
|
2235 | src: "",
|
2236 | map: self.state.map,
|
2237 | view: self.state.view
|
2238 | };
|
2239 |
|
2240 | var aml = new ArcticMapLayer(props);
|
2241 | aml.layerRef = layers[0];
|
2242 | aml.context = window._map.layers[0].context;
|
2243 | aml.layerRef.title = props.title;
|
2244 |
|
2245 | self.state.map.amlayers.push(aml);
|
2246 | });
|
2247 | }
|
2248 | }, {
|
2249 | key: "addGeojsonToMap",
|
2250 | value: function addGeojsonToMap(featureCollection, layerName, filetype) {
|
2251 | var self = this;
|
2252 | reactArcgis.loadModules(['esri/Graphic', 'esri/layers/FeatureLayer', 'esri/layers/support/Field', 'esri/PopupTemplate', "esri/renderers/SimpleRenderer"]).then(function (_ref7) {
|
2253 | var _ref8 = slicedToArray(_ref7, 5),
|
2254 | Graphic = _ref8[0],
|
2255 | FeatureLayer = _ref8[1],
|
2256 | Field = _ref8[2],
|
2257 | PopupTemplate = _ref8[3],
|
2258 | SimpleRenderer = _ref8[4];
|
2259 | var symbol = {
|
2260 | type: "simple-fill",
|
2261 | color: "rgba(224, 206, 69, 0.8)",
|
2262 | style: "solid",
|
2263 | outline: {
|
2264 | color: "red",
|
2265 | width: 2
|
2266 | }
|
2267 | };
|
2268 |
|
2269 | var i = 0;
|
2270 | var graphics = featureCollection.map(function (feature) {
|
2271 |
|
2272 | feature.attributes["OBJECTID"] = i++;
|
2273 | var gfx = Graphic.fromJSON(feature);
|
2274 |
|
2275 | gfx.symbol = symbol;
|
2276 | return gfx;
|
2277 | });
|
2278 |
|
2279 | var featureLayer = new FeatureLayer({
|
2280 | title: filetype + " File: " + layerName,
|
2281 | objectIdField: "OBJECTID",
|
2282 |
|
2283 | source: graphics
|
2284 |
|
2285 |
|
2286 |
|
2287 |
|
2288 | });
|
2289 |
|
2290 | self.state.map.add(featureLayer);
|
2291 | self.state.view.goTo(graphics);
|
2292 |
|
2293 | var props = {
|
2294 | title: filetype + " File: " + layerName,
|
2295 | transparency: ".32",
|
2296 | identmaxzoom: "13",
|
2297 | blockidentselect: true,
|
2298 | type: "geojson",
|
2299 | src: "",
|
2300 | map: self.state.map,
|
2301 | view: self.state.view
|
2302 | };
|
2303 |
|
2304 | var aml = new ArcticMapLayer(props);
|
2305 | aml.layerRef = featureLayer;
|
2306 | aml.context = window._map.layers[0].context;
|
2307 | aml.layerRef.title = props.title;
|
2308 |
|
2309 | self.state.map.amlayers.push(aml);
|
2310 | });
|
2311 | }
|
2312 | }, {
|
2313 | key: "reset",
|
2314 | value: function reset() {
|
2315 | this.state.sketchViewModel.cancel();
|
2316 | this.state.tempGraphicsLayer.removeAll();
|
2317 | this.setState({ hideEditors: false, geojson: null });
|
2318 | }
|
2319 | }, {
|
2320 | key: "setmaptoselect",
|
2321 | value: function setmaptoselect() {
|
2322 |
|
2323 | if (this.props.am.state.mode === "select") {
|
2324 | this.props.am.setMode("view");
|
2325 | this.setState({ mode: "view" });
|
2326 | } else {
|
2327 |
|
2328 | this.props.am.setMode("select");
|
2329 | this.setState({ mode: "select" });
|
2330 | }
|
2331 | }
|
2332 | }, {
|
2333 | key: "widgetRender",
|
2334 | value: function widgetRender() {
|
2335 |
|
2336 | var self = this;
|
2337 | var children = React.Children.map(this.props.children, function (child) {
|
2338 |
|
2339 | return React.cloneElement(child, {
|
2340 |
|
2341 | map: self.state.map,
|
2342 | view: self.state.view,
|
2343 |
|
2344 | hidden: self.state.hideEditors
|
2345 | });
|
2346 | });
|
2347 |
|
2348 | if (this.state.hidden === true) {
|
2349 | return React.createElement("div", { id: "topbar" });
|
2350 | }
|
2351 |
|
2352 | return React.createElement(
|
2353 | "div",
|
2354 | { id: "topbar" },
|
2355 | this.state.hideEditors === false && React.createElement(
|
2356 | "span",
|
2357 | null,
|
2358 | React.createElement(ArcticMapButton, { showactive: this.props.am.state.mode === "select", esriicon: "cursor", title: "Click to select/ Rightclick to remove", onclick: this.setmaptoselect.bind(this) }),
|
2359 | this.props.point && React.createElement(ArcticMapButton, { esriicon: "blank-map-pin", onclick: this.addPointClick.bind(this), title: "Draw point" }),
|
2360 | this.props.line && React.createElement(ArcticMapButton, { esriicon: "polyline", onclick: this.addLineClick.bind(this), title: "Draw polyline" }),
|
2361 | this.props.polygon && React.createElement(ArcticMapButton, { esriicon: "polygon", onclick: this.addPolyClick.bind(this), title: "Draw polygon" }),
|
2362 | this.props.square && React.createElement(ArcticMapButton, { esriicon: "checkbox-unchecked", onclick: this.addRecClick.bind(this), title: "Draw rectangle" }),
|
2363 | this.props.circle && React.createElement(ArcticMapButton, { esriicon: "radio-unchecked", onclick: this.addCircleClick.bind(this), title: "Draw circle" })
|
2364 | ),
|
2365 | children,
|
2366 | this.props.upload && React.createElement(
|
2367 | ArcticMapPanel,
|
2368 | { hidden: this.state.hideEditors, esriicon: "upload", title: "Upload Polygon", ref: this.uploadPanel },
|
2369 | React.createElement("br", null),
|
2370 | React.createElement(
|
2371 | "p",
|
2372 | { className: style$2.infoarea },
|
2373 | "Do you already have a shope of your plot? Upload your file here. Supported file types: Shapefiles (.zip), kml, glm, gpx, and geojson"
|
2374 | ),
|
2375 | React.createElement(
|
2376 | "form",
|
2377 | { encType: "multipart/form-data", method: "post", id: "uploadForm" },
|
2378 | React.createElement(
|
2379 | "div",
|
2380 | { className: "field" },
|
2381 | React.createElement(
|
2382 | "p",
|
2383 | null,
|
2384 | React.createElement(
|
2385 | "strong",
|
2386 | null,
|
2387 | "Select File"
|
2388 | )
|
2389 | ),
|
2390 | React.createElement(
|
2391 | "label",
|
2392 | { className: style$2.btm_primary_file },
|
2393 | React.createElement("input", { type: "file", name: "file", id: "inFile", onChange: this.fileUploaded.bind(this) }),
|
2394 | "Upload Image"
|
2395 | )
|
2396 | )
|
2397 | ),
|
2398 | React.createElement("br", null),
|
2399 | React.createElement("span", { id: "upload-status" })
|
2400 | ),
|
2401 | React.createElement(ArcticMapButton, { esriicon: "refresh", onclick: this.reset.bind(this), title: "Clear graphics" })
|
2402 | );
|
2403 | }
|
2404 | }, {
|
2405 | key: "componentDidUpdate",
|
2406 | value: function componentDidUpdate() {
|
2407 | if (this.top_right_node) {
|
2408 | ReactDOM.render(this.widgetRender(), this.top_right_node);
|
2409 | }
|
2410 | }
|
2411 | }, {
|
2412 | key: "render",
|
2413 | value: function render() {
|
2414 |
|
2415 |
|
2416 |
|
2417 |
|
2418 | return React.createElement(
|
2419 | "span",
|
2420 | null,
|
2421 | this.state.fileLayer
|
2422 | );
|
2423 | }
|
2424 | }, {
|
2425 | key: "addGraphic",
|
2426 | value: function addGraphic(event) {
|
2427 |
|
2428 |
|
2429 |
|
2430 |
|
2431 |
|
2432 |
|
2433 |
|
2434 | }
|
2435 | }, {
|
2436 | key: "updateGraphic",
|
2437 | value: function updateGraphic(event) {
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 |
|
2443 |
|
2444 |
|
2445 | }
|
2446 | }, {
|
2447 | key: "setUpClickHandler",
|
2448 | value: function setUpClickHandler() {
|
2449 | var self = this;
|
2450 | self.state.view.on("click", function (event) {
|
2451 | event.stopPropagation();
|
2452 |
|
2453 | self.state.view.hitTest(event).then(function (response) {
|
2454 | var results = response.results;
|
2455 |
|
2456 | if (results.length && results[results.length - 1].graphic && self.map.mode != 'identify') {
|
2457 |
|
2458 |
|
2459 |
|
2460 | self.state.editGraphic = results[results.length - 1].graphic;
|
2461 |
|
2462 |
|
2463 |
|
2464 |
|
2465 |
|
2466 | self.state.tempGraphicsLayer.graphics = [self.state.editGraphic];
|
2467 |
|
2468 |
|
2469 | self.state.sketchViewModel.update([self.state.editGraphic]);
|
2470 |
|
2471 |
|
2472 |
|
2473 |
|
2474 | }
|
2475 | });
|
2476 | });
|
2477 | }
|
2478 | }, {
|
2479 | key: "setActiveButton",
|
2480 | value: function setActiveButton(selectedButton) {
|
2481 |
|
2482 |
|
2483 |
|
2484 |
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 | }
|
2491 | }]);
|
2492 | return ArcticMapEdit;
|
2493 | }(React.Component);
|
2494 |
|
2495 | ArcticMapEdit.displayName = 'ArcticMapEdit';
|
2496 |
|
2497 | var css$2 = ".ArcticMapLLDSearch_lldsearchbar__10QoB {\n background: #fff;\n\n vertical-align: top; \n }\n\n\n .ArcticMapLLDSearch_lldsearchbar__10QoB div{\n display: inline;\n }";
|
2498 | var style$3 = { "lldsearchbar": "ArcticMapLLDSearch_lldsearchbar__10QoB" };
|
2499 | styleInject(css$2);
|
2500 |
|
2501 |
|
2502 |
|
2503 | var ArcticMapLLDSearch = function (_React$Component) {
|
2504 | inherits(ArcticMapLLDSearch, _React$Component);
|
2505 |
|
2506 | function ArcticMapLLDSearch(props) {
|
2507 | classCallCheck(this, ArcticMapLLDSearch);
|
2508 |
|
2509 | var _this = possibleConstructorReturn(this, (ArcticMapLLDSearch.__proto__ || Object.getPrototypeOf(ArcticMapLLDSearch)).call(this, props));
|
2510 |
|
2511 | _this.state = {
|
2512 | map: props.map,
|
2513 | view: props.view,
|
2514 | graphic: null
|
2515 | };
|
2516 |
|
2517 | _this.handleChange = _this.handleChange.bind(_this);
|
2518 | return _this;
|
2519 | }
|
2520 |
|
2521 | createClass(ArcticMapLLDSearch, [{
|
2522 | key: "componentDidMount",
|
2523 | value: function componentDidMount() {
|
2524 | var self = this;
|
2525 | reactArcgis.loadModules(['esri/Graphic', "esri/geometry/geometryEngine", 'esri/geometry/Geometry', 'esri/geometry/Polygon', "esri/widgets/Search/SearchSource", 'esri/request']).then(function (_ref) {
|
2526 | var _ref2 = slicedToArray(_ref, 6),
|
2527 | Graphic = _ref2[0],
|
2528 | geometryEngine = _ref2[1],
|
2529 | Geometry = _ref2[2],
|
2530 | Polygon = _ref2[3],
|
2531 | SearchSource = _ref2[4],
|
2532 | esriRequest = _ref2[5];
|
2533 |
|
2534 |
|
2535 |
|
2536 | self.top_right_node = document.createElement("div");
|
2537 |
|
2538 | self.Graphic = Graphic;
|
2539 | self.Geometry = Geometry;
|
2540 | self.Polygon = Polygon;
|
2541 |
|
2542 | self.state.view.ui.add(self.top_right_node, {
|
2543 | position: "top-right",
|
2544 | index: 0
|
2545 | });
|
2546 |
|
2547 |
|
2548 |
|
2549 |
|
2550 |
|
2551 |
|
2552 |
|
2553 | var url = "https://gis.blm.gov/arcgis/rest/services/Cadastral/BLM_Natl_PLSS_CadNSDI/MapServer/exts/CadastralSpecialServices/FindLD";
|
2554 |
|
2555 | self.search = new SearchSource({
|
2556 | name: 'Legal Land Description',
|
2557 | placeholder: "example: NV 21 T38N R56E SEC 10 ALIQ SESW",
|
2558 |
|
2559 | getSuggestions: function getSuggestions(params) {
|
2560 |
|
2561 | var serarcParams = params.suggestTerm.replace(/\+/g, ' ');
|
2562 | var options = {
|
2563 | query: {
|
2564 | "legaldescription": serarcParams,
|
2565 | "returnalllevels": "true",
|
2566 | f: "pjson"
|
2567 | },
|
2568 | responseType: "json"
|
2569 | };
|
2570 | return esriRequest(url, options).then(function (results) {
|
2571 |
|
2572 | return results.data.features.map(function (feature) {
|
2573 | return {
|
2574 | key: "name",
|
2575 | text: feature.attributes.landdescription,
|
2576 | sourceIndex: params.sourceIndex
|
2577 | };
|
2578 | });
|
2579 | });
|
2580 | },
|
2581 |
|
2582 | getResults: function getResults(params) {
|
2583 | var serarchParams = params.suggestResult.text.replace(/\+/g, ' ');
|
2584 | var options = {
|
2585 | query: {
|
2586 | "legaldescription": serarchParams,
|
2587 | "returnalllevels": "true",
|
2588 | f: "pjson"
|
2589 | },
|
2590 | responseType: "json"
|
2591 | };
|
2592 |
|
2593 | return esriRequest(url, options).then(function (results) {
|
2594 |
|
2595 | var searchResults = results.data.features.map(function (feature) {
|
2596 |
|
2597 | var outfeature = Graphic.fromJSON(feature);
|
2598 |
|
2599 | var buffer = geometryEngine.geodesicBuffer(outfeature.geometry, 100, "feet");
|
2600 |
|
2601 | var searchResult = {
|
2602 | extent: buffer.extent,
|
2603 | feature: outfeature,
|
2604 | name: feature.attributes.landdescription
|
2605 | };
|
2606 | return searchResult;
|
2607 | });
|
2608 | return searchResults;
|
2609 | });
|
2610 | }
|
2611 | });
|
2612 | });
|
2613 | }
|
2614 | }, {
|
2615 | key: "searchLLD",
|
2616 | value: function searchLLD(event) {
|
2617 |
|
2618 | var self = this;
|
2619 |
|
2620 | fetch("https://gis.blm.gov/arcgis/rest/services/Cadastral/BLM_Natl_PLSS_CadNSDI/MapServer/exts/CadastralSpecialServices/FindLD?legaldescription=" + this.state.searchinput + "+&returnalllevels=&f=json").then(function (r) {
|
2621 | return r.json();
|
2622 | }).then(function (data) {
|
2623 |
|
2624 | var popupresults = data.features.map(function (feature) {
|
2625 |
|
2626 | feature.geometry = self.Polygon.fromJSON(feature.geometry);
|
2627 |
|
2628 | feature = new self.Graphic(feature);
|
2629 |
|
2630 | var displayValue = feature.attributes.landdescription;
|
2631 |
|
2632 | feature.popupTemplate = {
|
2633 | title: 'Legal Land Description',
|
2634 | content: "<b>LLD</b>: " + displayValue,
|
2635 | actions: [{ title: "Select", id: "select-action" }]
|
2636 | };
|
2637 |
|
2638 | return feature;
|
2639 | });
|
2640 |
|
2641 | if (popupresults.length > 0) {
|
2642 | self.state.view.popup.open({
|
2643 | features: popupresults,
|
2644 | location: event.mapPoint
|
2645 | });
|
2646 | }
|
2647 | });
|
2648 | }
|
2649 | }, {
|
2650 | key: "handleChange",
|
2651 | value: function handleChange(event) {
|
2652 | this.setState({ searchinput: event.target.value });
|
2653 | }
|
2654 | }, {
|
2655 | key: "widgetRender",
|
2656 | value: function widgetRender() {
|
2657 | return React.createElement(
|
2658 | "div",
|
2659 | { className: style$3.lldsearchbar },
|
2660 | React.createElement(
|
2661 | "div",
|
2662 | { style: { display: 'inline-block', height: '32px', marginTop: '0px' } },
|
2663 | React.createElement("input", { style: { display: 'inline-block', height: '32px', verticalAlign: 'top' }, value: this.state.searchinput, onChange: this.handleChange, type: "text", placeholder: "Find legal land description", "aria-label": "Search", className: "esri-input", title: "Find leagal land desription" }),
|
2664 | React.createElement(
|
2665 | "div",
|
2666 | { style: { display: 'inline-block', width: '32px', height: '32px', verticalAlign: 'top' }, role: "button", title: "Search", className: "esri-search__submit-button esri-widget--button", onClick: this.searchLLD.bind(this) },
|
2667 | React.createElement("span", { style: { display: 'block', paddingTop: '8px' }, "aria-hidden": "true", role: "presentation", className: "esri-icon-search" })
|
2668 | )
|
2669 | )
|
2670 | );
|
2671 | }
|
2672 | }, {
|
2673 | key: "render",
|
2674 | value: function render() {
|
2675 | return null;
|
2676 | }
|
2677 | }]);
|
2678 | return ArcticMapLLDSearch;
|
2679 | }(React.Component);
|
2680 |
|
2681 | ArcticMapLLDSearch.displayName = 'ArcticMapLLDSearch';
|
2682 |
|
2683 | var ArcticMapLayerPopup = function (_React$Component) {
|
2684 | inherits(ArcticMapLayerPopup, _React$Component);
|
2685 |
|
2686 | function ArcticMapLayerPopup(props) {
|
2687 | classCallCheck(this, ArcticMapLayerPopup);
|
2688 | return possibleConstructorReturn(this, (ArcticMapLayerPopup.__proto__ || Object.getPrototypeOf(ArcticMapLayerPopup)).call(this, props));
|
2689 | }
|
2690 |
|
2691 | createClass(ArcticMapLayerPopup, [{
|
2692 | key: 'render',
|
2693 | value: function render() {
|
2694 |
|
2695 | return React.createElement('span', null);
|
2696 | }
|
2697 | }, {
|
2698 | key: 'renderPopup',
|
2699 | value: function renderPopup(context) {
|
2700 | if (this.props.popup) {
|
2701 | return this.props.popup(context);
|
2702 | }
|
2703 | }
|
2704 | }]);
|
2705 | return ArcticMapLayerPopup;
|
2706 | }(React.Component);
|
2707 |
|
2708 | ArcticMapLayerPopup.displayName = 'ArcticMapLayerPopup';
|
2709 |
|
2710 | var ArcticMapControlArea = function (_React$Component) {
|
2711 | inherits(ArcticMapControlArea, _React$Component);
|
2712 |
|
2713 | function ArcticMapControlArea(props) {
|
2714 | classCallCheck(this, ArcticMapControlArea);
|
2715 |
|
2716 | var _this = possibleConstructorReturn(this, (ArcticMapControlArea.__proto__ || Object.getPrototypeOf(ArcticMapControlArea)).call(this, props));
|
2717 |
|
2718 | _this.controlNode = document.createElement("div");
|
2719 | _this.props.view.ui.add(_this.controlNode, _this.props.location);
|
2720 |
|
2721 | return _this;
|
2722 | }
|
2723 |
|
2724 | createClass(ArcticMapControlArea, [{
|
2725 | key: 'componentDidUpdate',
|
2726 | value: function componentDidUpdate() {
|
2727 |
|
2728 | if (this.controlNode) {
|
2729 | ReactDOM.render(this.widgetRender(), this.controlNode, function () {});
|
2730 | }
|
2731 | }
|
2732 | }, {
|
2733 | key: 'append',
|
2734 | value: function append(ele) {
|
2735 | this.props.children.push(ele);
|
2736 | }
|
2737 | }, {
|
2738 | key: 'widgetRender',
|
2739 | value: function widgetRender() {
|
2740 |
|
2741 | var self = this;
|
2742 |
|
2743 | var children = React.Children.map(this.props.children, function (child) {
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 | return React.cloneElement(child, {
|
2754 | am: self.props.am,
|
2755 | map: self.props.am.state.map,
|
2756 | view: self.props.am.state.view
|
2757 |
|
2758 |
|
2759 |
|
2760 | });
|
2761 | });
|
2762 |
|
2763 | return React.createElement(
|
2764 | 'span',
|
2765 | { className: 'arcticmap-area' },
|
2766 | children
|
2767 | );
|
2768 | }
|
2769 | }, {
|
2770 | key: 'render',
|
2771 | value: function render() {
|
2772 | return React.createElement('span', null);
|
2773 | }
|
2774 | }]);
|
2775 | return ArcticMapControlArea;
|
2776 | }(React.Component);
|
2777 |
|
2778 | ArcticMapControlArea.displayName = 'ArcticMapControlArea';
|
2779 |
|
2780 | var ArcticMapIdentify = function (_React$Component) {
|
2781 | inherits(ArcticMapIdentify, _React$Component);
|
2782 |
|
2783 | function ArcticMapIdentify(props) {
|
2784 | classCallCheck(this, ArcticMapIdentify);
|
2785 |
|
2786 | var _this = possibleConstructorReturn(this, (ArcticMapIdentify.__proto__ || Object.getPrototypeOf(ArcticMapIdentify)).call(this, props));
|
2787 |
|
2788 | _this.state = { mode: 1 };
|
2789 |
|
2790 | return _this;
|
2791 | }
|
2792 |
|
2793 | createClass(ArcticMapIdentify, [{
|
2794 | key: 'setmaptoidentify',
|
2795 | value: function setmaptoidentify() {
|
2796 | this.props.am.setMode("identify");
|
2797 | this.setState({ mode: "identify" });
|
2798 | }
|
2799 | }, {
|
2800 | key: 'render',
|
2801 | value: function render() {
|
2802 |
|
2803 |
|
2804 |
|
2805 | return React.createElement(
|
2806 | 'span',
|
2807 | null,
|
2808 | React.createElement(ArcticMapButton, { showactive: this.props.am.state.mode === "description", esriicon: 'question', title: 'Identify', onclick: this.setmaptoidentify.bind(this) })
|
2809 | );
|
2810 | }
|
2811 | }]);
|
2812 | return ArcticMapIdentify;
|
2813 | }(React.Component);
|
2814 |
|
2815 | ArcticMapIdentify.displayName = 'ArcticMapIdentify';
|
2816 |
|
2817 | var ArcticMapBaseControl = function (_React$Component) {
|
2818 | inherits(ArcticMapBaseControl, _React$Component);
|
2819 |
|
2820 | function ArcticMapBaseControl(props) {
|
2821 | classCallCheck(this, ArcticMapBaseControl);
|
2822 |
|
2823 | var _this = possibleConstructorReturn(this, (ArcticMapBaseControl.__proto__ || Object.getPrototypeOf(ArcticMapBaseControl)).call(this, props));
|
2824 |
|
2825 | _this.state = {
|
2826 | zoomControl: null,
|
2827 | renderElements: [],
|
2828 | canReset: _this.props.reset !== undefined
|
2829 |
|
2830 | };
|
2831 | var self = _this;
|
2832 | _this.zoomControlDiv = document.createElement("div");
|
2833 | _this.layersDiv = document.createElement("div");
|
2834 | _this.legendDiv = document.createElement("div");
|
2835 |
|
2836 | reactArcgis.loadModules(['esri/widgets/Zoom', 'esri/widgets/LayerList', 'esri/widgets/Legend', 'esri/widgets/BasemapGallery']).then(function (_ref) {
|
2837 | var _ref2 = slicedToArray(_ref, 4),
|
2838 | Zoom = _ref2[0],
|
2839 | LayerList = _ref2[1],
|
2840 | Legend = _ref2[2],
|
2841 | BasemapGallery = _ref2[3];
|
2842 |
|
2843 | self.props.view.on('click', function (event) {
|
2844 |
|
2845 | self.props.view.ui.remove(self.basemapGallery);
|
2846 | });
|
2847 |
|
2848 | self.basemapGallery = new BasemapGallery({
|
2849 | view: props.view
|
2850 | });
|
2851 | self.basemapGallery.watch('activeBasemap', function (newValue, oldValue, property, object) {
|
2852 | self.props.view.ui.remove(self.basemapGallery);
|
2853 | });
|
2854 |
|
2855 | var zoom = new Zoom({
|
2856 | view: props.view,
|
2857 | container: self.zoomControlDiv,
|
2858 | position: "top-left"
|
2859 | });
|
2860 | self.state.zoomControl = zoom;
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 | var legend = new Legend({
|
2867 | view: props.view,
|
2868 | container: self.legendDiv
|
2869 | });
|
2870 |
|
2871 | var layerList = new LayerList({
|
2872 | view: props.view,
|
2873 | container: self.layersDiv,
|
2874 | listItemCreatedFunction: function listItemCreatedFunction(event) {
|
2875 | var item = event.item;
|
2876 | item.panel = {
|
2877 | content: 'legend',
|
2878 | open: false
|
2879 | };
|
2880 | }
|
2881 | });
|
2882 |
|
2883 |
|
2884 | _this.setState({ renderElements: self.state.renderElements.concat(self.zoomControlDiv) });
|
2885 | });
|
2886 |
|
2887 | return _this;
|
2888 | }
|
2889 |
|
2890 | createClass(ArcticMapBaseControl, [{
|
2891 | key: 'handleShowBasemaps',
|
2892 | value: function handleShowBasemaps() {}
|
2893 | }, {
|
2894 | key: 'renderZoomcontrol',
|
2895 | value: function renderZoomcontrol() {
|
2896 |
|
2897 | return this.zoomControlDiv;
|
2898 | }
|
2899 | }, {
|
2900 | key: 'basemapclick',
|
2901 | value: function basemapclick() {
|
2902 | this.props.view.ui.add(this.basemapGallery, {
|
2903 | position: 'bottom-right'
|
2904 | });
|
2905 |
|
2906 |
|
2907 | }
|
2908 | }, {
|
2909 | key: 'render',
|
2910 | value: function render() {
|
2911 | var _this2 = this;
|
2912 |
|
2913 | return React.createElement(
|
2914 | 'div',
|
2915 | null,
|
2916 | React.createElement(
|
2917 | ArcticMapControlArea,
|
2918 | { am: this.props.am, view: this.props.view, location: 'top-left' },
|
2919 | React.createElement('div', { ref: function ref(e) {
|
2920 | e && e.appendChild(_this2.zoomControlDiv);
|
2921 | } })
|
2922 | ),
|
2923 | React.createElement(
|
2924 | ArcticMapControlArea,
|
2925 | { am: this.props.am, view: this.props.view, location: 'bottom-right', className: styles.ArcticMap },
|
2926 | React.createElement(
|
2927 | ArcticMapPanel,
|
2928 | { esriicon: 'layers', title: 'Data Filters' },
|
2929 | React.createElement(
|
2930 | 'p',
|
2931 | null,
|
2932 | 'Toggle visibility of each data layer.'
|
2933 | ),
|
2934 | this.state.canReset && React.createElement(
|
2935 | 'p',
|
2936 | null,
|
2937 | React.createElement(
|
2938 | 'a',
|
2939 | { href: '#', style: { color: '#71A3AF', textDecoration: 'none' }, onClick: this.props.reset },
|
2940 | React.createElement('span', { style: { height: "10px", width: "10px", marginRight: '10px', color: 'black' }, 'aria-hidden': true, className: 'esri-icon esri-icon-trash' }),
|
2941 | 'Reset to Default Data Visibility'
|
2942 | )
|
2943 | ),
|
2944 | React.createElement('div', { ref: function ref(e) {
|
2945 | e && e.appendChild(_this2.layersDiv);
|
2946 | } })
|
2947 | ),
|
2948 | React.createElement(
|
2949 | ArcticMapPanel,
|
2950 | { esriicon: 'layer-list', title: 'Legend' },
|
2951 | React.createElement('div', { ref: function ref(e) {
|
2952 | e && e.appendChild(_this2.legendDiv);
|
2953 | } })
|
2954 | ),
|
2955 | React.createElement(ArcticMapButton, { esriicon: 'basemap', title: 'Basemaps', onclick: this.basemapclick.bind(this) })
|
2956 | )
|
2957 | );
|
2958 | }
|
2959 | }]);
|
2960 | return ArcticMapBaseControl;
|
2961 | }(React.Component);
|
2962 |
|
2963 | ArcticMapBaseControl.displayName = "ArcticMapBaseControl";
|
2964 |
|
2965 | var ArcticMapLayerRenderer = function (_React$Component) {
|
2966 | inherits(ArcticMapLayerRenderer, _React$Component);
|
2967 |
|
2968 | function ArcticMapLayerRenderer(props) {
|
2969 | classCallCheck(this, ArcticMapLayerRenderer);
|
2970 |
|
2971 | var _this = possibleConstructorReturn(this, (ArcticMapLayerRenderer.__proto__ || Object.getPrototypeOf(ArcticMapLayerRenderer)).call(this, props));
|
2972 |
|
2973 | if (props.style === undefined) {
|
2974 | console.log("Missing style: Build Styles @ https://developers.arcgis.com/javascript/latest/sample-code/playground/live/index.html");
|
2975 | }
|
2976 |
|
2977 | return _this;
|
2978 | }
|
2979 |
|
2980 | createClass(ArcticMapLayerRenderer, [{
|
2981 | key: 'render',
|
2982 | value: function render() {
|
2983 | return React.createElement('span', null);
|
2984 | }
|
2985 | }]);
|
2986 | return ArcticMapLayerRenderer;
|
2987 | }(React.Component);
|
2988 |
|
2989 | ArcticMapLayerRenderer.displayName = 'ArcticMapLayerRenderer';
|
2990 |
|
2991 | var ArcticMapLocator = function (_React$Component) {
|
2992 | inherits(ArcticMapLocator, _React$Component);
|
2993 |
|
2994 | function ArcticMapLocator(props) {
|
2995 | classCallCheck(this, ArcticMapLocator);
|
2996 | return possibleConstructorReturn(this, (ArcticMapLocator.__proto__ || Object.getPrototypeOf(ArcticMapLocator)).call(this, props));
|
2997 | }
|
2998 |
|
2999 | createClass(ArcticMapLocator, [{
|
3000 | key: 'componentWillMount',
|
3001 | value: function componentWillMount() {}
|
3002 | }, {
|
3003 | key: 'componentDidMount',
|
3004 | value: function componentDidMount() {
|
3005 | var self = this;
|
3006 | reactArcgis.loadModules(['esri/widgets/Locate', 'esri/widgets/BasemapGallery', 'esri/widgets/Home', 'esri/widgets/Search', 'esri/layers/FeatureLayer', 'esri/tasks/Locator', 'esri/geometry/geometryEngine', "esri/request"]).then(function (_ref) {
|
3007 | var _ref2 = slicedToArray(_ref, 8),
|
3008 | Locate = _ref2[0],
|
3009 | BasemapGallery = _ref2[1],
|
3010 | Home = _ref2[2],
|
3011 | Search = _ref2[3],
|
3012 | FeatureLayer = _ref2[4],
|
3013 | Locator = _ref2[5],
|
3014 | geometryEngine = _ref2[6],
|
3015 | Request = _ref2[7];
|
3016 |
|
3017 | var searchsources = [];
|
3018 |
|
3019 | var devaultSource = {
|
3020 | locator: new Locator({ url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer" }),
|
3021 | singleLineFieldName: "SingleLine",
|
3022 | name: "Standard Geocoder",
|
3023 | placeholder: "Find address",
|
3024 | maxResults: 3,
|
3025 | maxSuggestions: 6,
|
3026 | suggestionsEnabled: true,
|
3027 | minSuggestCharacters: 0
|
3028 | };
|
3029 | searchsources.push(devaultSource);
|
3030 | var searchitems = self.props.am.childrenElements.filter(function (ele) {
|
3031 |
|
3032 | if (ele.search) {
|
3033 | return ele;
|
3034 | }
|
3035 |
|
3036 |
|
3037 |
|
3038 | });
|
3039 |
|
3040 | var lldsSarchsources = searchitems.map(function (i) {
|
3041 | if (i.search) {
|
3042 | return i.search;
|
3043 | }
|
3044 | });
|
3045 |
|
3046 | searchsources.push(lldsSarchsources[0]);
|
3047 |
|
3048 | if (self.props.searchSources) {
|
3049 | self.props.searchSources.map(function (searchSource) {
|
3050 |
|
3051 | var searchFeature = new FeatureLayer({
|
3052 | url: searchSource.scr + searchSource.layerid
|
3053 | });
|
3054 | searchSource.layer = searchFeature;
|
3055 |
|
3056 | searchsources.push(searchSource);
|
3057 | });
|
3058 | }
|
3059 |
|
3060 | var searchWidget2 = new Search({
|
3061 | view: self.props.view,
|
3062 | sources: searchsources,
|
3063 | includeDefaultSources: false
|
3064 | });
|
3065 |
|
3066 | self.props.view.ui.add(searchWidget2, {
|
3067 | position: "top-right",
|
3068 | index: 1
|
3069 | });
|
3070 |
|
3071 | searchWidget2.on('select-result', function (evt) {
|
3072 |
|
3073 | self.props.view.popup.currentSearchResultFeature = evt.result.feature;
|
3074 | self.props.view.popup.close();
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 | });
|
3083 | });
|
3084 | }
|
3085 | }, {
|
3086 | key: 'render',
|
3087 | value: function render() {
|
3088 | return null;
|
3089 | }
|
3090 | }]);
|
3091 | return ArcticMapLocator;
|
3092 | }(React.Component);
|
3093 |
|
3094 | ArcticMapLocator.displayName = "ArcticMapLocator";
|
3095 |
|
3096 | exports.ArcticMap = ArcticMap;
|
3097 | exports.ArcticMapEdit = ArcticMapEdit;
|
3098 | exports.ArcticMapLayer = ArcticMapLayer;
|
3099 | exports.ArcticMapLLDSearch = ArcticMapLLDSearch;
|
3100 | exports.ArcticMapLayerPopup = ArcticMapLayerPopup;
|
3101 | exports.ArcticMapControlArea = ArcticMapControlArea;
|
3102 | exports.ArcticMapButton = ArcticMapButton;
|
3103 | exports.ArcticMapPanel = ArcticMapPanel;
|
3104 | exports.ArcticMapIdentify = ArcticMapIdentify;
|
3105 | exports.ArcticMapBaseControl = ArcticMapBaseControl;
|
3106 | exports.ArcticMapLayerRenderer = ArcticMapLayerRenderer;
|
3107 | exports.ArcticMapLocator = ArcticMapLocator;
|
3108 |
|