首页 / 浏览问题 / 组件GIS / 问题详情
vue3中引入@supermap/iclient-ol 使用 iServer 矢量瓦片服务
3EXP 2025年01月14日
let styleURL = 'https://iserver.supermap.io/iserver/services/map-china400/restjsr/v1/vectortile/maps/China_4326/style.json'
  var format = new MVT();
  var style = new MapboxStyles({
    style: styleURL,
    map: map.value
  })
  let vectorLayer = new VectorTileLayer({
    declutter: true,
    source: new VectorTileSuperMapRest({
      url: styleURL,
      projection: 'EPSG:4326',
      format: format
    }),
    style: style.getStyleFunction()
  });
  map.value.addLayer(vectorLayer)

使用产品:supermap/iclient-ol 操作系统:win11
数据类型:iServer 矢量瓦片服务
问题详细描述:接口报错告诉我404
 

1个回答

您好,麻烦贴一下报错信息,如果是OpenLayers的api提示undefined,需要看看引用是否有问题,参考:

https://iclient.supermap.io/web/introduction/openlayersDevelop.html

https://blog.csdn.net/supermapsupport/article/details/109294147

1,141EXP 2025年01月14日

报错如上图所示

您这个是瓦片获取报404,请求格式不对,用vectorstyles,应该是rest服务。这个url才能访问到:https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China_4326/tileFeature/vectorstyles.json?type=MapBox_GL

感谢您的回复,假如是这种iserver/services/map-mvt-river/restjsr/v1/vectortile/maps/river/style.json,我需要添加到地图上应该用何种方式

感谢您的回复,私下试了一下还是报错

加载restjsr可以用下面的代码:

var url = "https://iserver.supermap.io/iserver/services/map-Jingjin/restjsr/v1/vectortile/maps/%E4%BA%AC%E6%B4%A5%E5%9C%B0%E5%8C%BA%E5%9C%B0%E5%9B%BE";
var styleUrl = url + "/style.json";
$.get(styleUrl, function (styleJson){
    console.log(styleJson)
    var style = new ol.supermap.MapboxStyles({
        style: styleJson,
        source: styleJson.name,
        resolutions: resolutions,
        map: map
    })
    var tileUrl = url + "/tiles/{z}/{x}/{y}.mvt";
    style.on('styleloaded', function () {
            vectorLayer = new ol.layer.VectorTile({
                //设置避让参数
                declutter: true,
                source: new ol.source.VectorTile({
                    projection: 'EPSG:4326',
                    url: tileUrl,
                    wrapX: false,
                    tileGrid: new ol.tilegrid.TileGrid({
                        resolutions: resolutions,
                        origin: [-180, 90],
                        tileSize: 512
                    }),
                    format: format
                }),
                style: style.getStyleFunction()
            });
            map.addLayer(vectorLayer);
        }
    )
}) 

你好,我这边没有接收到json格式的数据。这边是哪里有问题吗

...