OpenLayers 不显示来自 WFS 的矢量

问题描述 投票:0回答:0

我正在使用 OpenLayers 创建 Web GIS 应用程序。我在从 WFS GeoServer 获取数据时遇到困难。数据已正确下载,但未以任何方式绘制。它只是不可见。 WFS 服务器使用抛光单位 - EPSG:2180,所以我在开始时重新投影了它。 WMS 下载完全相同的方式工作正常。

任何帮助表示赞赏。干杯, 米

<!DOCTYPE html>
<html lang="pl">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GEO</title>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.6.2/proj4.js"></script>
    <script src="http://epsg.io/2180.js"></script>
    <script src="./ol.js"></script>
    <link rel="stylesheet" href="./ol.min.css">
</head>
<body>
    <div id="map" class="map" style="width: 800px; height: 800px;"></div>
    
    <script>
        /** 
         * PROJ
        */
        proj4.defs("EPSG:2180","+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs");
        ol.proj.proj4.register(proj4);
        ol.proj.get("EPSG:2180").setExtent([0, 0, 1000000, 1000000]);

        /** 
         * Place
        */
        let miejsce4326 = [18.05165,53.23004] 
        const miejsce = ol.proj.transform(miejsce4326, 'EPSG:4326', 'EPSG:2180');


        /**
         * WFS 
         */
        let compURL = 'https://corsproxy.io/?https://mapy.geoportal.gov.pl/wss/service/PZGIK/mapy/WFS/SiatkiPodzialuArkuszowego?service=WFS&Request=GetFeature&version=1.1.0&srsname=EPSG:2180&typename=ms:Ark_50k_42&outputFormat=GML3'
        const WFSvectorSource = new ol.source.Vector({
            format: new ol.format.GML3(),
            url: function(extent) {
                // console.log(compURL+'&bbox='+extent.join(','))
                return compURL+'&bbox='+extent.join(',');
            },
            
            strategy: ol.loadingstrategy.bbox,
            //draw geoms
            style: new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: '#ffcc33',
                    width: 2
                }),
                fill: new ol.style.Fill({
                    color: 'rgba(255, 255, 255, 0.2)'
                })
            }),
            projection: 'EPSG:2180',
            visible: true,
            opacity: 1,
            zIndex: 100
        });
        const WFSvectorLayer = new ol.layer.Vector({
            source: WFSvectorSource,
            projection: 'EPSG:2180'
        });
        
        /**
         * MAPA init
         */
        var map = new ol.Map({
        layers: [
          new ol.layer.Tile({
            source: new ol.source.OSM(),
            projection: 'EPSG:2180'
          }),
            WFSvectorLayer
        ],
        target: 'map',
        view: new ol.View({
          projection: 'EPSG:2180',
          center: miejsce,
          zoom: 12
        })
      });
    </script>
</body>
</html>

我尝试阅读文档、观看教程等。没有帮助,因为这不是 GeoJSON。该服务器只提供 GML。更改矢量对象的样式参数绝对不会做任何事情,与添加额外参数(如“投影”到矢量源对象)一样。我希望它在作为背景的 OpenStreetMap 上绘制从 WFS 下载的几何图形和多边形。

gis openlayers openlayers-6 epsg wfs
© www.soinside.com 2019 - 2024. All rights reserved.