微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

QGIS - 渲染矢量瓦片

如何解决QGIS - 渲染矢量瓦片

我在 .shp 中加载了 QGIS 文件,并在 Export to Postgresql 窗格中使用 Processing ToolBox 命令将其导出。 然后我开始使用 pg_tileserv.exe 来提供矢量切片,正如您在此屏幕截图中看到的 - 它在浏览器中可见(蓝色轮廓线)。

enter image description here

我遇到的问题是,如果添加XYZ Tiles(或者如果我尝试使用我的代码和 OpenLayers js 库在浏览器中显示),则在 QGIS 中显示这些矢量图块。正如您在此屏幕截图中看到的那样,我添加XYZ Tiles,但它只是保持空白 - 我看不到右窗格中的地图(在屏幕截图中,复选框未选中,但即使选中也没有任何反应。我也尝试过改变风格等...):

enter image description here

如果我直接从 Postgresql 加载数据,它会加载并显示 OK:

enter image description here

有人知道这里有什么问题吗?

更新

正如@JGH 所说,我应该使用列表中的 Vector Tiles。现在看看为什么 OpenLayers 配置没有渲染它:

import 'ol/ol.css';
import MVT from 'ol/format/MVT';
import Map from 'ol/Map';
import VectorTileLayer from 'ol/layer/VectorTile';
import VectorTileSource from 'ol/source/VectorTile';
import View from 'ol/View';
import {Fill,Icon,stroke,Style,Text} from 'ol/style';

const key =
    '';

const map = new Map({
  layers: [
    new VectorTileLayer({
      declutter: true,source: new VectorTileSource({
        attributions:
            '© <a href="https://www.mapBox.com/map-Feedback/">MapBox</a> ' +
            '© <a href="https://www.openstreetmap.org/copyright">' +
            'OpenStreetMap contributors</a>',format: new MVT(),url:
            'http://localhost:7800/public.simplified_land_polygons/' +
            '{z}/{x}/{y}.pbf' +
            key,}),style: createMapBoxStreetsV6Style(Style,Fill,Text),],target: 'map',view: new View({
    center: [0,0],zoom: 1,});

更新 2

是的,这是由于风格。改完后就可以看到了!

style: new Style({
  fill: new Fill({
    color: 'red'
  }),stroke: new stroke({
    color: 'white',width: 1.25
  }),image: new Circle({
    radius: 5,fill: new Fill({
      color: 'red'
    }),stroke: new stroke({
      color: 'white',width: 1.25
    })
  })

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。