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