使用矢量瓦片

矢量瓦片是将矢量数据通过不同的描述文件来组织和定义,在客户端实时解析数据和完成绘制。SuperMap iServer 提供了矢量瓦片图层源,即 ol.source.VectorTileSuperMapRest.optionsFromMapJSON(url,mapJSONObj) 其中:

  • url:地图服务地址
  • mapJSONObj:地图JSON对象(由 getMapInfor() 方法返回的 JSON 数据格式的地图对象)

使用默认风格的矢量瓦片示例

new ol.supermap.MapService(url).getMapInfo(function (serviceResult) {
//矢量瓦片风格参数对象
var stylesOptions = {
    url: url,
    view: map.getView()
};
//创建瓦片风格对象
var vectorTileStyles = new ol.supermap.VectorTileStyles(stylesOptions);
//通过地图信息获取瓦片参数对象
var vectorTileOptions = ol.source.VectorTileSuperMapRest.optionsFromMapJSON(url, serviceResult.result);
//添加矢量瓦片图层
var vectorLayer = new ol.layer.VectorTile({
    source: new ol.source.VectorTileSuperMapRest(vectorTileOptions),
    style: vectorTileStyles.getFeatureStyle
});
map.addLayer(vectorLayer);

查看完整示例代码

查看更多风格的矢量瓦片地图示例代码:http://iclient.supermap.io/examples/openlayers/examples.html#viz-vectorTileLaye

results matching ""

    No results matching ""