Skip to content

Commit e43815c

Browse files
committed
Merge branch 'master' of https://github.com/SuperMap/iClient-JavaScript into master
2 parents e6911e4 + 1c2e17c commit e43815c

File tree

8 files changed

+165
-52
lines changed

8 files changed

+165
-52
lines changed

test/mapboxgl/overlay/DeckglLayerSpec.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,25 @@ describe('mapboxgl_DeckglLayer', () => {
1919
window.document.body.appendChild(testDiv);
2020
map = new mapboxgl.Map({
2121
container: 'map',
22-
style: 'mapbox://styles/mapbox/streets-v9',
22+
style: {
23+
version: 8,
24+
sources: {
25+
'raster-tiles': {
26+
type: 'raster',
27+
tiles: [GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
28+
tileSize: 256
29+
}
30+
},
31+
layers: [
32+
{
33+
id: 'simple-tiles',
34+
type: 'raster',
35+
source: 'raster-tiles',
36+
minzoom: 0,
37+
maxzoom: 22
38+
}
39+
]
40+
},
2341
center: [13.413952, 52.531913],
2442
zoom: 16.000000000000004,
2543
pitch: 33.2

test/mapboxgl/overlay/GraphicLayerSpec.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ describe('mapboxgl_GraphicLayer', () => {
1313
[-37.16, 40.05],
1414
[-38.16, 39.05]
1515
];
16+
let testDiv, map;
1617
function creatGraphicLayer() {
17-
let testDiv, map, graphics = [], graphicLayer;
18+
let graphics = [], graphicLayer;
1819
//构建数据
1920
for (let i = 0; i < coors.length; i++) {
2021
let lngLat = {
@@ -35,7 +36,25 @@ describe('mapboxgl_GraphicLayer', () => {
3536
window.document.body.appendChild(testDiv);
3637
map = new mapboxgl.Map({
3738
container: 'map',
38-
style: 'mapbox://styles/mapbox/streets-v9',
39+
style: {
40+
version: 8,
41+
sources: {
42+
'raster-tiles': {
43+
type: 'raster',
44+
tiles: [GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
45+
tileSize: 256
46+
}
47+
},
48+
layers: [
49+
{
50+
id: 'simple-tiles',
51+
type: 'raster',
52+
source: 'raster-tiles',
53+
minzoom: 0,
54+
maxzoom: 22
55+
}
56+
]
57+
},
3958
center: [13.413952, 52.531913],
4059
zoom: 16.000000000000004,
4160
pitch: 33.2
@@ -51,10 +70,15 @@ describe('mapboxgl_GraphicLayer', () => {
5170
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
5271
});
5372
afterEach(() => {
73+
if(testDiv){
74+
document.body.removeChild(testDiv);
75+
testDiv = null;
76+
}
5477
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
5578
});
5679
afterAll(() => {
57-
document.body.removeChild(document.getElementById('map'));
80+
// document.body.removeChild(document.getElementById('map'));
81+
map = null;
5882
// map.removeLayer("graphicLayer");
5983
});
6084

test/mapboxgl/overlay/ThreeLayerSpec.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,25 @@ describe('mapboxgl_ThreeLayer', () => {
2020
window.document.body.appendChild(testDiv);
2121
map = new mapboxgl.Map({
2222
container: 'map',
23-
style: 'mapbox://styles/mapbox/streets-v9',
23+
style: {
24+
version: 8,
25+
sources: {
26+
'raster-tiles': {
27+
type: 'raster',
28+
tiles: [GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
29+
tileSize: 256
30+
}
31+
},
32+
layers: [
33+
{
34+
id: 'simple-tiles',
35+
type: 'raster',
36+
source: 'raster-tiles',
37+
minzoom: 0,
38+
maxzoom: 22
39+
}
40+
]
41+
},
2442
center: [13.413952, 52.531913],
2543
zoom: 16.000000000000004,
2644
pitch: 33.2

test/maplibregl/overlay/DeckglLayerSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('maplibregl_DeckglLayer', () => {
7777
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
7878
});
7979
afterAll(() => {
80-
// document.body.removeChild(testDiv);
80+
document.body.removeChild(testDiv);
8181
});
8282

8383
it('onAdd_PathLayer', (done) => {

test/maplibregl/overlay/FGBLayerSpec.js

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,33 @@ describe('maplibregl_FGBLayer', () => {
77
var originalTimeout;
88
var testDiv, map;
99
beforeAll((done) => {
10-
testDiv = window.document.createElement('div');
11-
testDiv.setAttribute('id', 'map');
12-
testDiv.style.styleFloat = 'left';
13-
testDiv.style.marginLeft = '8px';
14-
testDiv.style.marginTop = '50px';
15-
testDiv.style.width = '500px';
16-
testDiv.style.height = '500px';
17-
window.document.body.appendChild(testDiv);
18-
map = new maplibregl.Map({
19-
container: 'map',
20-
style: {
21-
version: 8,
22-
sources: {
23-
'raster-tiles': {
24-
type: 'raster',
25-
tiles: [url],
26-
tileSize: 256
27-
}
10+
testDiv = window.document.createElement('div');
11+
testDiv.setAttribute('id', 'map');
12+
testDiv.style.styleFloat = 'left';
13+
testDiv.style.marginLeft = '8px';
14+
testDiv.style.marginTop = '50px';
15+
testDiv.style.width = '500px';
16+
testDiv.style.height = '500px';
17+
window.document.body.appendChild(testDiv);
18+
map = new maplibregl.Map({
19+
container: 'map',
20+
style: {
21+
version: 8,
22+
sources: {
23+
24+
},
25+
layers: [
26+
27+
]
2828
},
29-
layers: [
30-
{
31-
id: 'simple-tiles',
32-
type: 'raster',
33-
source: 'raster-tiles',
34-
minzoom: 0,
35-
maxzoom: 22
36-
}
37-
]
38-
},
39-
center: [0, 0],
40-
zoom: 3
41-
});
42-
map.on('load', function () {
43-
done();
44-
});
29+
center: [0, 0],
30+
zoom: 3
31+
});
32+
console.log(123)
33+
map.on('load', function () {
34+
console.log(334)
35+
done();
36+
});
4537
});
4638
beforeEach(() => {
4739
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
@@ -94,12 +86,19 @@ describe('maplibregl_FGBLayer', () => {
9486
});
9587

9688
it('set extent', (done) => {
89+
var count = 0;
9790
var fgblayer = new FGBLayer({
9891
url: fgbUrl,
9992
extent: [0, 0, 21, 21],
10093
featureLoader: function (feature) {
101-
expect(feature.properties['CAPITAL']).toBe('圣多美');
102-
done();
94+
if (count === 1) {
95+
expect(feature.properties['CAPITAL']).toBe('圣多美');
96+
}
97+
count++;
98+
console.log(count)
99+
if (count === 3) {
100+
done();
101+
}
103102
return feature;
104103
}
105104
});
@@ -109,21 +108,31 @@ describe('maplibregl_FGBLayer', () => {
109108
});
110109

111110
it('render moveLayer onRemove setVisibility', (done) => {
111+
var count = 0;
112112
var fgblayer = new FGBLayer({
113113
url: fgbUrl,
114114
extent: [0, 0, 21, 21],
115115
featureLoader: function (feature) {
116-
expect(feature.properties['CAPITAL']).toBe('圣多美');
117-
done();
116+
if (count === 1) {
117+
expect(feature.properties['CAPITAL']).toBe('圣多美');
118+
}
119+
count++;
120+
console.log(count)
121+
if (count === 3) {
122+
done();
123+
}
118124
return feature;
119125
}
120126
});
121127
fgblayer.onAdd(map);
122128
fgblayer.render();
123-
fgblayer.moveLayer(fgblayer.layerId, 'simple-tiles');
124-
fgblayer.setVisibility(false);
125-
fgblayer.onRemove();
126-
expect(fgblayer).not.toBeNull();
129+
while(map.getLayer(fgblayer.layerId)){
130+
fgblayer.moveLayer(fgblayer.layerId, 'simple-tiles');
131+
console.log(map.getStyle())
132+
fgblayer.setVisibility(false);
133+
fgblayer.onRemove();
134+
expect(fgblayer).not.toBeNull();
135+
}
127136
});
128137

129138
});

test/maplibregl/overlay/GraphicLayerSpec.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ describe('maplibregl_GraphicLayer', () => {
1313
[-37.16, 40.05],
1414
[-38.16, 39.05]
1515
];
16+
let testDiv, map;
1617
function creatGraphicLayer() {
17-
let testDiv, map, graphics = [], graphicLayer;
18+
let graphics = [], graphicLayer;
1819
//构建数据
1920
for (let i = 0; i < coors.length; i++) {
2021
let lngLat = {
@@ -35,7 +36,25 @@ describe('maplibregl_GraphicLayer', () => {
3536
window.document.body.appendChild(testDiv);
3637
map = new maplibregl.Map({
3738
container: 'map',
38-
style: 'mapbox://styles/mapbox/streets-v9',
39+
style: {
40+
version: 8,
41+
sources: {
42+
'raster-tiles': {
43+
type: 'raster',
44+
tiles: [GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
45+
tileSize: 256
46+
}
47+
},
48+
layers: [
49+
{
50+
id: 'simple-tiles',
51+
type: 'raster',
52+
source: 'raster-tiles',
53+
minzoom: 0,
54+
maxzoom: 22
55+
}
56+
]
57+
},
3958
center: [13.413952, 52.531913],
4059
zoom: 16.000000000000004,
4160
pitch: 33.2
@@ -51,11 +70,16 @@ describe('maplibregl_GraphicLayer', () => {
5170
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
5271
});
5372
afterEach(() => {
73+
if(testDiv){
74+
document.body.removeChild(testDiv);
75+
testDiv = null;
76+
}
5477
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
5578
});
5679
afterAll(() => {
57-
document.body.removeChild(document.getElementById('map'));
80+
// document.body.removeChild(document.getElementById('map'));
5881
// map.removeLayer("graphicLayer");
82+
map = null;
5983
});
6084

6185
it('constructor', (done) => {

test/maplibregl/overlay/GraticuleLayerSpec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe('maplibregl_GraticuleLayer', () => {
4343
beforeEach(() => {
4444
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
4545
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
46+
debugger
4647
if (!map.getLayer('graticuleLayer_1')) {
4748
graticuleLayer = new GraticuleLayer({layerID :'graticuleLayer_1'});
4849
graticuleLayer.onAdd(map);
@@ -57,6 +58,7 @@ describe('maplibregl_GraticuleLayer', () => {
5758
if (map.getLayer('graticuleLayer_1')) {
5859
map.removeLayer('graticuleLayer_1');
5960
}
61+
debugger
6062
document.body.removeChild(testDiv);
6163
map = null;
6264
});

test/maplibregl/overlay/ThreeLayerSpec.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,25 @@ describe('maplibregl_ThreeLayer', () => {
1818
window.document.body.appendChild(testDiv);
1919
map = new maplibregl.Map({
2020
container: 'map',
21-
style: 'mapbox://styles/mapbox/streets-v9',
21+
style: {
22+
version: 8,
23+
sources: {
24+
'raster-tiles': {
25+
type: 'raster',
26+
tiles: [GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
27+
tileSize: 256
28+
}
29+
},
30+
layers: [
31+
{
32+
id: 'simple-tiles',
33+
type: 'raster',
34+
source: 'raster-tiles',
35+
minzoom: 0,
36+
maxzoom: 22
37+
}
38+
]
39+
},
2240
center: [13.413952, 52.531913],
2341
zoom: 16.000000000000004,
2442
pitch: 33.2

0 commit comments

Comments
 (0)