使用产品:supermap-iserver-11.0.1-windows-x64 操作系统:win11 x64
数据类型: pgsql工作空间地图服务
问题详细描述:cesium通过请求SuperMap服务的JSON配置文件读取rest地图服务,但是现在我给服务限制了授权访问,我在iserve上申请了token,但是不知道怎么把token加到代码里
addSuperMapLayer(url) {
this.clearAllEntitys();
fetch(url + '.json')
.then(response => response.json())
.then(result => {
const epsgCode = result.prjCoordSys.epsgCode;
const rectangle = Cesium.Rectangle.fromDegrees(-180, -90, 180, 90);
let tilingScheme;
let originx, originy;
let minLevel = 0;
let maxLevel = 22;
if (epsgCode === 4326) {
tilingScheme = new Cesium.GeographicTilingScheme({
numberOfLevelZeroTilesX: 2,
numberOfLevelZeroTilesY: 1,
});
originx = -180;
originy = 90;
} else if (epsgCode === 3857) {
tilingScheme = new Cesium.WebMercatorTilingScheme();
originx = -20037508.34;
originy = 20037508.34;
}
const layerProvider = new Cesium.UrlTemplateImageryProvider({
url: url + "/tileImage.png?transparent=true&cacheEnabled=true&width=256&height=256&x={x}&y={y}&scale={scale}&redirect=false&overlapDisplayed=false&origin={'x':" + originx + ",'y':" + originy + "}",
rectangle: rectangle,
minimumLevel: minLevel,
maximumLevel: maxLevel,
tilingScheme: tilingScheme,
customTags: {
scale: (imageryProvider, x, y, level) => {
return epsgCode === 4326 ? this.scales84[level] : this.scalesWeb[level];
},
},
});
window.viewer.imageryLayers.addImageryProvider(layerProvider);
})
.catch(error => {
console.error('Error loading SuperMap layer:', error);
});