首页 / 浏览问题 / WebGIS / 问题详情
对接iserver图层,修改数据源时提示方法不存在
6EXP 2023年04月24日

使用产品:iserver 11 操作系统:win11

数据类型: 文件

问题描述: 对接iserver图层,修改数据源时提示方法不存在

问题重现步骤: 

__addSourceHandler(map, `${ cursubMenuModule.value.code }_Source`, {
      type: 'raster',
      tiles: [`${ mapConf.iserverPath }${ mapConf.namePrefix }_${ areaCode }`],
      rasterSource: "iserver",
      tileSize: 256,
    })
source.setTiles([`${ mapConf.iserverPath }${ mapConf.namePrefix }_${ nCode }`])

提示:caught (in promise) TypeError: source.setTiles is not a function
 

1个回答

您好,请问您具体用的是哪个接口呢?

是使用的iserver的rest api直接发的请求,还是用的哪个iClient的类,接口名或者类名是什么。

希望可以帮助到您
9,728EXP 2023年04月24日
使用map.addSource(sourceId, sourceObj)添加数据源;

使用map.addLayer(layerId, layerObj)添加图层;

map.getSource(sourceId).setTiles([])时,提示caught (in promise) TypeError: source.setTiles is not a function
用的是哪个产品?Leaflet、mapbox、classic、openlayer?
mapbox

您好,iClient的mapbox底层改写了VectorTileSource,因此没有serTiles的方法,

建议您目的如果是为了更换数据源中的信息,可以考虑参考下面这种方法实现:

if (!!map.getSource('theme')) {
                map.removeSource('theme');
                map.addSource("theme", {
                    "type": 'raster',
                    "tiles": [host + '/iserver/services/maps/rest/maps/World/zxyTileImage.png?z={z}&x={x}&y={y}&transparent=true&cacheEnabled=false&noWrap=true&layersID=' + result.newResourceID],
                    "tileSize": 256,
                });

                map.addLayer({
                    "id": "themeLayer",
                    "type": "raster",
                    "source": "theme",
                });

            }

...