@antv/l7-component 2.9.32-alpha.1 → 2.9.32-alpha.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/package.json +8 -5
- package/es/control/BaseControl.d.ts +0 -27
- package/es/control/BaseControl.js +0 -134
- package/es/control/layer.d.ts +0 -38
- package/es/control/layer.js +0 -340
- package/es/control/logo.d.ts +0 -9
- package/es/control/logo.js +0 -57
- package/es/control/scale.d.ts +0 -24
- package/es/control/scale.js +0 -148
- package/es/control/zoom.d.ts +0 -24
- package/es/control/zoom.js +0 -119
- package/es/css/l7.css +0 -502
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +0 -1
- package/es/images/logo.png +0 -0
- package/es/index.d.ts +0 -11
- package/es/index.js +0 -53
- package/es/interface.d.ts +0 -37
- package/es/interface.js +0 -1
- package/es/marker-layer.d.ts +0 -53
- package/es/marker-layer.js +0 -363
- package/es/marker.d.ts +0 -49
- package/es/marker.js +0 -434
- package/es/popup.d.ts +0 -35
- package/es/popup.js +0 -300
- package/es/utils/anchor.d.ts +0 -22
- package/es/utils/anchor.js +0 -35
- package/lib/control/BaseControl.js +0 -110
- package/lib/control/layer.js +0 -269
- package/lib/control/logo.js +0 -54
- package/lib/control/scale.js +0 -119
- package/lib/control/zoom.js +0 -101
- package/lib/css/l7.css +0 -502
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +0 -1
- package/lib/images/logo.png +0 -0
- package/lib/index.js +0 -56
- package/lib/interface.js +0 -17
- package/lib/marker-layer.js +0 -263
- package/lib/marker.js +0 -307
- package/lib/popup.js +0 -216
- package/lib/utils/anchor.js +0 -63
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-component",
|
|
3
|
-
"version": "2.9.32-alpha.
|
|
3
|
+
"version": "2.9.32-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"tsc": "tsc --project tsconfig.build.json",
|
|
16
|
+
"less": "lessc src/css/index.less src/css/index.css",
|
|
16
17
|
"clean": "rimraf dist; rimraf es; rimraf lib;",
|
|
17
18
|
"build": "father build",
|
|
18
19
|
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
"author": "lzxue",
|
|
26
27
|
"license": "ISC",
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@antv/l7-core": "2.9.32-alpha.
|
|
29
|
-
"@antv/l7-utils": "2.9.32-alpha.
|
|
29
|
+
"@antv/l7-core": "2.9.32-alpha.3",
|
|
30
|
+
"@antv/l7-utils": "2.9.32-alpha.3",
|
|
30
31
|
"@babel/runtime": "^7.7.7",
|
|
31
32
|
"eventemitter3": "^4.0.0",
|
|
32
33
|
"inversify": "^5.0.1",
|
|
@@ -35,9 +36,11 @@
|
|
|
35
36
|
"supercluster": "^7.0.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@antv/l7-test-utils": "2.9.32-alpha.
|
|
39
|
+
"@antv/l7-test-utils": "2.9.32-alpha.3",
|
|
40
|
+
"gcoord": "^0.3.2",
|
|
41
|
+
"less": "^4.1.3"
|
|
39
42
|
},
|
|
40
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "933f97b7f72989a523c164677235546838b476bf",
|
|
41
44
|
"publishConfig": {
|
|
42
45
|
"access": "public"
|
|
43
46
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { IControlOption, IControlService, ILayerService, IMapService, IRendererService, PositionType } from '@antv/l7-core';
|
|
2
|
-
import { EventEmitter } from 'eventemitter3';
|
|
3
|
-
import { Container } from 'inversify';
|
|
4
|
-
export { PositionType } from '@antv/l7-core';
|
|
5
|
-
export default class Control extends EventEmitter {
|
|
6
|
-
controlOption: IControlOption;
|
|
7
|
-
protected container: HTMLElement;
|
|
8
|
-
protected sceneContainer: Container;
|
|
9
|
-
protected mapsService: IMapService;
|
|
10
|
-
protected renderService: IRendererService;
|
|
11
|
-
protected layerService: ILayerService;
|
|
12
|
-
protected controlService: IControlService;
|
|
13
|
-
private isShow;
|
|
14
|
-
constructor(cfg?: Partial<IControlOption>);
|
|
15
|
-
getDefault(): {
|
|
16
|
-
position: PositionType;
|
|
17
|
-
name: string;
|
|
18
|
-
};
|
|
19
|
-
setPosition(position?: PositionType): this;
|
|
20
|
-
addTo(sceneContainer: Container): this;
|
|
21
|
-
onAdd(): HTMLElement;
|
|
22
|
-
onRemove(): void;
|
|
23
|
-
hide(): void;
|
|
24
|
-
show(): void;
|
|
25
|
-
remove(): this | undefined;
|
|
26
|
-
_refocusOnMap(e: MouseEvent): void;
|
|
27
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
|
|
8
|
-
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); }; }
|
|
9
|
-
|
|
10
|
-
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; } }
|
|
11
|
-
|
|
12
|
-
import { PositionType, TYPES } from '@antv/l7-core';
|
|
13
|
-
import { DOM } from '@antv/l7-utils';
|
|
14
|
-
import { EventEmitter } from 'eventemitter3';
|
|
15
|
-
export { PositionType } from '@antv/l7-core';
|
|
16
|
-
var controlId = 0;
|
|
17
|
-
|
|
18
|
-
var Control = /*#__PURE__*/function (_EventEmitter) {
|
|
19
|
-
_inherits(Control, _EventEmitter);
|
|
20
|
-
|
|
21
|
-
var _super = _createSuper(Control);
|
|
22
|
-
|
|
23
|
-
function Control(cfg) {
|
|
24
|
-
var _this;
|
|
25
|
-
|
|
26
|
-
_classCallCheck(this, Control);
|
|
27
|
-
|
|
28
|
-
_this = _super.call(this);
|
|
29
|
-
_this.controlOption = _objectSpread(_objectSpread({}, _this.getDefault()), cfg || {});
|
|
30
|
-
return _this;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
_createClass(Control, [{
|
|
34
|
-
key: "getDefault",
|
|
35
|
-
value: function getDefault() {
|
|
36
|
-
return {
|
|
37
|
-
position: PositionType.TOPRIGHT,
|
|
38
|
-
name: "".concat(controlId++)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
key: "setPosition",
|
|
43
|
-
value: function setPosition() {
|
|
44
|
-
var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PositionType.BOTTOMRIGHT;
|
|
45
|
-
// 考虑组件的自动布局,需要销毁重建
|
|
46
|
-
var controlService = this.controlService;
|
|
47
|
-
|
|
48
|
-
if (controlService) {
|
|
49
|
-
controlService.removeControl(this);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.controlOption.position = position;
|
|
53
|
-
|
|
54
|
-
if (controlService) {
|
|
55
|
-
controlService.addControl(this, this.sceneContainer);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "addTo",
|
|
62
|
-
value: function addTo(sceneContainer) {
|
|
63
|
-
this.mapsService = sceneContainer.get(TYPES.IMapService);
|
|
64
|
-
this.renderService = sceneContainer.get(TYPES.IRendererService);
|
|
65
|
-
this.layerService = sceneContainer.get(TYPES.ILayerService);
|
|
66
|
-
this.controlService = sceneContainer.get(TYPES.IControlService);
|
|
67
|
-
this.sceneContainer = sceneContainer;
|
|
68
|
-
this.isShow = true;
|
|
69
|
-
this.container = this.onAdd();
|
|
70
|
-
var container = this.container;
|
|
71
|
-
var pos = this.controlOption.position;
|
|
72
|
-
var corner = this.controlService.controlCorners[pos];
|
|
73
|
-
DOM.addClass(container, 'l7-control');
|
|
74
|
-
|
|
75
|
-
if (pos.indexOf('bottom') !== -1) {
|
|
76
|
-
corner.insertBefore(container, corner.firstChild);
|
|
77
|
-
} else {
|
|
78
|
-
corner.appendChild(container);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "onAdd",
|
|
85
|
-
value: function onAdd() {
|
|
86
|
-
throw new Error('Method not implemented.');
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "onRemove",
|
|
90
|
-
value: function onRemove() {
|
|
91
|
-
throw new Error('Method not implemented.');
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "hide",
|
|
95
|
-
value: function hide() {
|
|
96
|
-
var container = this.container;
|
|
97
|
-
DOM.addClass(container, 'l7-control-hide');
|
|
98
|
-
this.isShow = false;
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "show",
|
|
102
|
-
value: function show() {
|
|
103
|
-
var container = this.container;
|
|
104
|
-
DOM.removeClass(container, 'l7-control-hide');
|
|
105
|
-
this.isShow = true;
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "remove",
|
|
109
|
-
value: function remove() {
|
|
110
|
-
if (!this.mapsService) {
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
DOM.remove(this.container);
|
|
115
|
-
this.onRemove();
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "_refocusOnMap",
|
|
119
|
-
value: function _refocusOnMap(e) {
|
|
120
|
-
// if map exists and event is not a keyboard event
|
|
121
|
-
if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
|
|
122
|
-
var container = this.mapsService.getContainer();
|
|
123
|
-
|
|
124
|
-
if (container !== null) {
|
|
125
|
-
container.focus();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}]);
|
|
130
|
-
|
|
131
|
-
return Control;
|
|
132
|
-
}(EventEmitter);
|
|
133
|
-
|
|
134
|
-
export { Control as default };
|
package/es/control/layer.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { PositionType } from '@antv/l7-core';
|
|
2
|
-
import { ILayerControlOption } from '../interface';
|
|
3
|
-
import Control from './BaseControl';
|
|
4
|
-
export default class Layers extends Control {
|
|
5
|
-
private layerControlInputs;
|
|
6
|
-
private layers;
|
|
7
|
-
private lastZIndex;
|
|
8
|
-
private handlingClick;
|
|
9
|
-
private layersLink;
|
|
10
|
-
private baseLayersList;
|
|
11
|
-
private separator;
|
|
12
|
-
private overlaysList;
|
|
13
|
-
private form;
|
|
14
|
-
constructor(cfg: Partial<ILayerControlOption>);
|
|
15
|
-
getDefault(): {
|
|
16
|
-
collapsed: boolean;
|
|
17
|
-
position: PositionType;
|
|
18
|
-
autoZIndex: boolean;
|
|
19
|
-
hideSingleBase: boolean;
|
|
20
|
-
sortLayers: boolean;
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
onAdd(): HTMLElement;
|
|
24
|
-
addVisualLayer(layer: any, name: string | number): this;
|
|
25
|
-
expand(): this;
|
|
26
|
-
collapse(): this;
|
|
27
|
-
onRemove(): void;
|
|
28
|
-
private initLayout;
|
|
29
|
-
private initLayers;
|
|
30
|
-
private update;
|
|
31
|
-
private checkDisabledLayers;
|
|
32
|
-
private addLayer;
|
|
33
|
-
private expandIfNotCollapsed;
|
|
34
|
-
private onLayerChange;
|
|
35
|
-
private createRadioElement;
|
|
36
|
-
private addItem;
|
|
37
|
-
private onInputClick;
|
|
38
|
-
}
|
package/es/control/layer.js
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
|
|
8
|
-
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); }; }
|
|
9
|
-
|
|
10
|
-
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; } }
|
|
11
|
-
|
|
12
|
-
import { PositionType } from '@antv/l7-core';
|
|
13
|
-
import { bindAll, DOM } from '@antv/l7-utils';
|
|
14
|
-
import Control from "./BaseControl";
|
|
15
|
-
|
|
16
|
-
var Layers = /*#__PURE__*/function (_Control) {
|
|
17
|
-
_inherits(Layers, _Control);
|
|
18
|
-
|
|
19
|
-
var _super = _createSuper(Layers);
|
|
20
|
-
|
|
21
|
-
function Layers(cfg) {
|
|
22
|
-
var _this;
|
|
23
|
-
|
|
24
|
-
_classCallCheck(this, Layers);
|
|
25
|
-
|
|
26
|
-
_this = _super.call(this, cfg);
|
|
27
|
-
_this.layerControlInputs = [];
|
|
28
|
-
_this.layers = [];
|
|
29
|
-
_this.lastZIndex = 0;
|
|
30
|
-
_this.handlingClick = false;
|
|
31
|
-
|
|
32
|
-
_this.initLayers();
|
|
33
|
-
|
|
34
|
-
bindAll(['checkDisabledLayers', 'onLayerChange', 'collapse', 'extend', 'expand', 'onInputClick'], _assertThisInitialized(_this));
|
|
35
|
-
return _this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
_createClass(Layers, [{
|
|
39
|
-
key: "getDefault",
|
|
40
|
-
value: function getDefault() {
|
|
41
|
-
return {
|
|
42
|
-
collapsed: true,
|
|
43
|
-
position: PositionType.TOPRIGHT,
|
|
44
|
-
autoZIndex: true,
|
|
45
|
-
hideSingleBase: false,
|
|
46
|
-
sortLayers: false,
|
|
47
|
-
name: 'layers'
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}, {
|
|
51
|
-
key: "onAdd",
|
|
52
|
-
value: function onAdd() {
|
|
53
|
-
var _this2 = this;
|
|
54
|
-
|
|
55
|
-
this.initLayout();
|
|
56
|
-
this.update();
|
|
57
|
-
this.mapsService.on('zoomend', this.checkDisabledLayers);
|
|
58
|
-
this.layers.forEach(function (layerItem) {
|
|
59
|
-
layerItem.layer.on('remove', _this2.onLayerChange);
|
|
60
|
-
layerItem.layer.on('add', _this2.onLayerChange);
|
|
61
|
-
});
|
|
62
|
-
return this.container;
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "addVisualLayer",
|
|
66
|
-
value: function addVisualLayer(layer, name) {
|
|
67
|
-
this.addLayer(layer, name, true);
|
|
68
|
-
return this.mapsService ? this.update() : this;
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "expand",
|
|
72
|
-
value: function expand() {
|
|
73
|
-
var _this$renderService$g = this.renderService.getViewportSize(),
|
|
74
|
-
height = _this$renderService$g.height;
|
|
75
|
-
|
|
76
|
-
DOM.addClass(this.container, 'l7-control-layers-expanded');
|
|
77
|
-
this.form.style.height = 'null';
|
|
78
|
-
var acceptableHeight = height - (this.container.offsetTop + 50);
|
|
79
|
-
|
|
80
|
-
if (acceptableHeight < this.form.clientHeight) {
|
|
81
|
-
DOM.addClass(this.form, 'l7-control-layers-scrollbar');
|
|
82
|
-
this.form.style.height = acceptableHeight + 'px';
|
|
83
|
-
} else {
|
|
84
|
-
DOM.removeClass(this.form, 'l7-control-layers-scrollbar');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.checkDisabledLayers();
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "collapse",
|
|
92
|
-
value: function collapse() {
|
|
93
|
-
DOM.removeClass(this.container, 'l7-control-layers-expanded');
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "onRemove",
|
|
98
|
-
value: function onRemove() {
|
|
99
|
-
var _this3 = this;
|
|
100
|
-
|
|
101
|
-
if (!this.mapsService) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this.mapsService.off('click', this.collapse);
|
|
106
|
-
this.layers.forEach(function (layerItem) {
|
|
107
|
-
layerItem.layer.off('remove', _this3.onLayerChange);
|
|
108
|
-
layerItem.layer.off('add', _this3.onLayerChange);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}, {
|
|
112
|
-
key: "initLayout",
|
|
113
|
-
value: function initLayout() {
|
|
114
|
-
var className = 'l7-control-layers';
|
|
115
|
-
var container = this.container = DOM.create('div', className);
|
|
116
|
-
var collapsed = this.controlOption.collapsed; // makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released
|
|
117
|
-
|
|
118
|
-
container.setAttribute('aria-haspopup', 'true');
|
|
119
|
-
var form = this.form = DOM.create('form', className + '-list');
|
|
120
|
-
|
|
121
|
-
if (collapsed) {
|
|
122
|
-
this.mapsService.on('click', this.collapse);
|
|
123
|
-
container.addEventListener('mouseenter', this.expand);
|
|
124
|
-
container.addEventListener('mouseleave', this.collapse);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this.layersLink = DOM.create('a', className + '-toggle', container);
|
|
128
|
-
var link = this.layersLink; // link.href = '#';
|
|
129
|
-
|
|
130
|
-
link.title = 'Layers';
|
|
131
|
-
|
|
132
|
-
if (!collapsed) {
|
|
133
|
-
this.expand();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
this.baseLayersList = DOM.create('div', className + '-base', form);
|
|
137
|
-
this.separator = DOM.create('div', className + '-separator', form);
|
|
138
|
-
this.overlaysList = DOM.create('div', className + '-overlays', form);
|
|
139
|
-
container.appendChild(form);
|
|
140
|
-
}
|
|
141
|
-
}, {
|
|
142
|
-
key: "initLayers",
|
|
143
|
-
value: function initLayers() {
|
|
144
|
-
var _this4 = this;
|
|
145
|
-
|
|
146
|
-
var _this$controlOption = this.controlOption,
|
|
147
|
-
_this$controlOption$b = _this$controlOption.baseLayers,
|
|
148
|
-
baseLayers = _this$controlOption$b === void 0 ? {} : _this$controlOption$b,
|
|
149
|
-
_this$controlOption$o = _this$controlOption.overlayers,
|
|
150
|
-
overlayers = _this$controlOption$o === void 0 ? {} : _this$controlOption$o;
|
|
151
|
-
Object.keys(baseLayers).forEach(function (name) {
|
|
152
|
-
// baseLayers[name].once('inited', this.update);
|
|
153
|
-
_this4.addLayer(baseLayers[name], name, false);
|
|
154
|
-
});
|
|
155
|
-
Object.keys(overlayers).forEach(function (name) {
|
|
156
|
-
// overlayers[name].once('inited', this.update);
|
|
157
|
-
_this4.addLayer(overlayers[name], name, true);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "update",
|
|
162
|
-
value: function update() {
|
|
163
|
-
if (!this.container) {
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
DOM.empty(this.baseLayersList);
|
|
168
|
-
DOM.empty(this.overlaysList);
|
|
169
|
-
this.layerControlInputs = [];
|
|
170
|
-
var baseLayersPresent;
|
|
171
|
-
var overlaysPresent;
|
|
172
|
-
var i;
|
|
173
|
-
var obj;
|
|
174
|
-
var baseLayersCount = 0;
|
|
175
|
-
|
|
176
|
-
for (i = 0; i < this.layers.length; i++) {
|
|
177
|
-
obj = this.layers[i];
|
|
178
|
-
this.addItem(obj);
|
|
179
|
-
overlaysPresent = overlaysPresent || obj.overlay;
|
|
180
|
-
baseLayersPresent = baseLayersPresent || !obj.overlay;
|
|
181
|
-
baseLayersCount += !obj.overlay ? 1 : 0;
|
|
182
|
-
} // Hide base layers section if there's only one layer.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (this.controlOption.hideSingleBase) {
|
|
186
|
-
baseLayersPresent = baseLayersPresent && baseLayersCount > 1;
|
|
187
|
-
this.baseLayersList.style.display = baseLayersPresent ? '' : 'none';
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
this.separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';
|
|
191
|
-
return this;
|
|
192
|
-
}
|
|
193
|
-
}, {
|
|
194
|
-
key: "checkDisabledLayers",
|
|
195
|
-
value: function checkDisabledLayers() {
|
|
196
|
-
var inputs = this.layerControlInputs;
|
|
197
|
-
var input;
|
|
198
|
-
var layer;
|
|
199
|
-
var zoom = this.mapsService.getZoom();
|
|
200
|
-
|
|
201
|
-
for (var i = inputs.length - 1; i >= 0; i--) {
|
|
202
|
-
input = inputs[i];
|
|
203
|
-
layer = this.layerService.getLayer(input.layerId);
|
|
204
|
-
|
|
205
|
-
if (layer && layer.inited) {
|
|
206
|
-
var minZoom = layer.getMinZoom();
|
|
207
|
-
var maxZoom = layer.getMaxZoom();
|
|
208
|
-
input.disabled = zoom < minZoom || zoom > maxZoom;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}, {
|
|
213
|
-
key: "addLayer",
|
|
214
|
-
value: function addLayer(layer, name, overlay) {
|
|
215
|
-
if (this.mapsService) {
|
|
216
|
-
layer.on('add', this.onLayerChange);
|
|
217
|
-
layer.on('remove', this.onLayerChange);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
this.layers.push({
|
|
221
|
-
layer: layer,
|
|
222
|
-
name: name,
|
|
223
|
-
overlay: overlay
|
|
224
|
-
});
|
|
225
|
-
var _this$controlOption2 = this.controlOption,
|
|
226
|
-
sortLayers = _this$controlOption2.sortLayers,
|
|
227
|
-
sortFunction = _this$controlOption2.sortFunction,
|
|
228
|
-
autoZIndex = _this$controlOption2.autoZIndex;
|
|
229
|
-
|
|
230
|
-
if (sortLayers) {
|
|
231
|
-
this.layers.sort(function (a, b) {
|
|
232
|
-
return sortFunction(a.layer, b.layer, a.name, b.name);
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (autoZIndex && layer.setZIndex) {
|
|
237
|
-
this.lastZIndex++;
|
|
238
|
-
layer.setZIndex(this.lastZIndex);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
this.expandIfNotCollapsed();
|
|
242
|
-
}
|
|
243
|
-
}, {
|
|
244
|
-
key: "expandIfNotCollapsed",
|
|
245
|
-
value: function expandIfNotCollapsed() {
|
|
246
|
-
if (this.mapsService && !this.controlOption.collapsed) {
|
|
247
|
-
this.expand();
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return this;
|
|
251
|
-
}
|
|
252
|
-
}, {
|
|
253
|
-
key: "onLayerChange",
|
|
254
|
-
value: function onLayerChange(e) {
|
|
255
|
-
if (!this.handlingClick) {
|
|
256
|
-
this.update();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
var obj = this.layerService.getLayer(e.target.layerId); // @ts-ignore
|
|
260
|
-
|
|
261
|
-
var type = obj !== null && obj !== void 0 && obj.overlay ? e.type === 'add' ? 'overlayadd' : 'overlayremove' : e.type === 'add' ? 'baselayerchange' : null;
|
|
262
|
-
|
|
263
|
-
if (type) {
|
|
264
|
-
this.emit(type, obj);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}, {
|
|
268
|
-
key: "createRadioElement",
|
|
269
|
-
value: function createRadioElement(name, checked) {
|
|
270
|
-
var radioHtml = '<input type="radio" class="l7-control-layers-selector" name="' + name + '"' + (checked ? ' checked="checked"' : '') + '/>';
|
|
271
|
-
var radioFragment = document.createElement('div');
|
|
272
|
-
radioFragment.innerHTML = radioHtml;
|
|
273
|
-
return radioFragment.firstChild;
|
|
274
|
-
}
|
|
275
|
-
}, {
|
|
276
|
-
key: "addItem",
|
|
277
|
-
value: function addItem(obj) {
|
|
278
|
-
var label = document.createElement('label');
|
|
279
|
-
var layer = this.layerService.getLayer(obj.layer.id);
|
|
280
|
-
var checked = layer && layer.inited && obj.layer.isVisible();
|
|
281
|
-
var input;
|
|
282
|
-
|
|
283
|
-
if (obj.overlay) {
|
|
284
|
-
input = document.createElement('input');
|
|
285
|
-
input.type = 'checkbox';
|
|
286
|
-
input.className = 'l7-control-layers-selector';
|
|
287
|
-
input.defaultChecked = checked;
|
|
288
|
-
} else {
|
|
289
|
-
input = this.createRadioElement('l7-base-layers', checked);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
this.layerControlInputs.push(input);
|
|
293
|
-
input.layerId = obj.layer.id;
|
|
294
|
-
input.addEventListener('click', this.onInputClick);
|
|
295
|
-
var name = document.createElement('span');
|
|
296
|
-
name.innerHTML = ' ' + obj.name;
|
|
297
|
-
var holder = document.createElement('div');
|
|
298
|
-
label.appendChild(holder);
|
|
299
|
-
holder.appendChild(input);
|
|
300
|
-
holder.appendChild(name);
|
|
301
|
-
var container = obj.overlay ? this.overlaysList : this.baseLayersList;
|
|
302
|
-
container.appendChild(label);
|
|
303
|
-
this.checkDisabledLayers();
|
|
304
|
-
return label;
|
|
305
|
-
}
|
|
306
|
-
}, {
|
|
307
|
-
key: "onInputClick",
|
|
308
|
-
value: function onInputClick() {
|
|
309
|
-
var inputs = this.layerControlInputs;
|
|
310
|
-
var input;
|
|
311
|
-
var layer;
|
|
312
|
-
var addedLayers = [];
|
|
313
|
-
var removedLayers = [];
|
|
314
|
-
this.handlingClick = true;
|
|
315
|
-
|
|
316
|
-
for (var i = inputs.length - 1; i >= 0; i--) {
|
|
317
|
-
input = inputs[i];
|
|
318
|
-
layer = this.layerService.getLayer(input.layerId);
|
|
319
|
-
|
|
320
|
-
if (input.checked) {
|
|
321
|
-
addedLayers.push(layer);
|
|
322
|
-
} else if (!input.checked) {
|
|
323
|
-
removedLayers.push(layer);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
removedLayers.forEach(function (l) {
|
|
328
|
-
l.hide();
|
|
329
|
-
});
|
|
330
|
-
addedLayers.forEach(function (l) {
|
|
331
|
-
l.show();
|
|
332
|
-
});
|
|
333
|
-
this.handlingClick = false;
|
|
334
|
-
}
|
|
335
|
-
}]);
|
|
336
|
-
|
|
337
|
-
return Layers;
|
|
338
|
-
}(Control);
|
|
339
|
-
|
|
340
|
-
export { Layers as default };
|
package/es/control/logo.d.ts
DELETED
package/es/control/logo.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
7
|
-
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); }; }
|
|
8
|
-
|
|
9
|
-
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; } }
|
|
10
|
-
|
|
11
|
-
import { DOM } from '@antv/l7-utils';
|
|
12
|
-
import Control, { PositionType } from "./BaseControl";
|
|
13
|
-
|
|
14
|
-
var Logo = /*#__PURE__*/function (_Control) {
|
|
15
|
-
_inherits(Logo, _Control);
|
|
16
|
-
|
|
17
|
-
var _super = _createSuper(Logo);
|
|
18
|
-
|
|
19
|
-
function Logo() {
|
|
20
|
-
_classCallCheck(this, Logo);
|
|
21
|
-
|
|
22
|
-
return _super.apply(this, arguments);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
_createClass(Logo, [{
|
|
26
|
-
key: "getDefault",
|
|
27
|
-
value: function getDefault() {
|
|
28
|
-
return {
|
|
29
|
-
position: PositionType.BOTTOMLEFT,
|
|
30
|
-
name: 'logo'
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: "onAdd",
|
|
35
|
-
value: function onAdd() {
|
|
36
|
-
var className = 'l7-control-logo';
|
|
37
|
-
var container = DOM.create('div', className);
|
|
38
|
-
var anchor = DOM.create('a', 'l7-ctrl-logo');
|
|
39
|
-
anchor.target = '_blank';
|
|
40
|
-
anchor.rel = 'noopener nofollow';
|
|
41
|
-
anchor.href = 'https://antv.alipay.com/l7';
|
|
42
|
-
anchor.setAttribute('aria-label', 'AntV logo');
|
|
43
|
-
anchor.setAttribute('rel', 'noopener nofollow');
|
|
44
|
-
container.appendChild(anchor);
|
|
45
|
-
return container;
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "onRemove",
|
|
49
|
-
value: function onRemove() {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}]);
|
|
53
|
-
|
|
54
|
-
return Logo;
|
|
55
|
-
}(Control);
|
|
56
|
-
|
|
57
|
-
export { Logo as default };
|
package/es/control/scale.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { IScaleControlOption } from '../interface';
|
|
2
|
-
import Control, { PositionType } from './BaseControl';
|
|
3
|
-
export default class Scale extends Control {
|
|
4
|
-
private mScale;
|
|
5
|
-
private iScale;
|
|
6
|
-
constructor(cfg?: Partial<IScaleControlOption>);
|
|
7
|
-
getDefault(): {
|
|
8
|
-
position: PositionType;
|
|
9
|
-
maxWidth: number;
|
|
10
|
-
metric: boolean;
|
|
11
|
-
updateWhenIdle: boolean;
|
|
12
|
-
imperial: boolean;
|
|
13
|
-
name: string;
|
|
14
|
-
};
|
|
15
|
-
onAdd(): any;
|
|
16
|
-
onRemove(): void;
|
|
17
|
-
update(): void;
|
|
18
|
-
updateScales(maxMeters: number): void;
|
|
19
|
-
private updateMetric;
|
|
20
|
-
private updateImperial;
|
|
21
|
-
private updateScale;
|
|
22
|
-
private getRoundNum;
|
|
23
|
-
private addScales;
|
|
24
|
-
}
|