@vortex-ui/env-puzzle 2.0.0-beta.2 → 2.0.0-beta.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.
- package/lib/b-map/b-map.d.ts +63 -0
- package/lib/b-map/b-map.js +296 -0
- package/lib/b-map/b-map.js.map +1 -0
- package/lib/b-map/custom-overlay.d.ts +13 -0
- package/lib/b-map/custom-overlay.js +84 -0
- package/lib/b-map/custom-overlay.js.map +1 -0
- package/lib/b-map/drawing.d.ts +14 -0
- package/lib/b-map/drawing.js +73 -0
- package/lib/b-map/drawing.js.map +1 -0
- package/lib/b-map/index.d.ts +17 -0
- package/lib/b-map/index.js +35 -0
- package/lib/b-map/index.js.map +1 -0
- package/lib/b-map/js/marker-clusterer.js +158 -42
- package/lib/b-map/js/marker-clusterer.js.map +1 -1
- package/lib/b-map/lushu.d.ts +16 -0
- package/lib/b-map/lushu.js +78 -0
- package/lib/b-map/lushu.js.map +1 -0
- package/lib/b-map/marker-clusterer.d.ts +29 -0
- package/lib/b-map/marker-clusterer.js +52 -0
- package/lib/b-map/marker-clusterer.js.map +1 -0
- package/lib/b-map/marker.d.ts +45 -0
- package/lib/b-map/marker.js +184 -0
- package/lib/b-map/marker.js.map +1 -0
- package/lib/b-map/polygon.d.ts +54 -0
- package/lib/b-map/polygon.js +44 -0
- package/lib/b-map/polygon.js.map +1 -0
- package/lib/b-map/style/css.js +4 -0
- package/lib/b-map/style/css.js.map +1 -0
- package/lib/b-map/style/index.d.ts +1 -0
- package/lib/b-map/style/index.js +4 -0
- package/lib/b-map/style/index.js.map +1 -0
- package/lib/create-modal/create-modal.d.ts +31 -0
- package/lib/create-modal/create-modal.js +653 -0
- package/lib/create-modal/create-modal.js.map +1 -0
- package/lib/create-modal/index.d.ts +3 -0
- package/lib/create-modal/index.js +14 -0
- package/lib/create-modal/index.js.map +1 -0
- package/lib/create-modal/style/css.js +22 -0
- package/lib/create-modal/style/css.js.map +1 -0
- package/lib/create-modal/style/index.d.ts +10 -0
- package/lib/create-modal/style/index.js +22 -0
- package/lib/create-modal/style/index.js.map +1 -0
- package/lib/import-modal/import-modal.d.ts +23 -0
- package/lib/import-modal/import-modal.js +358 -0
- package/lib/import-modal/import-modal.js.map +1 -0
- package/lib/import-modal/index.d.ts +2 -0
- package/lib/import-modal/index.js +14 -0
- package/lib/import-modal/index.js.map +1 -0
- package/lib/import-modal/style/css.js +14 -0
- package/lib/import-modal/style/css.js.map +1 -0
- package/lib/import-modal/style/index.d.ts +6 -0
- package/lib/import-modal/style/index.js +14 -0
- package/lib/import-modal/style/index.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +104 -0
- package/lib/index.js.map +1 -0
- package/lib/interface/index.d.ts +7 -0
- package/lib/interface/index.js +6 -0
- package/lib/interface/index.js.map +1 -0
- package/lib/mapv-Layer/Function.d.ts +1 -0
- package/lib/mapv-Layer/Function.js +2 -0
- package/lib/mapv-Layer/Function.js.map +1 -1
- package/lib/mapv-Layer/index.d.ts +2 -0
- package/lib/mapv-Layer/index.js +14 -0
- package/lib/mapv-Layer/index.js.map +1 -0
- package/lib/mapv-Layer/mapv-Layer.d.ts +7 -0
- package/lib/mapv-Layer/mapv-Layer.js +117 -0
- package/lib/mapv-Layer/mapv-Layer.js.map +1 -0
- package/lib/mapv-Layer/style/css.js +2 -0
- package/lib/mapv-Layer/style/css.js.map +1 -0
- package/lib/mapv-Layer/style/index.d.ts +1 -0
- package/lib/mapv-Layer/style/index.js +2 -0
- package/lib/mapv-Layer/style/index.js.map +1 -0
- package/lib/percent/images/icon-arrow.png +0 -0
- package/lib/percent/index.d.ts +8 -0
- package/lib/percent/index.js +18 -0
- package/lib/percent/index.js.map +1 -0
- package/lib/percent/interface.d.ts +6 -0
- package/lib/percent/interface.js +6 -0
- package/lib/percent/interface.js.map +1 -0
- package/lib/percent/line-percent.d.ts +11 -0
- package/lib/percent/line-percent.js +114 -0
- package/lib/percent/line-percent.js.map +1 -0
- package/lib/percent/percent.d.ts +10 -0
- package/lib/percent/percent.js +139 -0
- package/lib/percent/percent.js.map +1 -0
- package/lib/percent/style/css.js +4 -0
- package/lib/percent/style/css.js.map +1 -0
- package/lib/percent/style/index.d.ts +1 -0
- package/lib/percent/style/index.js +4 -0
- package/lib/percent/style/index.js.map +1 -0
- package/lib/scroll/index.d.ts +2 -0
- package/lib/scroll/index.js +14 -0
- package/lib/scroll/index.js.map +1 -0
- package/lib/scroll/scroll.d.ts +4 -0
- package/lib/scroll/scroll.js +105 -0
- package/lib/scroll/scroll.js.map +1 -0
- package/lib/scroll/style/css.js +4 -0
- package/lib/scroll/style/css.js.map +1 -0
- package/lib/scroll/style/index.d.ts +1 -0
- package/lib/scroll/style/index.js +4 -0
- package/lib/scroll/style/index.js.map +1 -0
- package/lib/scroll-select/index.d.ts +2 -0
- package/lib/scroll-select/index.js +14 -0
- package/lib/scroll-select/index.js.map +1 -0
- package/lib/scroll-select/scrollSelect.d.ts +2 -0
- package/lib/scroll-select/scrollSelect.js +323 -0
- package/lib/scroll-select/scrollSelect.js.map +1 -0
- package/lib/scroll-select/style/css.js +6 -0
- package/lib/scroll-select/style/css.js.map +1 -0
- package/lib/scroll-select/style/index.d.ts +2 -0
- package/lib/scroll-select/style/index.js +6 -0
- package/lib/scroll-select/style/index.js.map +1 -0
- package/lib/table/index.d.ts +2 -0
- package/lib/table/index.js +14 -0
- package/lib/table/index.js.map +1 -0
- package/lib/table/style/css.js +6 -0
- package/lib/table/style/css.js.map +1 -0
- package/lib/table/style/index.d.ts +2 -0
- package/lib/table/style/index.js +6 -0
- package/lib/table/style/index.js.map +1 -0
- package/lib/table/table.d.ts +17 -0
- package/lib/table/table.js +162 -0
- package/lib/table/table.js.map +1 -0
- package/lib/template/action.d.ts +57 -0
- package/lib/template/action.js +265 -0
- package/lib/template/action.js.map +1 -0
- package/lib/template/card-table.d.ts +35 -0
- package/lib/template/card-table.js +193 -0
- package/lib/template/card-table.js.map +1 -0
- package/lib/template/card.d.ts +15 -0
- package/lib/template/card.js +116 -0
- package/lib/template/card.js.map +1 -0
- package/lib/template/check-row.d.ts +6 -0
- package/lib/template/check-row.js +39 -0
- package/lib/template/check-row.js.map +1 -0
- package/lib/template/field.d.ts +6 -0
- package/lib/template/field.js +50 -0
- package/lib/template/field.js.map +1 -0
- package/lib/template/filter.d.ts +13 -0
- package/lib/template/filter.js +146 -0
- package/lib/template/filter.js.map +1 -0
- package/lib/template/icon.d.ts +6 -0
- package/lib/template/icon.js +33 -0
- package/lib/template/icon.js.map +1 -0
- package/lib/template/index.d.ts +13 -0
- package/lib/template/index.js +24 -0
- package/lib/template/index.js.map +1 -0
- package/lib/template/interface.d.ts +4 -0
- package/lib/template/interface.js +6 -0
- package/lib/template/interface.js.map +1 -0
- package/lib/template/renderColumnButtons.d.ts +2 -0
- package/lib/template/renderColumnButtons.js +173 -0
- package/lib/template/renderColumnButtons.js.map +1 -0
- package/lib/template/style/css.js +40 -0
- package/lib/template/style/css.js.map +1 -0
- package/lib/template/style/index.d.ts +19 -0
- package/lib/template/style/index.js +40 -0
- package/lib/template/style/index.js.map +1 -0
- package/lib/template/table.d.ts +44 -0
- package/lib/template/table.js +103 -0
- package/lib/template/table.js.map +1 -0
- package/lib/template/template.d.ts +84 -0
- package/lib/template/template.js +610 -0
- package/lib/template/template.js.map +1 -0
- package/lib/template/toolbar.d.ts +16 -0
- package/lib/template/toolbar.js +102 -0
- package/lib/template/toolbar.js.map +1 -0
- package/lib/to-map/container.d.ts +28 -0
- package/lib/to-map/container.js +295 -0
- package/lib/to-map/container.js.map +1 -0
- package/lib/to-map/draw-area.d.ts +6 -0
- package/lib/to-map/draw-area.js +66 -0
- package/lib/to-map/draw-area.js.map +1 -0
- package/lib/to-map/images/icon-area.png +0 -0
- package/lib/to-map/images/icon-picker.png +0 -0
- package/lib/to-map/index.d.ts +8 -0
- package/lib/to-map/index.js +18 -0
- package/lib/to-map/index.js.map +1 -0
- package/lib/to-map/style/css.js +6 -0
- package/lib/to-map/style/css.js.map +1 -0
- package/lib/to-map/style/index.d.ts +2 -0
- package/lib/to-map/style/index.js +6 -0
- package/lib/to-map/style/index.js.map +1 -0
- package/lib/to-map/to-map.d.ts +12 -0
- package/lib/to-map/to-map.js +120 -0
- package/lib/to-map/to-map.js.map +1 -0
- package/lib/upload/index.d.ts +2 -0
- package/lib/upload/index.js +14 -0
- package/lib/upload/index.js.map +1 -0
- package/lib/upload/style/css.js +10 -0
- package/lib/upload/style/css.js.map +1 -0
- package/lib/upload/style/index.d.ts +4 -0
- package/lib/upload/style/index.js +10 -0
- package/lib/upload/style/index.js.map +1 -0
- package/lib/upload/upload.d.ts +12 -0
- package/lib/upload/upload.js +445 -0
- package/lib/upload/upload.js.map +1 -0
- package/lib/use-simple-res/demos/index.d.ts +2 -0
- package/lib/use-simple-res/demos/index.js +116 -0
- package/lib/use-simple-res/demos/index.js.map +1 -0
- package/lib/use-simple-res/index.d.ts +28 -0
- package/lib/use-simple-res/index.js +99 -0
- package/lib/use-simple-res/index.js.map +1 -0
- package/lib/use-simple-res/style/css.js +4 -0
- package/lib/use-simple-res/style/css.js.map +1 -0
- package/lib/use-simple-res/style/index.d.ts +1 -0
- package/lib/use-simple-res/style/index.js +4 -0
- package/lib/use-simple-res/style/index.js.map +1 -0
- package/lib/utils/dom-util.d.ts +19 -0
- package/lib/utils/dom-util.js +98 -0
- package/lib/utils/dom-util.js.map +1 -0
- package/lib/utils/request-util.d.ts +42 -0
- package/lib/utils/request-util.js +191 -0
- package/lib/utils/request-util.js.map +1 -0
- package/lib/utils/string-util.d.ts +11 -0
- package/lib/utils/string-util.js +47 -0
- package/lib/utils/string-util.js.map +1 -0
- package/lib/view-modal/index.d.ts +2 -0
- package/lib/view-modal/index.js +14 -0
- package/lib/view-modal/index.js.map +1 -0
- package/lib/view-modal/style/css.js +16 -0
- package/lib/view-modal/style/css.js.map +1 -0
- package/lib/view-modal/style/index.d.ts +8 -0
- package/lib/view-modal/style/index.js +16 -0
- package/lib/view-modal/style/index.js.map +1 -0
- package/lib/view-modal/view-modal.d.ts +8 -0
- package/lib/view-modal/view-modal.js +208 -0
- package/lib/view-modal/view-modal.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const defaultCenter: {
|
|
3
|
+
lng: number;
|
|
4
|
+
lat: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const defaultZoom = 15;
|
|
7
|
+
export interface Point {
|
|
8
|
+
lng: number | string;
|
|
9
|
+
lat: number | string;
|
|
10
|
+
}
|
|
11
|
+
export interface InternalBMapProps {
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
center?: Point;
|
|
15
|
+
zoom?: number;
|
|
16
|
+
onZoomChange?: (zoom: number) => any;
|
|
17
|
+
onCreate?: (mapInstance: any) => any;
|
|
18
|
+
}
|
|
19
|
+
export interface InternalBMapState {
|
|
20
|
+
map: any;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 原始的百度地图组件
|
|
24
|
+
*/
|
|
25
|
+
declare class InternalBMap extends React.Component<InternalBMapProps, InternalBMapState> {
|
|
26
|
+
mapInstance: any;
|
|
27
|
+
containerRef: HTMLDivElement | null;
|
|
28
|
+
static defaultProps: {
|
|
29
|
+
center: {
|
|
30
|
+
lng: number;
|
|
31
|
+
lat: number;
|
|
32
|
+
};
|
|
33
|
+
zoom: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 构造函数
|
|
37
|
+
* @param {InternalBMapProps} props
|
|
38
|
+
*/
|
|
39
|
+
constructor(props: InternalBMapProps | Readonly<InternalBMapProps>);
|
|
40
|
+
/**
|
|
41
|
+
* 钩子函数, 做一些初始化数据
|
|
42
|
+
*/
|
|
43
|
+
componentDidMount(): void;
|
|
44
|
+
/**
|
|
45
|
+
* 在状态变更的时候变更地图信息
|
|
46
|
+
* @param {InternalBMapProps} prevProps
|
|
47
|
+
*/
|
|
48
|
+
componentDidUpdate(prevProps: InternalBMapProps): void;
|
|
49
|
+
/**
|
|
50
|
+
* 1. 加载百度地图需要的js文件
|
|
51
|
+
* 2. 向百度地图示例上挂载一些自定义函数, 便于操作
|
|
52
|
+
* 3. 初始化百度地图示例
|
|
53
|
+
* @return {void}
|
|
54
|
+
*/
|
|
55
|
+
init(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* 渲染子节点, 并且向子元素的`props`自动填充`map`属性
|
|
58
|
+
* @return {React.ReactNode} node
|
|
59
|
+
*/
|
|
60
|
+
renderChildren(): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>>)[];
|
|
61
|
+
render(): JSX.Element;
|
|
62
|
+
}
|
|
63
|
+
export default InternalBMap;
|
|
@@ -0,0 +1,296 @@
|
|
|
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); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.defaultZoom = exports.defaultCenter = exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _domUtil = _interopRequireDefault(require("../utils/dom-util"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
23
|
+
|
|
24
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
+
|
|
26
|
+
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); } }
|
|
27
|
+
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
29
|
+
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
|
+
|
|
34
|
+
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); }; }
|
|
35
|
+
|
|
36
|
+
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); }
|
|
37
|
+
|
|
38
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
+
|
|
40
|
+
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; } }
|
|
41
|
+
|
|
42
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
|
+
|
|
44
|
+
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
45
|
+
function adopt(value) {
|
|
46
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
47
|
+
resolve(value);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
52
|
+
function fulfilled(value) {
|
|
53
|
+
try {
|
|
54
|
+
step(generator.next(value));
|
|
55
|
+
} catch (e) {
|
|
56
|
+
reject(e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function rejected(value) {
|
|
61
|
+
try {
|
|
62
|
+
step(generator["throw"](value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function step(result) {
|
|
69
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
var defaultCenter = {
|
|
77
|
+
lng: 116.404,
|
|
78
|
+
lat: 39.915
|
|
79
|
+
};
|
|
80
|
+
exports.defaultCenter = defaultCenter;
|
|
81
|
+
var defaultZoom = 15;
|
|
82
|
+
/**
|
|
83
|
+
* 原始的百度地图组件
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
exports.defaultZoom = defaultZoom;
|
|
87
|
+
|
|
88
|
+
var InternalBMap = /*#__PURE__*/function (_React$Component) {
|
|
89
|
+
_inherits(InternalBMap, _React$Component);
|
|
90
|
+
|
|
91
|
+
var _super = _createSuper(InternalBMap);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 构造函数
|
|
95
|
+
* @param {InternalBMapProps} props
|
|
96
|
+
*/
|
|
97
|
+
function InternalBMap(props) {
|
|
98
|
+
var _this;
|
|
99
|
+
|
|
100
|
+
_classCallCheck(this, InternalBMap);
|
|
101
|
+
|
|
102
|
+
_this = _super.call(this, props);
|
|
103
|
+
_this.state = {
|
|
104
|
+
map: null
|
|
105
|
+
};
|
|
106
|
+
_this.containerRef = null;
|
|
107
|
+
return _this;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 钩子函数, 做一些初始化数据
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
_createClass(InternalBMap, [{
|
|
115
|
+
key: "componentDidMount",
|
|
116
|
+
value: function componentDidMount() {
|
|
117
|
+
this.init();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 在状态变更的时候变更地图信息
|
|
121
|
+
* @param {InternalBMapProps} prevProps
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
}, {
|
|
125
|
+
key: "componentDidUpdate",
|
|
126
|
+
value: function componentDidUpdate(prevProps) {
|
|
127
|
+
var _this$props = this.props,
|
|
128
|
+
center = _this$props.center,
|
|
129
|
+
zoom = _this$props.zoom;
|
|
130
|
+
|
|
131
|
+
if (prevProps.center !== center && this.mapInstance) {
|
|
132
|
+
var lng = center.lng,
|
|
133
|
+
lat = center.lat;
|
|
134
|
+
this.mapInstance.customSetMapCenter(lng, lat);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (prevProps.zoom !== zoom && this.mapInstance && this.mapInstance.getZoom() !== zoom) {
|
|
138
|
+
this.mapInstance.setZoom(zoom);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 1. 加载百度地图需要的js文件
|
|
143
|
+
* 2. 向百度地图示例上挂载一些自定义函数, 便于操作
|
|
144
|
+
* 3. 初始化百度地图示例
|
|
145
|
+
* @return {void}
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
}, {
|
|
149
|
+
key: "init",
|
|
150
|
+
value: function init() {
|
|
151
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
152
|
+
var _this$props2, center, zoom, onCreate, onZoomChange, map, localSearch, geocoder, point;
|
|
153
|
+
|
|
154
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
155
|
+
while (1) {
|
|
156
|
+
switch (_context.prev = _context.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
if (window.BMap) {
|
|
159
|
+
_context.next = 11;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
location.protocol == 'https:' ? window.HOST_TYPE = '2' : '';
|
|
164
|
+
_context.next = 4;
|
|
165
|
+
return _domUtil["default"].loadJavascript('//api.map.baidu.com/getscript?v=3.0&ak=42IughV5lDxAt0wI8AhDVuGR');
|
|
166
|
+
|
|
167
|
+
case 4:
|
|
168
|
+
_context.next = 6;
|
|
169
|
+
return _domUtil["default"].loadJavascript('//api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js');
|
|
170
|
+
|
|
171
|
+
case 6:
|
|
172
|
+
_context.next = 8;
|
|
173
|
+
return _domUtil["default"].loadJavascript('//api.map.baidu.com/library/LuShu/1.2/src/LuShu_min.js');
|
|
174
|
+
|
|
175
|
+
case 8:
|
|
176
|
+
_context.next = 10;
|
|
177
|
+
return _domUtil["default"].loadJavascript('//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js');
|
|
178
|
+
|
|
179
|
+
case 10:
|
|
180
|
+
// eslint-disable-next-line max-len
|
|
181
|
+
window.BMap.Map.prototype.customSetMapCenter = function customSetMapCenter(lng, lat) {
|
|
182
|
+
var point = new window.BMap.Point(lng, lat);
|
|
183
|
+
this.setCenter(point);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
case 11:
|
|
187
|
+
_this$props2 = this.props, center = _this$props2.center, zoom = _this$props2.zoom, onCreate = _this$props2.onCreate, onZoomChange = _this$props2.onZoomChange; // 1. 创建map实例
|
|
188
|
+
|
|
189
|
+
map = new window.BMap.Map(this.containerRef, {
|
|
190
|
+
enableMapClick: false
|
|
191
|
+
}); // 创建搜索工具, 使得可以直接使用map搜索
|
|
192
|
+
|
|
193
|
+
localSearch = function localSearch(keyword, callback) {
|
|
194
|
+
var searchInstance = new window.BMap.LocalSearch(map, {
|
|
195
|
+
// 智能搜索
|
|
196
|
+
onSearchComplete: callback
|
|
197
|
+
});
|
|
198
|
+
searchInstance.search(keyword);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
map.localSearch = localSearch; // 创建地址解析工具, 通过经纬度查询到位置信息
|
|
202
|
+
|
|
203
|
+
geocoder = function geocoder(point, callback) {
|
|
204
|
+
var myGeo = new window.BMap.Geocoder({
|
|
205
|
+
extensions_town: true
|
|
206
|
+
});
|
|
207
|
+
var lng = point.lng,
|
|
208
|
+
lat = point.lat; // 根据坐标得到地址描述
|
|
209
|
+
|
|
210
|
+
myGeo.getLocation(new window.BMap.Point(lng, lat), callback);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
map.geocoder = geocoder;
|
|
214
|
+
this.mapInstance = map;
|
|
215
|
+
this.setState({
|
|
216
|
+
map: this.mapInstance
|
|
217
|
+
}); // 2. 设置中心点
|
|
218
|
+
|
|
219
|
+
point = new window.BMap.Point(center === null || center === void 0 ? void 0 : center.lng, center === null || center === void 0 ? void 0 : center.lat);
|
|
220
|
+
map.centerAndZoom(point, zoom); // 3. 开启滚轮缩放
|
|
221
|
+
|
|
222
|
+
map.enableScrollWheelZoom(true);
|
|
223
|
+
|
|
224
|
+
if (onCreate) {
|
|
225
|
+
onCreate(map);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (onZoomChange) {
|
|
229
|
+
map.addEventListener('zoomend', function () {
|
|
230
|
+
var zoom = map.getZoom();
|
|
231
|
+
onZoomChange(zoom);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
case 24:
|
|
236
|
+
case "end":
|
|
237
|
+
return _context.stop();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, _callee, this);
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 渲染子节点, 并且向子元素的`props`自动填充`map`属性
|
|
245
|
+
* @return {React.ReactNode} node
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
}, {
|
|
249
|
+
key: "renderChildren",
|
|
250
|
+
value: function renderChildren() {
|
|
251
|
+
var children = this.props.children;
|
|
252
|
+
var map = this.state.map;
|
|
253
|
+
if (!children || !map) return;
|
|
254
|
+
return React.Children.map(children, function (child) {
|
|
255
|
+
if (!child) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (typeof child === 'string' || typeof child === 'number' || typeof child === 'boolean') {
|
|
260
|
+
return child;
|
|
261
|
+
} // 给子元素自动添加地图prop
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
265
|
+
map: map
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}, {
|
|
270
|
+
key: "render",
|
|
271
|
+
value: function render() {
|
|
272
|
+
var _this2 = this;
|
|
273
|
+
|
|
274
|
+
var _this$props3 = this.props,
|
|
275
|
+
className = _this$props3.className,
|
|
276
|
+
style = _this$props3.style;
|
|
277
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
278
|
+
className: (0, _classnames["default"])(className, 'eh-bmap'),
|
|
279
|
+
style: style,
|
|
280
|
+
ref: function ref(_ref) {
|
|
281
|
+
_this2.containerRef = _ref;
|
|
282
|
+
}
|
|
283
|
+
}, this.renderChildren());
|
|
284
|
+
}
|
|
285
|
+
}]);
|
|
286
|
+
|
|
287
|
+
return InternalBMap;
|
|
288
|
+
}(React.Component);
|
|
289
|
+
|
|
290
|
+
InternalBMap.defaultProps = {
|
|
291
|
+
center: defaultCenter,
|
|
292
|
+
zoom: defaultZoom
|
|
293
|
+
};
|
|
294
|
+
var _default = InternalBMap;
|
|
295
|
+
exports["default"] = _default;
|
|
296
|
+
//# sourceMappingURL=b-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b-map.js","names":["__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","Promise","reject","fulfilled","step","next","e","rejected","result","done","then","apply","defaultCenter","lng","lat","defaultZoom","InternalBMap","props","state","map","containerRef","init","prevProps","center","zoom","mapInstance","customSetMapCenter","getZoom","setZoom","window","BMap","location","protocol","HOST_TYPE","DomUtil","loadJavascript","Map","prototype","point","Point","setCenter","onCreate","onZoomChange","enableMapClick","localSearch","keyword","callback","searchInstance","LocalSearch","onSearchComplete","search","geocoder","myGeo","Geocoder","extensions_town","getLocation","setState","centerAndZoom","enableScrollWheelZoom","addEventListener","children","React","Children","child","cloneElement","className","style","createElement","classnames","ref","renderChildren","Component","defaultProps"],"sources":["b-map/b-map.js"],"sourcesContent":["var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as React from 'react';\nimport classnames from 'classnames';\nimport DomUtil from '../utils/dom-util';\nexport const defaultCenter = { lng: 116.404, lat: 39.915 };\nexport const defaultZoom = 15;\n/**\n * 原始的百度地图组件\n */\nclass InternalBMap extends React.Component {\n /**\n * 构造函数\n * @param {InternalBMapProps} props\n */\n constructor(props) {\n super(props);\n this.state = {\n map: null,\n };\n this.containerRef = null;\n }\n /**\n * 钩子函数, 做一些初始化数据\n */\n componentDidMount() {\n this.init();\n }\n /**\n * 在状态变更的时候变更地图信息\n * @param {InternalBMapProps} prevProps\n */\n componentDidUpdate(prevProps) {\n const { center, zoom } = this.props;\n if (prevProps.center !== center && this.mapInstance) {\n const { lng, lat } = center;\n this.mapInstance.customSetMapCenter(lng, lat);\n }\n if (prevProps.zoom !== zoom\n && this.mapInstance\n && this.mapInstance.getZoom() !== zoom) {\n this.mapInstance.setZoom(zoom);\n }\n }\n /**\n * 1. 加载百度地图需要的js文件\n * 2. 向百度地图示例上挂载一些自定义函数, 便于操作\n * 3. 初始化百度地图示例\n * @return {void}\n */\n init() {\n return __awaiter(this, void 0, void 0, function* () {\n if (!window.BMap) {\n location.protocol == 'https:' ? (window.HOST_TYPE = '2') : '';\n yield DomUtil.loadJavascript('//api.map.baidu.com/getscript?v=3.0&ak=42IughV5lDxAt0wI8AhDVuGR');\n yield DomUtil.loadJavascript('//api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js');\n yield DomUtil.loadJavascript('//api.map.baidu.com/library/LuShu/1.2/src/LuShu_min.js');\n yield DomUtil.loadJavascript('//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js');\n // eslint-disable-next-line max-len\n window.BMap.Map.prototype.customSetMapCenter = function customSetMapCenter(lng, lat) {\n const point = new window.BMap.Point(lng, lat);\n this.setCenter(point);\n };\n }\n const { center, zoom, onCreate, onZoomChange } = this.props;\n // 1. 创建map实例\n const map = new window.BMap.Map(this.containerRef, {\n enableMapClick: false,\n });\n // 创建搜索工具, 使得可以直接使用map搜索\n const localSearch = (keyword, callback) => {\n const searchInstance = new window.BMap.LocalSearch(map, {\n // 智能搜索\n onSearchComplete: callback,\n });\n searchInstance.search(keyword);\n };\n map.localSearch = localSearch;\n // 创建地址解析工具, 通过经纬度查询到位置信息\n const geocoder = (point, callback) => {\n const myGeo = new window.BMap.Geocoder({\n extensions_town: true,\n });\n const { lng, lat } = point;\n // 根据坐标得到地址描述\n myGeo.getLocation(new window.BMap.Point(lng, lat), callback);\n };\n map.geocoder = geocoder;\n this.mapInstance = map;\n this.setState({ map: this.mapInstance });\n // 2. 设置中心点\n const point = new window.BMap.Point(center === null || center === void 0 ? void 0 : center.lng, center === null || center === void 0 ? void 0 : center.lat);\n map.centerAndZoom(point, zoom);\n // 3. 开启滚轮缩放\n map.enableScrollWheelZoom(true);\n if (onCreate) {\n onCreate(map);\n }\n if (onZoomChange) {\n map.addEventListener('zoomend', function () {\n const zoom = map.getZoom();\n onZoomChange(zoom);\n });\n }\n });\n }\n /**\n * 渲染子节点, 并且向子元素的`props`自动填充`map`属性\n * @return {React.ReactNode} node\n */\n renderChildren() {\n const { children } = this.props;\n const { map } = this.state;\n if (!children || !map)\n return;\n return React.Children.map(children, (child) => {\n if (!child) {\n return;\n }\n if (typeof child === 'string'\n || typeof child === 'number'\n || typeof child === 'boolean') {\n return child;\n }\n // 给子元素自动添加地图prop\n return React.cloneElement(child, {\n map,\n });\n });\n }\n render() {\n const { className, style } = this.props;\n return (React.createElement(\"div\", { className: classnames(className, 'eh-bmap'), style: style, ref: (ref) => {\n this.containerRef = ref;\n } }, this.renderChildren()));\n }\n}\nInternalBMap.defaultPro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D,IAApB;QACH;MAF8B,CAA3B,EAEC,KAAKC,cAAL,EAFD,CAAR;IAGH;;;;EA7HsBT,KAAK,CAACU,S;;AA+HjCvD,YAAY,CAACwD,YAAb,GAA4B;EACxBjD,MAAM,EAAEX,aADgB;EAExBY,IAAI,EAAET;AAFkB,CAA5B;eAIeC,Y"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Point } from './b-map';
|
|
2
|
+
declare const _default: (BMapOverlay: typeof window.BMap.Overlay) => {
|
|
3
|
+
new (point: Point, content: HTMLElement, options?: any): {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
options: any;
|
|
6
|
+
point: typeof window.BMap.Point;
|
|
7
|
+
content: HTMLElement;
|
|
8
|
+
initialize(map: any): HTMLDivElement;
|
|
9
|
+
draw(): void;
|
|
10
|
+
};
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,84 @@
|
|
|
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); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
|
|
12
|
+
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); } }
|
|
13
|
+
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
|
+
|
|
20
|
+
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); }; }
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
+
|
|
26
|
+
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; } }
|
|
27
|
+
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
+
|
|
30
|
+
var _default = function _default(BMapOverlay) {
|
|
31
|
+
return /*#__PURE__*/function (_BMapOverlay) {
|
|
32
|
+
_inherits(CustomOverlay, _BMapOverlay);
|
|
33
|
+
|
|
34
|
+
var _super = _createSuper(CustomOverlay);
|
|
35
|
+
|
|
36
|
+
function CustomOverlay(point, content, options) {
|
|
37
|
+
var _this;
|
|
38
|
+
|
|
39
|
+
_classCallCheck(this, CustomOverlay);
|
|
40
|
+
|
|
41
|
+
_this = _super.call(this);
|
|
42
|
+
_this.point = new window.BMap.Point(point.lng, point.lat);
|
|
43
|
+
_this.content = content;
|
|
44
|
+
_this.options = options || {};
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_createClass(CustomOverlay, [{
|
|
49
|
+
key: "initialize",
|
|
50
|
+
value: function initialize(map) {
|
|
51
|
+
this.map = map;
|
|
52
|
+
var div = document.createElement('div');
|
|
53
|
+
this.div = div;
|
|
54
|
+
div.setAttribute('tag', 'customoverlay');
|
|
55
|
+
div.style.position = 'absolute';
|
|
56
|
+
div.style.zIndex = this.options.zIndex || window.BMap.Overlay.getZIndex(this.point.lat);
|
|
57
|
+
div.addEventListener('touchstart', function (e) {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
});
|
|
60
|
+
div.addEventListener('touchend', function (e) {
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
});
|
|
63
|
+
div.appendChild(this.content);
|
|
64
|
+
var pane = this.options.pane || 'labelPane';
|
|
65
|
+
map.getPanes()[pane].appendChild(div);
|
|
66
|
+
return div;
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "draw",
|
|
70
|
+
value: function draw() {
|
|
71
|
+
var map = this.map;
|
|
72
|
+
var pixel = map.pointToOverlayPixel(this.point);
|
|
73
|
+
var offset = this.options.offset || new window.BMap.Size(0, 0);
|
|
74
|
+
this.div.style.left = "".concat(pixel.x + offset.width, "px");
|
|
75
|
+
this.div.style.top = "".concat(pixel.y + offset.height, "px");
|
|
76
|
+
}
|
|
77
|
+
}]);
|
|
78
|
+
|
|
79
|
+
return CustomOverlay;
|
|
80
|
+
}(BMapOverlay);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
exports["default"] = _default;
|
|
84
|
+
//# sourceMappingURL=custom-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-overlay.js","names":["BMapOverlay","point","content","options","window","BMap","Point","lng","lat","map","div","document","createElement","setAttribute","style","position","zIndex","Overlay","getZIndex","addEventListener","e","stopPropagation","appendChild","pane","getPanes","pixel","pointToOverlayPixel","offset","Size","left","x","width","top","y","height"],"sources":["b-map/custom-overlay.js"],"sourcesContent":["export default (BMapOverlay) => class CustomOverlay extends BMapOverlay {\n constructor(point, content, options) {\n super();\n this.point = new window.BMap.Point(point.lng, point.lat);\n this.content = content;\n this.options = options || {};\n }\n initialize(map) {\n this.map = map;\n const div = document.createElement('div');\n this.div = div;\n div.setAttribute('tag', 'customoverlay');\n div.style.position = 'absolute';\n div.style.zIndex\n = this.options.zIndex\n || window.BMap.Overlay.getZIndex(this.point.lat);\n div.addEventListener('touchstart', (e) => {\n e.stopPropagation();\n });\n div.addEventListener('touchend', (e) => {\n e.stopPropagation();\n });\n div.appendChild(this.content);\n const pane = this.options.pane || 'labelPane';\n map.getPanes()[pane].appendChild(div);\n return div;\n }\n draw() {\n const { map } = this;\n const pixel = map.pointToOverlayPixel(this.point);\n const offset = this.options.offset || new window.BMap.Size(0, 0);\n this.div.style.left = `${pixel.x + offset.width}px`;\n this.div.style.top = `${pixel.y + offset.height}px`;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAAe,kBAACA,WAAD;EAAA;IAAA;;IAAA;;IACX,uBAAYC,KAAZ,EAAmBC,OAAnB,EAA4BC,OAA5B,EAAqC;MAAA;;MAAA;;MACjC;MAC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QACA,IAAM0B,MAAM,GAAG,KAAKxB,OAAL,CAAawB,MAAb,IAAuB,IAAIvB,MAAM,CAACC,IAAP,CAAYuB,IAAhB,CAAqB,CAArB,EAAwB,CAAxB,CAAtC;QACA,KAAKlB,GAAL,CAASI,KAAT,CAAee,IAAf,aAAyBJ,KAAK,CAACK,CAAN,GAAUH,MAAM,CAACI,KAA1C;QACA,KAAKrB,GAAL,CAASI,KAAT,CAAekB,GAAf,aAAwBP,KAAK,CAACQ,CAAN,GAAUN,MAAM,CAACO,MAAzC;MACH;IAjCU;;IAAA;EAAA,EAA6ClC,WAA7C;AAAA,C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DrawControls {
|
|
3
|
+
clear: () => any;
|
|
4
|
+
}
|
|
5
|
+
export interface DrawingProps {
|
|
6
|
+
map?: any;
|
|
7
|
+
/**
|
|
8
|
+
* 当完成多边形绘制的回调
|
|
9
|
+
*/
|
|
10
|
+
onOverlayComplete?: (e: any) => any;
|
|
11
|
+
onCreate?: (drawingManager: typeof window.BMapLib.DrawingManager) => any;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: React.ForwardRefExoticComponent<DrawingProps & React.RefAttributes<DrawControls>>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
|
|
14
|
+
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); }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
19
|
+
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
+
|
|
22
|
+
var Drawing = function Drawing(props, ref) {
|
|
23
|
+
var _useState = (0, _react.useState)(),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
drawingManager = _useState2[0],
|
|
26
|
+
setDrawingManager = _useState2[1];
|
|
27
|
+
|
|
28
|
+
var map = props.map,
|
|
29
|
+
onCreate = props.onCreate,
|
|
30
|
+
onOverlayComplete = props.onOverlayComplete;
|
|
31
|
+
(0, _react.useEffect)(function () {
|
|
32
|
+
var drawingManager = new window.BMapLib.DrawingManager(map, {
|
|
33
|
+
isOpen: true,
|
|
34
|
+
polygonOptions: {
|
|
35
|
+
enableEditing: true,
|
|
36
|
+
strokeColor: '#1890ff',
|
|
37
|
+
strokeWeight: 2
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
drawingManager.setDrawingMode(window.BMAP_DRAWING_POLYGON);
|
|
41
|
+
drawingManager.addEventListener('overlaycomplete', function (e) {
|
|
42
|
+
// 补充额外的属性, 便于使用map.removeOverlay方法删除
|
|
43
|
+
e.overlay.type = 'draw';
|
|
44
|
+
onOverlayComplete && onOverlayComplete(e);
|
|
45
|
+
});
|
|
46
|
+
setDrawingManager(drawingManager);
|
|
47
|
+
onCreate && onCreate(drawingManager);
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
var getDrawOverlay = function getDrawOverlay() {
|
|
51
|
+
var overlays = map.getOverlays();
|
|
52
|
+
return (overlays || []).find(function (item) {
|
|
53
|
+
return item.type === 'draw';
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
58
|
+
return {
|
|
59
|
+
clear: function clear() {
|
|
60
|
+
var drawArea = getDrawOverlay();
|
|
61
|
+
map.removeOverlay(drawArea);
|
|
62
|
+
drawingManager === null || drawingManager === void 0 ? void 0 : drawingManager.close();
|
|
63
|
+
drawingManager === null || drawingManager === void 0 ? void 0 : drawingManager.open();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var _default = /*#__PURE__*/(0, _react.forwardRef)(Drawing);
|
|
71
|
+
|
|
72
|
+
exports["default"] = _default;
|
|
73
|
+
//# sourceMappingURL=drawing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawing.js","names":["Drawing","props","ref","useState","drawingManager","setDrawingManager","map","onCreate","onOverlayComplete","useEffect","window","BMapLib","DrawingManager","isOpen","polygonOptions","enableEditing","strokeColor","strokeWeight","setDrawingMode","BMAP_DRAWING_POLYGON","addEventListener","e","overlay","type","getDrawOverlay","overlays","getOverlays","find","item","useImperativeHandle","clear","drawArea","removeOverlay","close","open","forwardRef"],"sources":["b-map/drawing.js"],"sourcesContent":["import { forwardRef, useEffect, useImperativeHandle, useState, } from 'react';\nconst Drawing = (props, ref) => {\n const [drawingManager, setDrawingManager] = useState();\n const { map, onCreate, onOverlayComplete } = props;\n useEffect(() => {\n const drawingManager = new window.BMapLib.DrawingManager(map, {\n isOpen: true,\n polygonOptions: {\n enableEditing: true,\n strokeColor: '#1890ff',\n strokeWeight: 2,\n },\n });\n drawingManager.setDrawingMode(window.BMAP_DRAWING_POLYGON);\n drawingManager.addEventListener('overlaycomplete', (e) => {\n // 补充额外的属性, 便于使用map.removeOverlay方法删除\n e.overlay.type = 'draw';\n onOverlayComplete && onOverlayComplete(e);\n });\n setDrawingManager(drawingManager);\n onCreate && onCreate(drawingManager);\n }, []);\n const getDrawOverlay = () => {\n const overlays = map.getOverlays();\n return (overlays || []).find((item) => item.type === 'draw');\n };\n useImperativeHandle(ref, () => ({\n clear: () => {\n const drawArea = getDrawOverlay();\n map.removeOverlay(drawArea);\n drawingManager === null || drawingManager === void 0 ? void 0 : drawingManager.close();\n drawingManager === null || drawingManager === void 0 ? void 0 : drawingManager.open();\n },\n }));\n return null;\n};\nexport default forwardRef(Drawing);\n"],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;AACA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,GAAR,EAAgB;EAC5B,gBAA4C,IAAAC,eAAA,GAA5C;EAAA;EAAA,IAAOC,cAAP;EAAA,IAAuBC,iBAAvB;;EACA,IAAQC,GAAR,GAA6CL,KAA7C,CAAQK,GAAR;EAAA,IAAaC,QAAb,GAA6CN,KAA7C,CAAaM,QAAb;EAAA,IAAuBC,iBAAvB,GAA6CP,KAA7C,CAAuBO,iBAAvB;EACA,IAAAC,gBAAA,EAAU,YAAM;IACZ,IAAML,cAAc,GAAG,IAAIM,MAAM,CAACC,OAAP,CAAeC,cAAnB,CAAkCN,GAAlC,EAAuC;MAC1DO,MAAM,EAAE,IADkD;MAE1D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1,17 @@
|
|
|
1
|
+
import InternalBMap, { Point, InternalBMapProps } from './b-map';
|
|
2
|
+
import Marker from './marker';
|
|
3
|
+
import Drawing from './drawing';
|
|
4
|
+
import Polygon from './polygon';
|
|
5
|
+
import MarkerClusterer from './marker-clusterer';
|
|
6
|
+
declare type InternalBMapT = typeof InternalBMap;
|
|
7
|
+
interface BMapI extends InternalBMapT {
|
|
8
|
+
defaultCenter: Point;
|
|
9
|
+
defaultZoom: number;
|
|
10
|
+
Marker: typeof Marker;
|
|
11
|
+
Polygon: typeof Polygon;
|
|
12
|
+
Drawing: typeof Drawing;
|
|
13
|
+
MarkerClusterer: typeof MarkerClusterer;
|
|
14
|
+
}
|
|
15
|
+
declare const BMap: BMapI;
|
|
16
|
+
export default BMap;
|
|
17
|
+
export { Point, InternalBMapProps };
|