0 安装Vector Tiles扩展
- 链接:官方下载地址
- 解压扩展包,将解压文件夹内的jar包全部copy进geoserver WEB-INF/lib文件夹内
- 重启geoserver服务即可,安装成功的标志为:Layers -> Tile Caching -> Tile Formats下增加了三种切片方式:
application/json;type=geojson
application/json;type=topojson
application/vnd.mapbox-vector-tile(推荐使用方式)
- 矢量切片最适合的应用方向在于对渲染速度有要求的前提下对图层style的定制化需求。
1 OpenLayers中调用
import MVT from "ol/format/MVT";
import VectorTileLayer from "ol/layer/VectorTile";
import VectorTileSource from "ol/source/VectorTile";
const v = new VectorTileLayer({
declutter: true,
source: new VectorTileSource({
format: new MVT(),
url: "http://localhost:8081/geoserver/gwc/service/tms/1.0.0/
heny_power:hn_power_p@EPSG:900913@pbf/{z}/{x}/{-y}.pbf",
}),
});
this.mMap.addLayer(v);