问题描述
我在 .shp
中加载了 QGIS
文件,并在 Export to Postgresql
窗格中使用 Processing ToolBox
命令将其导出。
然后我开始使用 pg_tileserv.exe
来提供矢量切片,正如您在此屏幕截图中看到的 - 它在浏览器中可见(蓝色轮廓线)。
我遇到的问题是,如果添加为 XYZ Tiles
(或者如果我尝试使用我的代码和 OpenLayers js 库在浏览器中显示),则在 QGIS 中显示这些矢量图块。正如您在此屏幕截图中看到的那样,我添加了 XYZ Tiles
,但它只是保持空白 - 我看不到右窗格中的地图(在屏幕截图中,复选框未选中,但即使选中也没有任何反应。我也尝试过改变风格等...):
如果我直接从 Postgresql 加载数据,它会加载并显示 OK:
有人知道这里有什么问题吗?
更新
正如@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 (将#修改为@)