报错 Could not load image because of The source image could not be decoded.. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.
this.map= new mapboxgl.Map({
container: "map",
style: "mapbox://styles/mapbox/outdoors-v10", //地图样式,可以使用官网预定义的样式,也可以自定义
center: [100.66667449903593, 30.61048586436445],
minZoom: 2,
zoom: 4
})
statusChange(vals) {
let id=vals.id+Date.parse(new Date())
var index = this.strArr.indexOf(vals.id);
if (index > -1) {
this.strArr.splice(index, 1); //存在就删除
this.map.removeLayer(vals.id);
this.map.removeSource(vals.id)
} else {
this.strArr.push(vals.id); //不存在就添加
this.map.addSource(id, {
type: "raster",
tiles: ['http://10.64.101.123/iserver/services/map-zjroadview-3/rest/maps/zjmap/tileFeature/vectorstyles.json?type=MapBox_GL&styleonly=true'],
tileSize: 256,
});
this.map.addLayer({
id: vals.id,
type: "raster",
source: id,
minzoom: 0,
maxzoom: 22,
});
}
},