wt-antd 4.2.41 → 4.2.43

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.
@@ -37,6 +37,7 @@ export declare class BiuMapSelectSite extends React.PureComponent<BiuMapSelectSi
37
37
  componentDidUpdate(): void;
38
38
  init: () => void;
39
39
  mapDrawMarker: (lng: any, lat: any) => void;
40
+ getGeocoder: () => void;
40
41
  invokeSearchPOI: (name: string) => Promise<any>;
41
42
  invokeAutoComplete: (name: string) => Promise<any>;
42
43
  search: (value: string) => Promise<void>;
@@ -101,6 +101,10 @@ export var BiuMapSelectSite = /*#__PURE__*/function (_React$PureComponent) {
101
101
  // map.plugin(['AMap.PlaceSearch'], () => {
102
102
  // map.addControl(new AMap.PlaceSearch());
103
103
  // });
104
+ if (_this.props.textAddress) {
105
+ _this.getGeocoder();
106
+ return false;
107
+ }
104
108
  // 默认位置
105
109
  if (_this.props.position && _this.props.position.lng && _this.props.position.lat) {
106
110
  _this.mapDrawMarker(_this.props.position.lng, _this.props.position.lat);
@@ -157,6 +161,37 @@ export var BiuMapSelectSite = /*#__PURE__*/function (_React$PureComponent) {
157
161
  }
158
162
  map.setCenter([lng, lat]); // 设置地图中心点
159
163
  });
164
+ _defineProperty(_assertThisInitialized(_this), "getGeocoder", function () {
165
+ var that = _assertThisInitialized(_this);
166
+ AMap.plugin('AMap.Geocoder', function () {
167
+ var _that$props;
168
+ var geocoder = new AMap.Geocoder({
169
+ enableHighAccuracy: true,
170
+ // 是否使用高精度定位,默认:true
171
+ timeout: 10000,
172
+ // 超过10秒后停止定位,默认:5s
173
+ buttonPosition: 'RB',
174
+ // 定位按钮的停靠位置
175
+ buttonOffset: new AMap.Pixel(10, 20),
176
+ // 定位按钮距离对应角落的距离
177
+ zoomToAccuracy: true
178
+ });
179
+ // map.addControl(geocoder)
180
+ geocoder.getLocation((_that$props = that.props) === null || _that$props === void 0 ? void 0 : _that$props.textAddress, function (status, result) {
181
+ console.log('geocoder.getLocation', status, result);
182
+ if (status === 'complete' && result.geocodes.length) {
183
+ var geocode = result.geocodes[0];
184
+ map.setCenter(geocode.location); // 根据地址设置地图中心点
185
+ that.mark = new AMap.Marker({
186
+ position: geocode.location,
187
+ map: map // 添加到地图上
188
+ });
189
+ } else {
190
+ console.error('根据地址查询失败');
191
+ }
192
+ });
193
+ });
194
+ });
160
195
  _defineProperty(_assertThisInitialized(_this), "invokeSearchPOI", /*#__PURE__*/function () {
161
196
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(name) {
162
197
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -254,7 +289,7 @@ export var BiuMapSelectSite = /*#__PURE__*/function (_React$PureComponent) {
254
289
  }
255
290
  _context3.prev = 9;
256
291
  _context3.next = 12;
257
- return _this.invokeSearchPOI(value);
292
+ return _this.invokeAutoComplete(value);
258
293
  case 12:
259
294
  result = _context3.sent;
260
295
  _context3.next = 17;
@@ -264,12 +299,12 @@ export var BiuMapSelectSite = /*#__PURE__*/function (_React$PureComponent) {
264
299
  _context3.t0 = _context3["catch"](9);
265
300
  case 17:
266
301
  _context3.prev = 17;
267
- if (result) {
302
+ if (!(!result || result.length === 0)) {
268
303
  _context3.next = 22;
269
304
  break;
270
305
  }
271
306
  _context3.next = 21;
272
- return _this.invokeAutoComplete(value);
307
+ return _this.invokeSearchPOI(value);
273
308
  case 21:
274
309
  result = _context3.sent;
275
310
  case 22:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wt-antd",
3
- "version": "4.2.41",
3
+ "version": "4.2.43",
4
4
  "description": "万通业务组件",
5
5
  "sideEffects": false,
6
6
  "main": "dist/esm/index.js",