@ohuoy/easymap 1.1.0 → 1.1.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/index.js
CHANGED
|
@@ -125,9 +125,52 @@ export class EasyMap {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
this.map
|
|
130
|
-
|
|
128
|
+
setMapStyle(style){
|
|
129
|
+
let map = this.map;
|
|
130
|
+
const layerIds = map.style.order
|
|
131
|
+
const oldLayer = map.getStyle().layers;
|
|
132
|
+
let sources =[]
|
|
133
|
+
let layers = []
|
|
134
|
+
layerIds.forEach(id => {
|
|
135
|
+
let layer = map.getLayer(id);
|
|
136
|
+
if(layer.source){
|
|
137
|
+
let source = map.getSource(layer.source)
|
|
138
|
+
sources.push(source)
|
|
139
|
+
}
|
|
140
|
+
layers.push(layer)
|
|
141
|
+
map.removeLayer(id)
|
|
142
|
+
});
|
|
143
|
+
const handleStyleLoad = () => {
|
|
144
|
+
// Object.keys(sources).forEach(key => {
|
|
145
|
+
// if (!map.getSource(key)) {
|
|
146
|
+
// map.addSource(key, sources[key]);
|
|
147
|
+
// }
|
|
148
|
+
// }
|
|
149
|
+
// );
|
|
150
|
+
|
|
151
|
+
sources.forEach(source=>{
|
|
152
|
+
if (!map.getSource(source.id)) {
|
|
153
|
+
map.addSource(source.id,source._options);
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
layers.forEach(layer=>{
|
|
157
|
+
if (!map.getLayer(layer.id)) {
|
|
158
|
+
map.addLayer(layer);
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
map.theme.value = map.style.stylesheet.theme
|
|
162
|
+
|
|
163
|
+
map.off('style.load', handleStyleLoad);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
map.on('style.load', handleStyleLoad);
|
|
167
|
+
map.setStyle(style);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async setStyle(url){
|
|
171
|
+
if(this.map){
|
|
172
|
+
this.setMapStyle(url)
|
|
173
|
+
}
|
|
131
174
|
}
|
|
132
175
|
addScale(postion="bottom-right"){
|
|
133
176
|
if(this.ScaleControl){
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ export default class AnimationLayer{
|
|
|
16
16
|
timerId
|
|
17
17
|
speed=1//帧
|
|
18
18
|
itemList = []
|
|
19
|
+
oldItem ={}
|
|
19
20
|
opacity = 0.8
|
|
20
21
|
obj = {}
|
|
21
22
|
status = actionStatus.Pause
|
|
@@ -82,6 +83,7 @@ export default class AnimationLayer{
|
|
|
82
83
|
if(this.itemList.length == 0){
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
86
|
+
this.oldItem =Object.assign({},item);
|
|
85
87
|
this.obj = this.loadMesh()
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -226,8 +228,11 @@ export default class AnimationLayer{
|
|
|
226
228
|
map,
|
|
227
229
|
gl, //get the context from Mapbox
|
|
228
230
|
{ defaultLights: true ,passiveRendering:false}
|
|
229
|
-
);
|
|
231
|
+
);
|
|
230
232
|
this.createInterval()
|
|
233
|
+
if(this.oldItem.imageList){
|
|
234
|
+
this.createTexture(this.oldItem)
|
|
235
|
+
}
|
|
231
236
|
esMapWatchEffect(()=>{
|
|
232
237
|
this.updateStyleByTheme()
|
|
233
238
|
})
|
|
@@ -11,6 +11,7 @@ export default class ThreeScanLayer{
|
|
|
11
11
|
opacity = 0.8
|
|
12
12
|
textClass = ''
|
|
13
13
|
forceClear = false
|
|
14
|
+
oldDrawArray = []
|
|
14
15
|
constructor(id,config) {
|
|
15
16
|
this.id = id;
|
|
16
17
|
this.opacity = Number(config.opacity)
|
|
@@ -21,7 +22,7 @@ export default class ThreeScanLayer{
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
//同时渲染多个地点图片文本
|
|
24
|
-
async drawImageList(list,delay = 300){
|
|
25
|
+
async drawImageList(list,delay = 300){
|
|
25
26
|
for(let i in list){
|
|
26
27
|
await this.update(list[i])
|
|
27
28
|
//this.drawArray.push(list[i])
|
|
@@ -34,6 +35,7 @@ export default class ThreeScanLayer{
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
this.drawArray = this.drawArray.filter(a=>a)
|
|
38
|
+
this.oldDrawArray = Object.assign([],this.drawArray)
|
|
37
39
|
// this.tb.update();
|
|
38
40
|
// this.map.triggerRepaint();
|
|
39
41
|
await sleep(delay)
|
|
@@ -289,16 +291,26 @@ export default class ThreeScanLayer{
|
|
|
289
291
|
point.mesh = mesh;
|
|
290
292
|
}
|
|
291
293
|
|
|
292
|
-
|
|
293
|
-
this.
|
|
294
|
+
resetDraw(){
|
|
295
|
+
if(this.oldDrawArray.length > 0){
|
|
296
|
+
for(let i in this.oldDrawArray){
|
|
297
|
+
this.update(this.oldDrawArray[i])
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
onAdd(map, gl) {
|
|
303
|
+
this.map = map;
|
|
294
304
|
this.tb = new Threebox(
|
|
295
305
|
map,
|
|
296
306
|
gl, //get the context from Mapbox
|
|
297
307
|
{ defaultLights: true ,passiveRendering:false}
|
|
298
308
|
);
|
|
309
|
+
this.resetDraw()
|
|
299
310
|
esMapWatchEffect(()=>{
|
|
300
311
|
this.updateStyleByTheme()
|
|
301
312
|
})
|
|
313
|
+
|
|
302
314
|
}
|
|
303
315
|
render(gl, matrix) {
|
|
304
316
|
this.tb.update();
|