首頁 / 浏覽問題 / WebGIS / 問題詳情
使用api注冊token不(bù)生效
32EXP 2024年08月21日
window.L.supermap.SecurityManager.destroyToken(leafletOption.iserverBaseUrl);
  window.L.supermap.SecurityManager.registerToken(leafletOption.iserverBaseUrl, leafletOption.token);

//leafletOption.iserverBaseUrl:iserver服務器地(dì / de)址
//leafletOption.token:iserver裏設置的(de)token

我用上(shàng)面這(zhè)個(gè)方法來(lái)給leaflet綁定token,但是(shì)我發現我的(de)請求沒有攜帶token,所以(yǐ)在(zài)當我批量授權之(zhī)後,圖層就(jiù)不(bù)顯示了(le/liǎo),下面是(shì)url

1個(gè)回答

您的(de)iClient for Leaflet是(shì)什麽版本的(de)?可以(yǐ)從“include-web.js”請求中查看版本。我這(zhè)邊用11.1.1的(de)iClient測試,是(shì)可以(yǐ)将token添加到(dào)url中的(de):

var token = "wU32bHaw5jrhWbFXgY1ZzDy-Xz_Brs-Pnb7XzxU679mnRGayKZYXTyvZBbCmbkevBQ8wpEDCYSijVhyOZ0St3Q..";
var url = "http://localhost:8092/iserver/services/map-testWorkspace/rest/maps/Province_R";
window.L.supermap.SecurityManager.destroyToken(url);
window.L.supermap.SecurityManager.registerToken(url, token);
new L.supermap.TiledMapLayer(url).addTo(map);

1,191EXP 2024年08月21日
...