@vtx/map 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,872 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
+
9
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
+
11
+ var _react = require('react');
12
+
13
+ var _react2 = _interopRequireDefault(_react);
14
+
15
+ require('./VtxSearchMap.css');
16
+
17
+ var _button = require('antd/lib/button');
18
+
19
+ var _button2 = _interopRequireDefault(_button);
20
+
21
+ require('antd/lib/button/style/css');
22
+
23
+ var _input = require('antd/lib/input');
24
+
25
+ var _input2 = _interopRequireDefault(_input);
26
+
27
+ require('antd/lib/input/style/css');
28
+
29
+ var _message = require('antd/lib/message');
30
+
31
+ var _message2 = _interopRequireDefault(_message);
32
+
33
+ require('antd/lib/message/style/css');
34
+
35
+ var _checkbox = require('antd/lib/checkbox');
36
+
37
+ var _checkbox2 = _interopRequireDefault(_checkbox);
38
+
39
+ require('antd/lib/checkbox/style/css');
40
+
41
+ var _VtxModal = require('../VtxModal');
42
+
43
+ var _VtxMap = require('../VtxMap');
44
+
45
+ var _default = require('../default');
46
+
47
+ var _default2 = _interopRequireDefault(_default);
48
+
49
+ var _mapping = require('./mapping');
50
+
51
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
52
+
53
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
54
+
55
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
56
+
57
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
58
+
59
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
60
+
61
+ var styles = {
62
+ searchModal: 'vtx-ui-searchmap-searchmodal',
63
+ searchMap: 'vtx-ui-searchmap-searchmap',
64
+ top: 'vtx-ui-searchmap-top',
65
+ bottom: 'vtx-ui-searchmap-bottom',
66
+ content: 'vtx-ui-searchmap-content',
67
+ show: 'vtx-ui-searchmap-show',
68
+ hidden: 'vtx-ui-searchmap-hidden',
69
+ w_l: 'vtx-ui-searchmap-w_l',
70
+ content_left: 'vtx-ui-searchmap-content_left',
71
+ listTitle: 'vtx-ui-searchmap-listtitle',
72
+ title: 'vtx-ui-searchmap-title',
73
+ btn: 'vtx-ui-searchmap-btn',
74
+ lists: 'vtx-ui-searchmap-lists',
75
+ select: 'vtx-ui-searchmap-select',
76
+ scrollauto: 'vtx-ui-searchmap-scrollauto',
77
+ content_right: 'vtx-ui-searchmap-content_right',
78
+ showLabel: 'vtx-ui-searchmap-showlabel',
79
+ hiddenLabel: 'vtx-ui-searchmap-hiddenlabel',
80
+ otherModal: 'vtx-ui-searchmap-othermodal'
81
+ };
82
+ // import Icon from 'antd/lib/icon';
83
+ // import 'antd/lib/icon/style/css';
84
+
85
+ //公共地址配置
86
+
87
+
88
+ // message.config({
89
+ // top: document.getElementById('root').offsetHeight/3,
90
+ // duration: 5,
91
+ // });
92
+ var warning = function warning() {
93
+ _message2.default.warning('位置点查询失败,请缩小比例尺或切换关键字后再重新查询!');
94
+ };
95
+ function distinct(ary) {
96
+ var pts = [].concat(_toConsumableArray(ary));
97
+ if (pts[0][0] == pts[pts.length - 1][0] && pts[0][1] == pts[pts.length - 1][1]) {
98
+ pts.pop();
99
+ return distinct(pts);
100
+ } else {
101
+ return pts;
102
+ }
103
+ }
104
+
105
+ var getIcon = function getIcon(type) {
106
+ return _default.antdMajorVersion === '4' ? _react2.default.createElement(_default.VtxMapIcon, { type: 'icon-' + _mapping.iconMapping[type] }) : type;
107
+ };
108
+
109
+ var VtxSearchMap = function (_React$Component) {
110
+ _inherits(VtxSearchMap, _React$Component);
111
+
112
+ function VtxSearchMap(props) {
113
+ _classCallCheck(this, VtxSearchMap);
114
+
115
+ var _this = _possibleConstructorReturn(this, (VtxSearchMap.__proto__ || Object.getPrototypeOf(VtxSearchMap)).call(this, props));
116
+
117
+ _this.map = null; //Map组件的ref对象
118
+ _this.mapLoaded = false;
119
+ _this.isDrawStatus = false;
120
+ _this.isClickMap = false;
121
+ _this.apid = []; //所有点id,除编辑点外
122
+ _this.loadExtent = null;
123
+ _this.mapId = 'searchMap' + new Date().getTime();
124
+ _this.state = {
125
+ //列表和地图宽度切换的动画需要
126
+ isShowList: false,
127
+ //可拖动用于定位的点
128
+ locationPoint: [],
129
+ //搜索框文字
130
+ searchValue: '',
131
+ //搜索出来的列表点位
132
+ listPoint: [],
133
+ //列表数据
134
+ listMess: [],
135
+ // 返回点位/图形
136
+ graphicType: props.graphicType || 'point',
137
+ isDraw: props.graphicType !== 'point',
138
+ parameter: props.drawParameter,
139
+ graphicValue: null,
140
+ drawGraphID: 'drawnGraph',
141
+ /*地图Api参数*/
142
+ mapCenter: props.mapCenter || '',
143
+ maxZoom: props.maxZoom,
144
+ minZoom: props.minZoom,
145
+ wkid: props.wkid,
146
+ mapType: props.mapType || 'bmap',
147
+ mapServer: props.mapServer,
148
+ setCenter: false,
149
+ mapVisiblePoints: {
150
+ fitView: [],
151
+ type: 'all'
152
+ },
153
+ setVisiblePoints: false,
154
+ isDoEdit: false,
155
+ isEndEdit: false,
156
+ editGraphicId: '',
157
+ editGraphic: null,
158
+ mapZoomLevel: props.mapZoomLevel || 11,
159
+ setZoomLevel: false,
160
+ /*modal参数*/
161
+ modal1Visible: props.modal1Visible || false,
162
+ isShowOther: props.isShowOther || false,
163
+ otherText: props.otherText || '显示服务区域',
164
+ isShowOtherGraph: props.isShowOther || false
165
+ };
166
+ return _this;
167
+ }
168
+ //经纬度回调
169
+
170
+
171
+ _createClass(VtxSearchMap, [{
172
+ key: 'callback',
173
+ value: function callback() {
174
+ var fun = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'callback';
175
+
176
+ if (fun in this.props && typeof this.props[fun] === 'function') {
177
+ var editGraphicId = this.state.editGraphicId;
178
+
179
+ switch (this.state.graphicType) {
180
+ case 'point':
181
+ var locationPoint = this.state.locationPoint;
182
+
183
+ if (this.map.getGraphic('locationPoint')) {
184
+ var p = this.map.getGraphic(locationPoint[0].id).geometry;
185
+ this.props[fun]([p.x, p.y]);
186
+ } else {
187
+ return [];
188
+ }
189
+ break;
190
+ case 'circle':
191
+ this.props[fun](this.state.graphicValue ? {
192
+ x: this.state.graphicValue.geometry.x,
193
+ y: this.state.graphicValue.geometry.y,
194
+ radius: this.state.graphicValue.geometry.radius,
195
+ area: this.state.graphicValue.area
196
+ } : null);
197
+ break;
198
+ case 'polygon':
199
+ if (this.map.getGraphic(editGraphicId)) {
200
+ var _p = this.map.getGraphic(editGraphicId);
201
+ this.props[fun]({
202
+ rings: distinct(_p.geometry.rings),
203
+ area: this.map.getPolygonArea(distinct(_p.geometry.rings))
204
+ });
205
+ } else {
206
+ this.props[fun](this.state.graphicValue ? {
207
+ rings: distinct(this.state.graphicValue.geometry.rings),
208
+ area: this.state.graphicValue.area
209
+ } : null);
210
+ }
211
+ break;
212
+ case 'rectangle':
213
+ this.props[fun](this.state.graphicValue ? {
214
+ rings: distinct(this.state.graphicValue.geometry.rings),
215
+ area: this.state.graphicValue.area
216
+ } : null);
217
+ break;
218
+ case 'polyline':
219
+ if (this.map.getGraphic(editGraphicId)) {
220
+ var _p2 = this.map.getGraphic(editGraphicId);
221
+ this.props[fun]({
222
+ paths: _p2.geometry.paths,
223
+ length: this.map.calculateDistance(_p2.geometry.paths)
224
+ });
225
+ } else {
226
+ this.props[fun](this.state.graphicValue ? {
227
+ paths: this.state.graphicValue.geometry.paths,
228
+ length: this.map.calculateDistance(this.state.graphicValue.geometry.paths)
229
+ } : null);
230
+ }
231
+ break;
232
+ }
233
+ }
234
+ if (this.props.clearDrawnGraph) {
235
+ this.clearDrawnGraph();
236
+ }
237
+ }
238
+ }, {
239
+ key: 'showOrhidden',
240
+ value: function showOrhidden(bealoon) {
241
+ this.setState({
242
+ isShowList: bealoon
243
+ });
244
+ }
245
+ //绘制定位点(以当前的中心点位参照 => 同时开启点位编辑)
246
+
247
+ }, {
248
+ key: 'drawLocationPoint',
249
+ value: function drawLocationPoint() {
250
+ var t = this;
251
+ //判断arcgis,是: 判断中心点是否已经确定,确定,继续走逻辑.不确认.轮询等待
252
+ if (this.props.mapType !== 'gmap' || this.map.state.gis.extent && !!this.map.state.gis.extent.xmax) {
253
+ var lglt = this.map.getMapExtent(),
254
+ editGraphic = null,
255
+ editGraphicId = 'locationPoint';
256
+ if (this.props.editParam && (this.props.graphicType == 'polyline' || this.props.graphicType == 'polygon')) {
257
+ editGraphic = _extends({}, this.props.editParam, { id: 'drawnGraph' });
258
+ editGraphicId = 'drawnGraph';
259
+ }
260
+ this.isinit = false;
261
+ this.setState({
262
+ editGraphic: editGraphic,
263
+ locationPoint: [{
264
+ id: 'locationPoint',
265
+ longitude: (t.props.mapCenter || [])[0] || lglt.nowCenter.lng,
266
+ latitude: (t.props.mapCenter || [])[1] || lglt.nowCenter.lat,
267
+ url: _default2.default.mapServerURL + '/images/defaultMarker.png',
268
+ config: {
269
+ zIndex: 1000
270
+ }
271
+ }]
272
+ }, function () {
273
+ t.setState({
274
+ isDoEdit: true,
275
+ editGraphicId: editGraphicId
276
+ }, function () {
277
+ setTimeout(function () {
278
+ t.setState({
279
+ isDoEdit: false
280
+ });
281
+ }, 500);
282
+ });
283
+ });
284
+ } else {
285
+ t.loadExtent = setTimeout(function () {
286
+ t.drawLocationPoint();
287
+ }, 50);
288
+ }
289
+ }
290
+ //校正定位的点位位置到当前的中心点
291
+
292
+ }, {
293
+ key: 'correction',
294
+ value: function correction() {
295
+ var t = this;
296
+ //获取当前中心点经纬度
297
+ var lglt = this.map.getMapExtent();
298
+ var locationPoint = t.state.locationPoint;
299
+
300
+ locationPoint = locationPoint.map(function (item, index) {
301
+ return _extends({}, item, {
302
+ longitude: lglt.nowCenter.lng,
303
+ latitude: lglt.nowCenter.lat
304
+ });
305
+ });
306
+ this.map.updatePoint(locationPoint);
307
+ }
308
+ //搜索关键字切换
309
+
310
+ }, {
311
+ key: 'changeValue',
312
+ value: function changeValue(e) {
313
+ this.setState({
314
+ searchValue: e.target.value
315
+ });
316
+ }
317
+ //根据关键字搜索数据
318
+
319
+ }, {
320
+ key: 'searchList',
321
+ value: function searchList() {
322
+ //因为antd组件问题,这边使用手动关键位,控制方法执行
323
+ var t = this;
324
+ var searchPoints = t.map.searchPoints(this.state.searchValue);
325
+ searchPoints.then(function (results) {
326
+ if (results.length > 0) {
327
+ var lsp = [],
328
+ lsm = [];
329
+ t.apid = [];
330
+ for (var i = 0; i < results.length; i++) {
331
+ var r = results[i];
332
+ lsp.push(_extends({}, results[i], {
333
+ url: _default2.default.mapServerURL + '/images/defaultMarker_selected.png',
334
+ labelClass: styles.hiddenLabel
335
+ }));
336
+ lsm.push({
337
+ id: r.id,
338
+ title: r.config.labelContent,
339
+ isSelect: false
340
+ });
341
+ t.apid.push(r.id);
342
+ }
343
+ t.setState({
344
+ listPoint: lsp,
345
+ listMess: lsm,
346
+ isShowList: true
347
+ });
348
+ t.setFitView();
349
+ } else {
350
+ warning();
351
+ }
352
+ });
353
+ }
354
+ //返回最佳位置(zoom,center)
355
+
356
+ }, {
357
+ key: 'setFitView',
358
+ value: function setFitView() {
359
+ var _this2 = this;
360
+
361
+ this.setState({
362
+ mapVisiblePoints: {
363
+ fitView: this.apid,
364
+ type: 'all'
365
+ },
366
+ setVisiblePoints: true
367
+ }, function () {
368
+ _this2.setState({
369
+ setVisiblePoints: false
370
+ });
371
+ });
372
+ }
373
+ //清空列表的所有数据(包括点位)
374
+
375
+ }, {
376
+ key: 'clearList',
377
+ value: function clearList() {
378
+ this.apid = [];
379
+ this.setState({
380
+ searchValue: '',
381
+ listPoint: [],
382
+ listMess: [],
383
+ isShowList: false
384
+ });
385
+ }
386
+ //列表选中地址
387
+
388
+ }, {
389
+ key: 'chooseAddress',
390
+ value: function chooseAddress(id) {
391
+ var t = this;
392
+ var _state = this.state,
393
+ listPoint = _state.listPoint,
394
+ listMess = _state.listMess;
395
+
396
+ var mapCenter = [];
397
+ listPoint = listPoint.map(function (item, index) {
398
+ if (item.id === id) {
399
+ mapCenter = [item.longitude, item.latitude];
400
+ return _extends({}, item, {
401
+ labelClass: styles.showLabel
402
+ });
403
+ } else {
404
+ return _extends({}, item, {
405
+ labelClass: styles.hiddenLabel
406
+ });
407
+ }
408
+ });
409
+ listMess = listMess.map(function (item, index) {
410
+ if (item.id === id) {
411
+ return _extends({}, item, {
412
+ isSelect: true
413
+ });
414
+ } else {
415
+ return _extends({}, item, {
416
+ isSelect: false
417
+ });
418
+ }
419
+ });
420
+ this.setState({
421
+ listPoint: listPoint,
422
+ listMess: listMess,
423
+ mapCenter: mapCenter,
424
+ setCenter: true
425
+ }, function () {
426
+ t.setState({
427
+ setCenter: false
428
+ });
429
+ if (t.state.graphicType == 'point') {
430
+ t.correction();
431
+ }
432
+ });
433
+ }
434
+ }, {
435
+ key: 'clickGraphic',
436
+ value: function clickGraphic(obj) {
437
+ if (obj.type === 'point' && obj.attributes.other === 'search') {
438
+ this.chooseAddress(obj.attributes.id);
439
+ }
440
+ }
441
+ }, {
442
+ key: 'closeModal',
443
+ value: function closeModal(e) {
444
+ if (this.isDrawStatus && this.isClickMap) {
445
+ _message2.default.warning('请双击结束图元编辑');
446
+ } else {
447
+ if ('closeModal' in this.props) {
448
+ this.props.closeModal();
449
+ } else {
450
+ this.setState({
451
+ modal1Visible: false
452
+ });
453
+ }
454
+ // if(this.props.clearDrawnGraph){
455
+ this.clearDrawnGraph();
456
+ // }
457
+ }
458
+ }
459
+ }, {
460
+ key: 'clearDrawnGraph',
461
+ value: function clearDrawnGraph() {
462
+ var _this3 = this;
463
+
464
+ this.isDrawStatus = true;
465
+ this.setState({
466
+ isDraw: this.state.graphicType !== 'point',
467
+ graphicValue: null,
468
+ isEndEdit: this.state.graphicType !== 'point'
469
+ }, function () {
470
+ _this3.setState({ isEndEdit: false });
471
+ });
472
+ }
473
+ }, {
474
+ key: 'render',
475
+ value: function render() {
476
+ var _this4 = this;
477
+
478
+ var t = this;
479
+ var _state2 = this.state,
480
+ isShowList = _state2.isShowList,
481
+ searchValue = _state2.searchValue,
482
+ locationPoint = _state2.locationPoint,
483
+ listPoint = _state2.listPoint,
484
+ listMess = _state2.listMess,
485
+ mapZoomLevel = _state2.mapZoomLevel,
486
+ setZoomLevel = _state2.setZoomLevel,
487
+ maxZoom = _state2.maxZoom,
488
+ minZoom = _state2.minZoom,
489
+ wkid = _state2.wkid,
490
+ mapServer = _state2.mapServer,
491
+ mapCenter = _state2.mapCenter,
492
+ setCenter = _state2.setCenter,
493
+ mapType = _state2.mapType,
494
+ mapVisiblePoints = _state2.mapVisiblePoints,
495
+ setVisiblePoints = _state2.setVisiblePoints,
496
+ isDoEdit = _state2.isDoEdit,
497
+ editGraphicId = _state2.editGraphicId,
498
+ isEndEdit = _state2.isEndEdit,
499
+ modal1Visible = _state2.modal1Visible,
500
+ drawGraphID = _state2.drawGraphID,
501
+ isShowOther = _state2.isShowOther,
502
+ otherText = _state2.otherText,
503
+ isShowOtherGraph = _state2.isShowOtherGraph,
504
+ editGraphic = _state2.editGraphic,
505
+ graphicType = _state2.graphicType;
506
+
507
+ var InputProps = {
508
+ style: { 'width': '200px' },
509
+ placeholder: '输入关键字',
510
+ value: searchValue,
511
+ onChange: this.changeValue.bind(this),
512
+ onPressEnter: this.searchList.bind(this),
513
+ onKeyDown: this.changeValue.bind(this)
514
+ };
515
+ var drawProps = this.state.graphicType == 'point' || t.isinit ? {
516
+ isDraw: this.state.isDraw,
517
+ isCloseDraw: this.state.isCloseDraw
518
+ } : {
519
+ isDraw: this.state.isDraw,
520
+ isCloseDraw: this.state.isCloseDraw,
521
+ drawEnd: function drawEnd(obj) {
522
+ _this4.isDrawStatus = false;
523
+ _this4.isClickMap = false;
524
+ var objparam = {
525
+ graphicValue: obj,
526
+ isDraw: false
527
+ };
528
+ if (obj.geometryType == 'polyline' || obj.geometryType == 'polygon') {
529
+ objparam.editGraphicId = obj.id;
530
+ objparam.isDoEdit = true;
531
+ }
532
+ _this4.setState(objparam, function () {
533
+ _this4.setState({
534
+ isDoEdit: false
535
+ });
536
+ });
537
+ },
538
+ mapDraw: {
539
+ geometryType: this.state.graphicType,
540
+ parameter: this.state.parameter || (this.state.graphicType == 'polyline' ? {
541
+ color: '#108edf', //线颜色,
542
+ pellucidity: 1, //线透明度,
543
+ lineWidth: 3, //线宽度
544
+ lineType: 'solid'
545
+ } : this.state.graphicType == 'polygon' || this.state.graphicType == 'circle' || this.state.graphicType == 'rectangle' ? {
546
+ color: '#ffffff', //填充色,
547
+ lineColor: '#108edf', //线颜色,
548
+ lineOpacity: 1, //线透明度,
549
+ lineWidth: 3, //线宽度,
550
+ pellucidity: 0.8, //填充透明度
551
+ lineType: 'solid'
552
+ } : {}),
553
+ data: { id: drawGraphID }
554
+ }
555
+ };
556
+ var mapPoints = [],
557
+ mapLines = [],
558
+ mapPolygons = [],
559
+ mapCircles = [];
560
+ if (graphicType == 'point') {
561
+ mapPoints = [].concat(_toConsumableArray(locationPoint), _toConsumableArray(listPoint));
562
+ } else {
563
+ mapPoints = [].concat(_toConsumableArray(listPoint));
564
+ }
565
+ if (graphicType === 'polygon') {
566
+ if (editGraphic) {
567
+ mapPolygons.push(editGraphic);
568
+ drawProps = null;
569
+ }
570
+ }
571
+ if (graphicType === 'polyline') {
572
+ if (editGraphic) {
573
+ mapLines.push(editGraphic);
574
+ drawProps = null;
575
+ }
576
+ }
577
+ if (isShowOtherGraph) {
578
+ var otherGraph = this.props.otherGraph;
579
+
580
+ if (otherGraph) {
581
+ mapPoints = [].concat(_toConsumableArray(mapPoints), _toConsumableArray(otherGraph.point || []));
582
+ mapLines = [].concat(_toConsumableArray(mapLines), _toConsumableArray(otherGraph.polyline || []));
583
+ mapPolygons = [].concat(_toConsumableArray(mapPolygons), _toConsumableArray(otherGraph.polygon || []));
584
+ mapCircles = [].concat(_toConsumableArray(mapCircles), _toConsumableArray(otherGraph.circle || []));
585
+ }
586
+ }
587
+ return _react2.default.createElement(
588
+ _VtxModal.VtxModal,
589
+ {
590
+ title: this.state.graphicType == 'point' ? "定位" : "绘制",
591
+ style: { top: 50 },
592
+ visible: modal1Visible,
593
+ maximize: true,
594
+ isNotMoving: true,
595
+ wrapClassName: styles.searchModal,
596
+ bodyStyle: { height: window.innerHeight * 0.7 + 'px' },
597
+ maskClosable: false,
598
+ onCancel: this.closeModal.bind(this),
599
+ footer: _react2.default.createElement(
600
+ 'div',
601
+ { className: styles.bottom },
602
+ _react2.default.createElement(
603
+ _button2.default,
604
+ { type: 'primary', onClick: function onClick() {
605
+ _this4.callback();
606
+ }, icon: getIcon('check') },
607
+ '\u786E\u5B9A'
608
+ ),
609
+ _react2.default.createElement(
610
+ _button2.default,
611
+ { onClick: this.closeModal.bind(this), icon: getIcon('close') },
612
+ '\u5173\u95ED'
613
+ )
614
+ )
615
+ },
616
+ _react2.default.createElement(
617
+ 'div',
618
+ { className: styles.searchMap },
619
+ _react2.default.createElement(
620
+ 'div',
621
+ { className: styles.top },
622
+ mapType == 'gmap' ? '' : [_react2.default.createElement(_input2.default, _extends({ key: '1' }, InputProps)), _react2.default.createElement(
623
+ _button2.default,
624
+ { key: '2', type: 'primary', onClick: this.searchList.bind(this), icon: getIcon('search') },
625
+ '\u67E5\u8BE2'
626
+ ), _react2.default.createElement(
627
+ _button2.default,
628
+ { key: '3', onClick: this.clearList.bind(this), icon: getIcon('close') },
629
+ '\u6E05\u7A7A'
630
+ )],
631
+ this.state.graphicType == 'point' ? _react2.default.createElement(
632
+ _button2.default,
633
+ { onClick: this.correction.bind(this), icon: getIcon('environment') },
634
+ '\u6821\u6B63'
635
+ ) : null,
636
+ this.state.graphicType != 'point' ? _react2.default.createElement(
637
+ _button2.default,
638
+ { disabled: this.isDrawStatus, onClick: function onClick() {
639
+ _this4.isDrawStatus = true;
640
+ _this4.setState({
641
+ isDraw: true,
642
+ graphicValue: null,
643
+ editGraphic: null,
644
+ isEndEdit: true
645
+ }, function () {
646
+ t.map.removeGraphic('drawnGraph', 'draw');
647
+ t.setState({
648
+ isEndEdit: false
649
+ });
650
+ });
651
+ _this4.callback('editDraw');
652
+ }, icon: getIcon('edit') },
653
+ '\u91CD\u65B0\u7ED8\u5236'
654
+ ) : null,
655
+ mapType == 'gmap' ? '' : _react2.default.createElement(
656
+ _button2.default,
657
+ { onClick: this.setFitView.bind(this), icon: getIcon('sync') },
658
+ '\u8FD4\u56DE\u5168\u5C40\u5730\u56FE'
659
+ ),
660
+ isShowOther ? _react2.default.createElement(
661
+ 'div',
662
+ { className: styles.otherModal },
663
+ _react2.default.createElement(
664
+ _checkbox2.default,
665
+ { checked: isShowOtherGraph, onChange: function onChange(e) {
666
+ _this4.setState({ isShowOtherGraph: e.target.checked });
667
+ } },
668
+ otherText
669
+ )
670
+ ) : ''
671
+ ),
672
+ _react2.default.createElement(
673
+ 'div',
674
+ { className: styles.content, style: { paddingLeft: mapType == 'gmap' ? '0px' : '25px' } },
675
+ mapType == 'gmap' ? '' : _react2.default.createElement(
676
+ 'div',
677
+ { className: styles.content_left + ' ' + (isShowList ? styles.w_l : '') },
678
+ _react2.default.createElement(
679
+ 'div',
680
+ { className: '' + (isShowList ? styles.show : styles.hidden) },
681
+ _react2.default.createElement(
682
+ 'div',
683
+ { className: styles.listTitle },
684
+ _react2.default.createElement(
685
+ 'div',
686
+ { className: styles.title },
687
+ '\u67E5\u8BE2\u7ED3\u679C'
688
+ ),
689
+ _react2.default.createElement(
690
+ 'div',
691
+ { onClick: function onClick() {
692
+ return _this4.showOrhidden(false);
693
+ }, className: styles.btn },
694
+ _react2.default.createElement(_default.VtxMapIcon, { type: 'icon-doubleleft' })
695
+ )
696
+ ),
697
+ _react2.default.createElement(
698
+ 'div',
699
+ { className: styles.scrollauto },
700
+ listMess.map(function (item, index) {
701
+ return _react2.default.createElement(
702
+ 'div',
703
+ {
704
+ key: index,
705
+ onClick: function onClick() {
706
+ return _this4.chooseAddress(item.id);
707
+ },
708
+ className: styles.lists + ' ' + (item.isSelect ? styles.select : '')
709
+ },
710
+ item.title
711
+ );
712
+ })
713
+ )
714
+ ),
715
+ _react2.default.createElement(
716
+ 'div',
717
+ { onClick: function onClick() {
718
+ return _this4.showOrhidden(true);
719
+ }, className: styles.btn + ' ' + (!isShowList ? styles.show : styles.hidden) },
720
+ _react2.default.createElement(_default.VtxMapIcon, { type: 'icon-doubleright' })
721
+ )
722
+ ),
723
+ _react2.default.createElement(
724
+ 'div',
725
+ { className: styles.content_right },
726
+ _react2.default.createElement(_VtxMap.VtxMap, _extends({
727
+ getMapInstance: function getMapInstance(map) {
728
+ if (map) _this4.map = map;
729
+ },
730
+ mapType: mapType,
731
+ mapServer: mapServer,
732
+ wkid: wkid,
733
+ mapId: t.mapId,
734
+ setCenter: setCenter,
735
+ mapCenter: mapCenter,
736
+ minZoom: minZoom,
737
+ maxZoom: maxZoom,
738
+ mapZoomLevel: mapZoomLevel,
739
+ setZoomLevel: setZoomLevel,
740
+ mapPoints: mapPoints,
741
+ mapLines: mapLines,
742
+ mapPolygons: mapPolygons,
743
+ mapCircles: mapCircles,
744
+ mapVisiblePoints: mapVisiblePoints,
745
+ setVisiblePoints: setVisiblePoints,
746
+ isDoEdit: isDoEdit,
747
+ isEndEdit: isEndEdit,
748
+ editGraphicId: editGraphicId,
749
+ editGraphicChange: function editGraphicChange() {},
750
+ clickGraphic: this.clickGraphic.bind(this),
751
+ clickMap: function clickMap() {
752
+ t.isClickMap = true;
753
+ }
754
+ }, drawProps))
755
+ )
756
+ )
757
+ )
758
+ );
759
+ }
760
+ }, {
761
+ key: 'initSearchMap',
762
+ value: function initSearchMap() {
763
+ var _this5 = this;
764
+
765
+ if (this.props.modal1Visible /*&& !this.state.locationPoint[0]*/) {
766
+ if (this.map) {
767
+ this.map.loadMapComplete.then(function () {
768
+ if (!_this5.mapLoaded) {
769
+ _this5.mapLoaded = true;
770
+ _this5.drawLocationPoint();
771
+ }
772
+ });
773
+ }
774
+ }
775
+ }
776
+ }, {
777
+ key: 'componentDidMount',
778
+ value: function componentDidMount() {
779
+ //绘制定位点(以当前的中心点位参照=>初始化好后才有ref可以获取中心点)
780
+ this.initSearchMap();
781
+ }
782
+ }, {
783
+ key: 'componentDidUpdate',
784
+ value: function componentDidUpdate(prevProps, prevState) {
785
+ //重新渲染结束
786
+ this.initSearchMap();
787
+ }
788
+ }, {
789
+ key: 'componentWillReceiveProps',
790
+ value: function componentWillReceiveProps(nextProps) {
791
+ var _this6 = this;
792
+
793
+ var t = this;
794
+ this.isClickMap = false;
795
+ if (t.state.graphicType !== nextProps.graphicType && !!this.map) {
796
+ this.map.clearAll();
797
+ t.mapLoaded = false;
798
+ t.isinit = true;
799
+ }
800
+ if (nextProps.editParam) {
801
+ t.mapLoaded = false;
802
+ }
803
+ t.isDrawStatus = nextProps.graphicType !== 'point' && !nextProps.editParam;
804
+ this.setState({
805
+ modal1Visible: nextProps.modal1Visible,
806
+ maxZoom: nextProps.maxZoom,
807
+ minZoom: nextProps.minZoom,
808
+ wkid: nextProps.wkid,
809
+ mapCenter: nextProps.mapCenter || '',
810
+ mapType: nextProps.mapType || 'bmap',
811
+ mapServer: nextProps.mapServer,
812
+ graphicType: nextProps.graphicType || 'point',
813
+ isDraw: nextProps.graphicType !== 'point' && !nextProps.editParam,
814
+ isCloseDraw: !(nextProps.graphicType !== 'point' && !nextProps.editParam),
815
+ editGraphicId: ''
816
+ }, function () {
817
+ t.setState({
818
+ isCloseDraw: false
819
+ });
820
+ t.initSearchMap();
821
+ });
822
+ setTimeout(function () {
823
+ //实现2+次进入时,清理数据
824
+ if (nextProps.modal1Visible) {
825
+ _this6.clearList();
826
+ _this6.setState({
827
+ setZoomLevel: true
828
+ }, function () {
829
+ _this6.setState({
830
+ setZoomLevel: false
831
+ });
832
+ });
833
+ if (!!_this6.map && !!_this6.state.locationPoint[0] && nextProps.mapCenter && !!nextProps.mapCenter[0]) {
834
+ if (_this6.map.getGraphic('locationPoint')) {
835
+ switch (nextProps.mapType) {
836
+ case 'bmap':
837
+ _this6.map.getGraphic('locationPoint').mapLayer.setPosition(new BMap.Point(nextProps.mapCenter[0], nextProps.mapCenter[1]));
838
+ break;
839
+ case 'amap':
840
+ _this6.map.getGraphic('locationPoint').mapLayer.setPosition(new AMap.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
841
+ break;
842
+ case 'tmap':
843
+ _this6.map.getGraphic('locationPoint').mapLayer.setLngLat(new T.LngLat(nextProps.mapCenter[0], nextProps.mapCenter[1]));
844
+ break;
845
+ case 'gmap':
846
+ _this6.map.getGraphic('locationPoint').mapLayer.geometry.setLatitude(nextProps.mapCenter[1]);
847
+ _this6.map.getGraphic('locationPoint').mapLayer.geometry.setLongitude(nextProps.mapCenter[0]);
848
+ _this6.map.state.gis.graphics.refresh();
849
+ break;
850
+ }
851
+ }
852
+ _this6.map.setCenter(nextProps.mapCenter);
853
+ }
854
+ }
855
+ }, 100);
856
+ }
857
+ }, {
858
+ key: 'componentWillUnmount',
859
+ value: function componentWillUnmount() {
860
+ //关闭moveTo定时
861
+ var t = this;
862
+ if (t.loadExtent) {
863
+ clearInterval(t.loadExtent);
864
+ }
865
+ }
866
+ }]);
867
+
868
+ return VtxSearchMap;
869
+ }(_react2.default.Component);
870
+
871
+ exports.default = VtxSearchMap;
872
+ module.exports = exports['default'];