首頁 / 浏覽問題 / 組件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個(gè)回答

您好,麻煩貼一(yī / yì /yí)下報錯信息,如果是(shì)OpenLayers的(de)api提示undefined,需要(yào / yāo)看看引用是(shì)否有問題,參考:

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

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

1,191EXP 2025年01月14日

報錯如上(shàng)圖所示

您這(zhè)個(gè)是(shì)瓦片獲取報404,請求格式不(bù)對,用vectorstyles,應該是(shì)rest服務。這(zhè)個(gè)url才能訪問到(dào):https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China_4326/tileFeature/vectorstyles.json?type=MapBox_GL

感謝您的(de)回複,假如是(shì)這(zhè)種iserver/services/map-mvt-river/restjsr/v1/vectortile/maps/river/style.json,我需要(yào / yāo)添加到(dào)地(dì / de)圖上(shàng)應該用何種方式

感謝您的(de)回複,私下試了(le/liǎo)一(yī / yì /yí)下還是(shì)報錯

加載restjsr可以(yǐ)用下面的(de)代碼:

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);
        }
    )
}) 

你好,我這(zhè)邊沒有接收到(dào)json格式的(de)數據。這(zhè)邊是(shì)哪裏有問題嗎

...