首页 / 浏览问题 / WebGIS / 问题详情
回调函数作用域问题
41EXP 2022年10月21日
比如 我获取图层信息,我怎么才能在  mainObj.getLayersInfoServiceCompleted的方法中获得mainObj

var layerInfoService = new L.supermap.LayerInfoService(mainObj.dituUrl);
layerInfoService.getLayersInfo(mainObj.getLayersInfoServiceCompleted);

以前用SuperMap iClient Classic的时候可以配置

 getLayersInfoService.events.on({
            "processCompleted": mainObj.getLayersInfoServiceCompleted,
            scope: mainObj
        });

1个回答

你好,leaflet获取图层信息的示例可以参考demo:https://iclient.supermap.io/examples/leaflet/editor.html#01_layerService

主要使用获取图层的方法是:

new LayerInfoService(url).getLayersInfo(function(result){
  //doSomething
})
3,745EXP 2022年10月21日
主要是作用域问题。

获取图层信息完成后的回调函数参考api,里面可以返回result、object、type、element

...