bigmap-plugin 1.0.3 → 1.0.4

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.
@@ -1,2 +1,110 @@
1
- var r=Object.defineProperty;var d=(a,u)=>r(a,"name",{value:u,configurable:!0});(function(){"use strict";var a,u=window.location.href,s=u.lastIndexOf("/");s>0&&s<u.length-1&&(u=u.substring(s+1)),window.Sandcastle={bucket:u,declare:d(function(){},"declare"),highlight:d(function(){},"highlight"),registered:[],finishedLoading:d(function(){window.Sandcastle.reset(),a&&(window.Sandcastle.highlight(a),a(),a=void 0),document.body.className=document.body.className.replace(/(?:\s|^)sandcastle-loading(?:\s|$)/," ")},"finishedLoading"),addToggleButton:d(function(e,n,t,o){window.Sandcastle.declare(t);var c=document.createElement("input");c.checked=n,c.type="checkbox",c.style.pointerEvents="none";var i=document.createElement("label");i.appendChild(c),i.appendChild(document.createTextNode(e)),i.style.pointerEvents="none";var l=document.createElement("button");l.type="button",l.className="cesium-button",l.appendChild(i),l.onclick=function(){window.Sandcastle.reset(),window.Sandcastle.highlight(t),c.checked=!c.checked,t(c.checked)},document.getElementById(o||"toolbar").appendChild(l)},"addToggleButton"),addToolbarButton:d(function(e,n,t){window.Sandcastle.declare(n);var o=document.createElement("button");o.type="button",o.className="cesium-button",o.onclick=function(){window.Sandcastle.reset(),window.Sandcastle.highlight(n),n()},o.textContent=e,document.getElementById(t||"toolbar").appendChild(o)},"addToolbarButton"),addDefaultToolbarButton:d(function(e,n,t){window.Sandcastle.addToolbarButton(e,n,t),a=n},"addDefaultToolbarButton"),addDefaultToolbarMenu:d(function(e,n){window.Sandcastle.addToolbarMenu(e,n),a=e[0].onselect},"addDefaultToolbarMenu"),addToolbarMenu:d(function(e,n){var t=document.createElement("select");t.className="cesium-button",t.onchange=function(){window.Sandcastle.reset();var l=e[t.selectedIndex];l&&typeof l.onselect=="function"&&l.onselect()},document.getElementById(n||"toolbar").appendChild(t),!a&&typeof e[0].onselect=="function"&&(a=e[0].onselect);for(var o=0,c=e.length;o<c;++o){var i=document.createElement("option");i.textContent=e[o].text,i.value=e[o].value,t.appendChild(i)}},"addToolbarMenu"),reset:d(function(){},"reset")},window.location.protocol==="file:"&&window.confirm(`You must host this app on a web server.
2
- See contributor's guide for more info?`)&&(window.location="https://github.com/CesiumGS/cesium/wiki/Contributor%27s-Guide")})();
1
+ (function () {
2
+ "use strict";
3
+ var defaultAction;
4
+ var bucket = window.location.href;
5
+ var pos = bucket.lastIndexOf("/");
6
+ if (pos > 0 && pos < bucket.length - 1) {
7
+ bucket = bucket.substring(pos + 1);
8
+ }
9
+
10
+ window.Sandcastle = {
11
+ bucket: bucket,
12
+ declare: function () { },
13
+ highlight: function () { },
14
+ registered: [],
15
+ finishedLoading: function () {
16
+ window.Sandcastle.reset();
17
+
18
+ if (defaultAction) {
19
+ window.Sandcastle.highlight(defaultAction);
20
+ defaultAction();
21
+ defaultAction = undefined;
22
+ }
23
+
24
+ document.body.className = document.body.className.replace(
25
+ /(?:\s|^)sandcastle-loading(?:\s|$)/,
26
+ " "
27
+ );
28
+ },
29
+ addToggleButton: function (text, checked, onchange, toolbarID) {
30
+ window.Sandcastle.declare(onchange);
31
+ var input = document.createElement("input");
32
+ input.checked = checked;
33
+ input.type = "checkbox";
34
+ input.style.pointerEvents = "none";
35
+ var label = document.createElement("label");
36
+ label.appendChild(input);
37
+ label.appendChild(document.createTextNode(text));
38
+ label.style.pointerEvents = "none";
39
+ var button = document.createElement("button");
40
+ button.type = "button";
41
+ button.className = "cesium-button";
42
+ button.appendChild(label);
43
+
44
+ button.onclick = function () {
45
+ window.Sandcastle.reset();
46
+ window.Sandcastle.highlight(onchange);
47
+ input.checked = !input.checked;
48
+ onchange(input.checked);
49
+ };
50
+
51
+ document.getElementById(toolbarID || "toolbar").appendChild(button);
52
+ },
53
+ addToolbarButton: function (text, onclick, toolbarID) {
54
+ window.Sandcastle.declare(onclick);
55
+ var button = document.createElement("button");
56
+ button.type = "button";
57
+ button.className = "cesium-button";
58
+ button.onclick = function () {
59
+ window.Sandcastle.reset();
60
+ window.Sandcastle.highlight(onclick);
61
+ onclick();
62
+ };
63
+ button.textContent = text;
64
+ document.getElementById(toolbarID || "toolbar").appendChild(button);
65
+ },
66
+ addDefaultToolbarButton: function (text, onclick, toolbarID) {
67
+ window.Sandcastle.addToolbarButton(text, onclick, toolbarID);
68
+ defaultAction = onclick;
69
+ },
70
+ addDefaultToolbarMenu: function (options, toolbarID) {
71
+ window.Sandcastle.addToolbarMenu(options, toolbarID);
72
+ defaultAction = options[0].onselect;
73
+ },
74
+ addToolbarMenu: function (options, toolbarID) {
75
+ var menu = document.createElement("select");
76
+ menu.className = "cesium-button";
77
+ menu.onchange = function () {
78
+ window.Sandcastle.reset();
79
+ var item = options[menu.selectedIndex];
80
+ if (item && typeof item.onselect === "function") {
81
+ item.onselect();
82
+ }
83
+ };
84
+ document.getElementById(toolbarID || "toolbar").appendChild(menu);
85
+
86
+ if (!defaultAction && typeof options[0].onselect === "function") {
87
+ defaultAction = options[0].onselect;
88
+ }
89
+
90
+ for (var i = 0, len = options.length; i < len; ++i) {
91
+ var option = document.createElement("option");
92
+ option.textContent = options[i].text;
93
+ option.value = options[i].value;
94
+ menu.appendChild(option);
95
+ }
96
+ },
97
+ reset: function () { },
98
+ };
99
+
100
+ if (window.location.protocol === "file:") {
101
+ if (
102
+ window.confirm(
103
+ "You must host this app on a web server.\nSee contributor's guide for more info?"
104
+ )
105
+ ) {
106
+ window.location =
107
+ "https://github.com/CesiumGS/cesium/wiki/Contributor%27s-Guide";
108
+ }
109
+ }
110
+ })();
@@ -1,34 +1,284 @@
1
- var v=Object.defineProperty;var r=(i,e)=>v(i,"name",{value:e,configurable:!0});class Effect{static{r(this,"Effect")}viewer;id;duration;maxRadius;pointDraged;leftDownFlag;update_position;constructor(e,a){this.viewer=e,this.id=a,this.duration=1e3,this.maxRadius=1e3,this.pointDraged=null,this.leftDownFlag=!1}change_duration(e){this.duration=e}change_color(e){const a=this.viewer.entities.getById(this.id);a._ellipse._material.color=new bmgl.Color.fromCssColorString(e)}change_position(e){const a=bmgl.Cartesian3.fromDegrees(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])),n=this.viewer.entities.getById(this.id);n.position=a}del(){this.viewer.entities.removeById(this.id)}add(e,a,n,l,d=!1){const t=this;if(this.duration=l,this.maxRadius=n,!d)return;function o(s){t.pointDraged=t.viewer.scene.pick(s.position),t.pointDraged&&t.pointDraged.id&&t.pointDraged.id.id===t.id&&(t.leftDownFlag=!0,t.viewer.scene.screenSpaceCameraController.enableRotate=!1)}r(o,"leftDownAction");function u(s){t.leftDownFlag=!1,t.pointDraged=null,t.viewer.scene.screenSpaceCameraController.enableRotate=!0}r(u,"leftUpAction");function m(s){if(t.leftDownFlag===!0&&t.pointDraged!==null&&t.pointDraged!==void 0){const f=t.viewer.camera.getPickRay(s.endPosition),p=t.viewer.scene.globe.pick(f,t.viewer.scene);t.pointDraged.id.position=p;const g=t.viewer.scene.globe.ellipsoid.cartesianToCartographic(p),h=bmgl.Math.toDegrees(g.latitude),b=bmgl.Math.toDegrees(g.longitude);let c=g.height;c=c<0?0:c,t.update_position&&t.update_position([b.toFixed(8),h.toFixed(8),c])}}r(m,"mouseMoveAction"),this.viewer.screenSpaceEventHandler.setInputAction(o,bmgl.ScreenSpaceEventType.LEFT_DOWN),this.viewer.screenSpaceEventHandler.setInputAction(u,bmgl.ScreenSpaceEventType.LEFT_UP),this.viewer.screenSpaceEventHandler.setInputAction(m,bmgl.ScreenSpaceEventType.MOUSE_MOVE)}}function CircleWaveMaterialProperty(i){this._definitionChanged=new bmgl.Event,this._color=void 0,this._colorSubscription=void 0,this.color=i.color,this.duration=bmgl.defaultValue(i.duration,1e3),this.count=bmgl.defaultValue(i.count,2),this.count<=0&&(this.count=1),this.gradient=bmgl.defaultValue(i.gradient,.1),this.gradient===0&&(this.gradient=0),this.gradient>1&&(this.gradient=1),this._time=new Date().getTime()}r(CircleWaveMaterialProperty,"CircleWaveMaterialProperty"),Object.defineProperties(CircleWaveMaterialProperty.prototype,{isConstant:{get:r(function(){return!1},"get")},definitionChanged:{get:r(function(){return this._definitionChanged},"get")},color:bmgl.createPropertyDescriptor("color"),duration:bmgl.createPropertyDescriptor("duration"),count:bmgl.createPropertyDescriptor("count")}),CircleWaveMaterialProperty.prototype.getType=function(i){return bmgl.Material.CircleWaveMaterialType},CircleWaveMaterialProperty.prototype.getValue=function(i,e){return bmgl.defined(e)||(e={}),e.color=bmgl.Property.getValueOrClonedDefault(this._color,i,bmgl.Color.WHITE,e.color),e.time=(new Date().getTime()-this._time)%this.duration/this.duration,e.count=this.count,e.gradient=1+10*(1-this.gradient),e},CircleWaveMaterialProperty.prototype.equals=function(i){return this===i||i instanceof CircleWaveMaterialProperty&&bmgl.Property.equals(this._color,i._color)},bmgl.CircleWaveMaterialProperty=CircleWaveMaterialProperty,bmgl.Material.CircleWaveMaterialType="CircleWaveMaterial",bmgl.Material.CircleWaveSource=`
2
- czm_material czm_getMaterial(czm_materialInput materialInput) {
3
- czm_material material = czm_getDefaultMaterial(materialInput);
4
- material.diffuse = 1.5 * color.rgb;
5
- vec2 st = materialInput.st;
6
- vec3 str = materialInput.str;
7
- float dis = distance(st, vec2(0.5, 0.5));
8
- float per = fract(time);
9
- if (abs(str.z) > 0.001) {
10
- discard;
11
- }
12
- if (dis > 0.5) {
13
- discard;
14
- } else {
15
- float perDis = 0.5 / count;
16
- float disNum;
17
- float bl = .0;
18
- for (int i = 0; i <= 9; i++) {
19
- if (float(i) <= count) {
20
- disNum = perDis *float(i) - dis + per / count;
21
- if (disNum > 0.0) {
22
- if (disNum < perDis) {
23
- bl = 1.0 - disNum / perDis;
24
- } else if(disNum - perDis < perDis) {
25
- bl = 1.0 - abs(1.0 - disNum / perDis);
26
- }
27
- material.alpha = pow(bl, gradient);
28
- }
29
- }
30
- }
31
- }
32
- return material;
33
- }
34
- `,bmgl.Material._materialCache.addMaterial(bmgl.Material.CircleWaveMaterialType,{fabric:{type:bmgl.Material.CircleWaveMaterialType,uniforms:{color:new bmgl.Color(1,0,0,1),time:1,count:1,gradient:.1},source:bmgl.Material.CircleWaveSource},translucent:r(function(i){return!0},"translucent")});class CircleWave extends Effect{static{r(this,"CircleWave")}count;constructor(e,a){super(e,a)}change_duration(e){super.change_duration(e);const a=this.viewer.entities.getById(this.id);a._ellipse._material.duration=e}change_waveCount(e){const a=this.viewer.entities.getById(this.id);a._ellipse._material.count=e}add(e,a,n,l,d=!1,t=3){super.add(e,a,n,l,d);const o=this;this.count=t,this.viewer.entities.add({id:o.id,position:bmgl.Cartesian3.fromDegrees(e[0],e[1],e[2]),ellipse:{semiMinorAxis:new bmgl.CallbackProperty(function(u){return o.maxRadius},!1),semiMajorAxis:new bmgl.CallbackProperty(function(u){return o.maxRadius},!1),material:new bmgl.CircleWaveMaterialProperty({duration:l,gradient:0,color:new bmgl.Color.fromCssColorString(a),count:t})}})}}
1
+ /***
2
+ * 鍏竟褰㈡墿鏁f晥鏋�
3
+ * 鍙傝€僩itee寮€婧恡s浠g爜
4
+ * 鍙栨秷import鍜宔xport锛屾暣鍚堜袱涓被
5
+ */
6
+
7
+ // 鐐规晥鏋滈泦鍚� 鐖剁被
8
+ class Effect {
9
+ viewer;
10
+ id;
11
+ duration;
12
+ maxRadius;
13
+ pointDraged;
14
+ leftDownFlag;
15
+ update_position;
16
+ constructor(viewer, id) {
17
+ this.viewer = viewer
18
+ this.id = id
19
+ this.duration = 1000
20
+ this.maxRadius = 1000
21
+ this.pointDraged = null
22
+ this.leftDownFlag = false
23
+ }
24
+ change_duration(d) {
25
+ this.duration = d
26
+ }
27
+ change_color(val) {
28
+ const curEntity = this.viewer.entities.getById(this.id)
29
+ curEntity._ellipse._material.color = new bmgl.Color.fromCssColorString(
30
+ val
31
+ )
32
+ }
33
+ change_position(p) {
34
+ const cartesian3 = bmgl.Cartesian3.fromDegrees(
35
+ parseFloat(p[0]),
36
+ parseFloat(p[1]),
37
+ parseFloat(p[2])
38
+ )
39
+ const curEntity = this.viewer.entities.getById(this.id)
40
+ curEntity.position = cartesian3
41
+ }
42
+ del() {
43
+ this.viewer.entities.removeById(this.id)
44
+ }
45
+ add(
46
+ position,
47
+ color,
48
+ maxRadius,
49
+ duration,
50
+ isEdit = false
51
+ ) {
52
+ const _this = this
53
+ this.duration = duration
54
+ this.maxRadius = maxRadius
55
+ if (!isEdit) {
56
+ return
57
+ }
58
+
59
+ function leftDownAction(e) {
60
+ _this.pointDraged = _this.viewer.scene.pick(e.position) // 閫夊彇褰撳墠鐨別ntity
61
+ if (
62
+ _this.pointDraged &&
63
+ _this.pointDraged.id &&
64
+ _this.pointDraged.id.id === _this.id
65
+ ) {
66
+ _this.leftDownFlag = true
67
+ _this.viewer.scene.screenSpaceCameraController.enableRotate = false // 閿佸畾鐩告満
68
+ }
69
+ }
70
+
71
+ function leftUpAction(e) {
72
+ _this.leftDownFlag = false
73
+ _this.pointDraged = null
74
+ _this.viewer.scene.screenSpaceCameraController.enableRotate = true // 瑙i攣鐩告満
75
+ }
76
+
77
+ function mouseMoveAction(e) {
78
+ if (
79
+ _this.leftDownFlag === true &&
80
+ _this.pointDraged !== null &&
81
+ _this.pointDraged !== undefined
82
+ ) {
83
+ const ray = _this.viewer.camera.getPickRay(e.endPosition)
84
+ const cartesian = _this.viewer.scene.globe.pick(ray, _this.viewer.scene)
85
+ _this.pointDraged.id.position = cartesian // 姝ゅ鏍规嵁鍏蜂綋entity鏉ュ鐞嗭紝涔熷彲鑳芥槸pointDraged.id.position=cartesian;
86
+ // 杩欓噷绗涘崱灏斿潗鏍囪浆 缁忕含搴�
87
+ const ellipsoid = _this.viewer.scene.globe.ellipsoid
88
+ const cartographic = ellipsoid.cartesianToCartographic(cartesian)
89
+ const lat = bmgl.Math.toDegrees(cartographic.latitude)
90
+ const lng = bmgl.Math.toDegrees(cartographic.longitude)
91
+ let alt = cartographic.height
92
+ alt = alt < 0 ? 0 : alt
93
+ if (_this.update_position) {
94
+ _this.update_position([lng.toFixed(8), lat.toFixed(8), alt])
95
+ }
96
+ }
97
+ }
98
+
99
+ this.viewer.screenSpaceEventHandler.setInputAction(
100
+ leftDownAction,
101
+ bmgl.ScreenSpaceEventType.LEFT_DOWN
102
+ )
103
+ this.viewer.screenSpaceEventHandler.setInputAction(
104
+ leftUpAction,
105
+ bmgl.ScreenSpaceEventType.LEFT_UP
106
+ )
107
+ this.viewer.screenSpaceEventHandler.setInputAction(
108
+ mouseMoveAction,
109
+ bmgl.ScreenSpaceEventType.MOUSE_MOVE
110
+ )
111
+ }
112
+ }
113
+
114
+ /**
115
+ * 姘存尝绾规墿鏁f潗璐�
116
+ *
117
+ *
118
+ * @param {*} color 棰滆壊
119
+ * @param {*} duration 鎸佺画鏃堕棿 姣
120
+ * @param {*} count 娉㈡氮鏁伴噺
121
+ * @param {*} gradient 娓愬彉鏇茬巼
122
+ */
123
+ function CircleWaveMaterialProperty(ob) {
124
+ this._definitionChanged = new bmgl.Event()
125
+ this._color = undefined
126
+ this._colorSubscription = undefined
127
+ this.color = ob.color
128
+ this.duration = bmgl.defaultValue(ob.duration, 1000)
129
+ this.count = bmgl.defaultValue(ob.count, 2)
130
+ if (this.count <= 0) {
131
+ this.count = 1
132
+ }
133
+ this.gradient = bmgl.defaultValue(ob.gradient, 0.1)
134
+ if (this.gradient === 0) {
135
+ this.gradient = 0
136
+ }
137
+ if (this.gradient > 1) {
138
+ this.gradient = 1
139
+ }
140
+ this._time = new Date().getTime()
141
+ }
142
+ Object.defineProperties(CircleWaveMaterialProperty.prototype, {
143
+ isConstant: {
144
+ get: function () {
145
+ return false
146
+ },
147
+ },
148
+ definitionChanged: {
149
+ get: function () {
150
+ return this._definitionChanged
151
+ },
152
+ },
153
+ color: bmgl.createPropertyDescriptor('color'),
154
+ duration: bmgl.createPropertyDescriptor('duration'),
155
+ count: bmgl.createPropertyDescriptor('count'),
156
+ })
157
+ CircleWaveMaterialProperty.prototype.getType = function (_time) {
158
+ return bmgl.Material.CircleWaveMaterialType
159
+ }
160
+ CircleWaveMaterialProperty.prototype.getValue = function (
161
+ time,
162
+ result
163
+ ) {
164
+ if (!bmgl.defined(result)) {
165
+ result = {}
166
+ }
167
+ result.color = bmgl.Property.getValueOrClonedDefault(
168
+ this._color,
169
+ time,
170
+ bmgl.Color.WHITE,
171
+ result.color
172
+ )
173
+ result.time =
174
+ ((new Date().getTime() - this._time) % this.duration) / this.duration
175
+ result.count = this.count
176
+ result.gradient = 1 + 10 * (1 - this.gradient)
177
+ return result
178
+ }
179
+ CircleWaveMaterialProperty.prototype.equals = function (other) {
180
+ const reData = (
181
+ this === other ||
182
+ (other instanceof CircleWaveMaterialProperty &&
183
+ bmgl.Property.equals(this._color, other._color))
184
+ )
185
+ return reData
186
+ }
187
+ bmgl.CircleWaveMaterialProperty = CircleWaveMaterialProperty
188
+ bmgl.Material.CircleWaveMaterialType = 'CircleWaveMaterial'
189
+ bmgl.Material.CircleWaveSource = `
190
+ czm_material czm_getMaterial(czm_materialInput materialInput) {
191
+ czm_material material = czm_getDefaultMaterial(materialInput);
192
+ material.diffuse = 1.5 * color.rgb;
193
+ vec2 st = materialInput.st;
194
+ vec3 str = materialInput.str;
195
+ float dis = distance(st, vec2(0.5, 0.5));
196
+ float per = fract(time);
197
+ if (abs(str.z) > 0.001) {
198
+ discard;
199
+ }
200
+ if (dis > 0.5) {
201
+ discard;
202
+ } else {
203
+ float perDis = 0.5 / count;
204
+ float disNum;
205
+ float bl = .0;
206
+ for (int i = 0; i <= 9; i++) {
207
+ if (float(i) <= count) {
208
+ disNum = perDis *float(i) - dis + per / count;
209
+ if (disNum > 0.0) {
210
+ if (disNum < perDis) {
211
+ bl = 1.0 - disNum / perDis;
212
+ } else if(disNum - perDis < perDis) {
213
+ bl = 1.0 - abs(1.0 - disNum / perDis);
214
+ }
215
+ material.alpha = pow(bl, gradient);
216
+ }
217
+ }
218
+ }
219
+ }
220
+ return material;
221
+ }
222
+ `
223
+ bmgl.Material._materialCache.addMaterial(
224
+ bmgl.Material.CircleWaveMaterialType, {
225
+ fabric: {
226
+ type: bmgl.Material.CircleWaveMaterialType,
227
+ uniforms: {
228
+ color: new bmgl.Color(1, 0, 0, 1),
229
+ time: 1,
230
+ count: 1,
231
+ gradient: 0.1,
232
+ },
233
+ source: bmgl.Material.CircleWaveSource,
234
+ },
235
+ translucent: function (material) {
236
+ return true
237
+ },
238
+ }
239
+ )
240
+
241
+ // 姘存尝绾�
242
+ class CircleWave extends Effect {
243
+ count;
244
+ constructor(viewer, id) {
245
+ super(viewer, id)
246
+ }
247
+ change_duration(d) {
248
+ super.change_duration(d)
249
+ const curEntity = this.viewer.entities.getById(this.id)
250
+ curEntity._ellipse._material.duration = d
251
+ }
252
+ change_waveCount(d) {
253
+ const curEntity = this.viewer.entities.getById(this.id)
254
+ curEntity._ellipse._material.count = d
255
+ }
256
+ add(position, color, maxRadius, duration, isedit = false, count = 3) {
257
+ super.add(position, color, maxRadius, duration, isedit)
258
+ const _this = this
259
+ this.count = count
260
+ this.viewer.entities.add({
261
+ id: _this.id,
262
+ position: bmgl.Cartesian3.fromDegrees(
263
+ position[0],
264
+ position[1],
265
+ position[2]
266
+ ),
267
+ ellipse: {
268
+ // height: position[2],
269
+ semiMinorAxis: new bmgl.CallbackProperty(function (n) {
270
+ return _this.maxRadius
271
+ }, false),
272
+ semiMajorAxis: new bmgl.CallbackProperty(function (n) {
273
+ return _this.maxRadius
274
+ }, false),
275
+ material: new bmgl.CircleWaveMaterialProperty({
276
+ duration: duration,
277
+ gradient: 0,
278
+ color: new bmgl.Color.fromCssColorString(color),
279
+ count: count,
280
+ }),
281
+ },
282
+ })
283
+ }
284
+ }
@@ -1 +1,74 @@
1
- BM.Marker.addInitHook(function(){this.moveOptions={origin:null,timer:null,done:0,path:null,length:0,replay:!0},this.setSpeed=function(e){this.moveOptions.speed=isNaN(parseFloat(e))||parseFloat(e)<=0?200:parseFloat(e)},this.getSpeed=function(){return this.moveOptions.speed},this.moveAlong=function(e,t,o){e=e instanceof BM.Polyline?e:new BM.Polyline(e),this.moveOptions.path=e,this.moveOptions.replay=o.replay??!0,this.moveOptions.length=BM.GeometryUtil.length(e),this.moveOptions.speed=isNaN(parseFloat(t))||parseFloat(t<=0)?200:parseFloat(t),this._move(),setTimeout(()=>{console.log(this)},5e3)},this.pauseMove=function(){clearInterval(this.moveOptions.timer),this.moveOptions.timer=null},this.resumeMove=function(){if(!this.moveOptions.path)throw"\u672A\u5BFC\u5165\u8DEF\u5F84";this._move()},this.stopMove=function(){this.pauseMove(),this.moveOptions.done=0},this._move=function(){if(this.moveOptions.timer)return;let e=this;this.moveOptions.timer=setInterval(function(){let t=e.moveOptions.done;t+=e.moveOptions.speed/1e3*20;let o=t/e.moveOptions.length;if(e.moveOptions.replay)o>=1&&(o=0,t=0);else if(o>=1){let s=BM.GeometryUtil.interpolateOnLine(e._map,e.moveOptions.path,!0);s.predecessor+=1;let n=e.moveOptions.path.getLatLngs().slice(0,s.predecessor+1);e.fire("update_position",{path:n,index:s.predecessor}),e.stopMove();return}e.moveOptions.done=t;let i=BM.GeometryUtil.interpolateOnLine(e._map,e.moveOptions.path,o);e.setLatLng(i.latLng);let p=e.moveOptions.path.getLatLngs()[i.predecessor];if(p){let s=e.moveOptions.path.getLatLngs().slice(0,i.predecessor+1);s.push(i.latLng),e.fire("update_position",{path:s,index:i.predecessor});let n=BM.GeometryUtil.computeAngle(e._map.project(p),e._map.project(i.latLng));e._icon.style.transformOrigin="50% 50%",e._icon.style.transform+=" rotateZ("+n+"deg)"}},20)}});
1
+ BM.Marker.addInitHook(function () {
2
+ this.moveOptions = {
3
+ origin: null,
4
+ timer: null,
5
+ done: 0,
6
+ path: null,
7
+ length: 0,
8
+ replay: true
9
+ };
10
+ this.setSpeed = function (speed) {
11
+ this.moveOptions.speed = isNaN(parseFloat(speed)) || parseFloat(speed) <= 0 ? 200 : parseFloat(speed);
12
+ };
13
+ this.getSpeed = function () {
14
+ return this.moveOptions.speed;
15
+ };
16
+ this.moveAlong = function (path, speed, param) {
17
+ path = path instanceof BM.Polyline ? path : new BM.Polyline(path);
18
+ this.moveOptions.path = path;
19
+ this.moveOptions.replay = param.replay ?? true;
20
+ this.moveOptions.length = BM.GeometryUtil.length(path);
21
+ this.moveOptions.speed = isNaN(parseFloat(speed)) || parseFloat(speed <= 0) ? 200 : parseFloat(speed);
22
+ this._move();
23
+ setTimeout(()=>{
24
+ console.log(this);
25
+ },5000)
26
+ };
27
+ this.pauseMove = function () {
28
+ clearInterval(this.moveOptions.timer);
29
+ this.moveOptions.timer = null;
30
+ };
31
+ this.resumeMove = function () {
32
+ if(!this.moveOptions.path){
33
+ throw('未导入路径');
34
+ }
35
+ this._move();
36
+ };
37
+ this.stopMove = function () {
38
+ this.pauseMove();
39
+ this.moveOptions.done = 0;
40
+ };
41
+ this._move = function () {
42
+ if (this.moveOptions.timer) return;
43
+ let _t = this;
44
+ this.moveOptions.timer = setInterval(function () {
45
+ let done = _t.moveOptions.done;
46
+ done += _t.moveOptions.speed / 1000 * 20;
47
+ let radio = done / _t.moveOptions.length;
48
+ if (_t.moveOptions.replay) {
49
+ radio >= 1 ? (radio = 0, done = 0) : true;
50
+ } else {
51
+ if (radio >= 1) {
52
+ let p = BM.GeometryUtil.interpolateOnLine(_t._map, _t.moveOptions.path, true);
53
+ p.predecessor+=1;
54
+ let passed = _t.moveOptions.path.getLatLngs().slice(0, p.predecessor+1);
55
+ _t.fire('update_position', { path: passed, index: p.predecessor });
56
+ _t.stopMove();
57
+ return
58
+ }
59
+ }
60
+ _t.moveOptions.done = done;
61
+ let p = BM.GeometryUtil.interpolateOnLine(_t._map, _t.moveOptions.path, radio);
62
+ _t.setLatLng(p.latLng);
63
+ let pre_p = _t.moveOptions.path.getLatLngs()[p.predecessor];
64
+ if (pre_p) {
65
+ let passed = _t.moveOptions.path.getLatLngs().slice(0, p.predecessor + 1);
66
+ passed.push(p.latLng);
67
+ _t.fire('update_position', { path: passed, index: p.predecessor });
68
+ let deg = BM.GeometryUtil.computeAngle(_t._map.project(pre_p), _t._map.project(p.latLng))
69
+ _t._icon.style.transformOrigin = '50% 50%';
70
+ _t._icon.style.transform += ' rotateZ(' + deg + 'deg)';
71
+ }
72
+ }, 20);
73
+ }
74
+ });