let map = this.map;
this.removeUnderMapLayer(this.currentUnderMap);
switch (obj.type) {
case "tdt":
map.addSource("tdtVec", {
type: "raster",
tiles: [
//请求地址
obj.url[0],
],
//分辨率
tileSize: 256,
});
map.addSource("tdtCva", {
type: "raster",
tiles: [
//请求地址
obj.url[1],
],
//分辨率
tileSize: 256,
});
map.addLayer(
{
id: "tdtVec",
type: "raster",
source: "tdtVec",
minzoom: 0,
maxzoom: 22,
},
"gl-draw-polygon-fill-inactive.cold"
);
map.addLayer(
{
id: "tdtCva",
type: "raster",
source: "tdtCva",
minzoom: 0,
maxzoom: 22,
},
"gl-draw-polygon-fill-inactive.cold"
);
var style1 = map.getStyle().layers;
console.log(style1, "style3style4style");
this.currentUnderMap = "tdt";
break;
case "arcgisMap":
map.addSource("arcgisMap", {
type: "raster",
tiles: [
//请求地址
obj.url[0],
],
//分辨率
tileSize: 256,
});
map.addSource("tdtCva", {
type: "raster",
tiles: [
//请求地址
obj.url[1],
],
//分辨率
tileSize: 256,
});
map.addLayer(
{
id: "arcgisMap",
type: "raster",
source: "arcgisMap",
minzoom: 0,
maxzoom: 22,
},
"gl-draw-polygon-fill-inactive.cold"
);
map.addLayer(
{
id: "tdtCva",
type: "raster",
source: "tdtCva",
minzoom: 0,
maxzoom: 22,
},
"gl-draw-polygon-fill-inactive.cold"
);
var style = map.getStyle().layers;
console.log(style, "style1style2style");
// map.moveLayer("arcgisMap", 'RoadLine2_1@GZGQ_0(0_9)');
// map.moveLayer("tdtCva", 'RoadLine2_1@GZGQ_0(0_9)');
this.currentUnderMap = "arcgisMap";
break;
case "supermapMap":
map.addSource("supermapMap", {
type: "raster",
tiles: [
//请求地址
obj.url[0],
],
//分辨率
tileSize: 256,
});
map.addLayer(
{
id: "supermapMap",
type: "raster",
source: "supermapMap",
minzoom: 0,
maxzoom: 22,
},
RemotesesingConfig.rasterFlagLayer
);
this.currentUnderMap = "supermapMap";
break;
default:
break;
}
切换图层报错
{
"status": 429,
"url": "
http://t0.tianditu.gov.cn/vec_w/wmts?tk=c6593be49827aef69dbcdf610226abfa&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&TILEMATRIX=5&TILEROW=13&TILECOL=24&FORMAT=tiles",
"name": "e",
"message": "Too Many Requests"
}