@vtx/map 1.1.6 → 1.1.9

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