首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >geoserver到openlayers wfst

geoserver到openlayers wfst
EN

Stack Overflow用户
提问于 2019-04-10 03:17:04
回答 1查看 90关注 0票数 0

我想使用以下代码在开放图层中显示我的地理服务器图层,但是我无法获得正确的url格式以输入以下图层的url- localhost:8080/geoserver/itachi/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=itachi%3Awfs_geom&maxFeatures=50

代码语言:javascript
运行
复制
var sourceWFS = new ol.source.Vector({            
    loader: function (extent) {
        $.ajax('https://gsx.geolytix.net/geoserver/geolytix_wfs/ows', {
            type: 'GET',
            data: {
                service: 'WFS',
                version: '1.1.0',
                request: 'GetFeature',
                typename: 'wfs_geom',
                srsname: 'EPSG:3857',
                bbox: extent.join(',') + ',EPSG:3857'
            }
        }).done(function (response) {
            sourceWFS.addFeatures(formatWFS.readFeatures(response));
        });
    },
EN

回答 1

Stack Overflow用户

发布于 2019-04-10 18:40:00

您可以使用完整的url来完成此操作。

代码语言:javascript
运行
复制
var sourceWFS = new ol.source.Vector({
    url: 'http://localhost:8080/geoserver/itachi/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=itachi%3Awfs_geom&maxFeatures=50',
    format: formatWFS
});

但如果您需要更改投影(例如,数据在EPSG:4326中返回,视图在EPSG:3857中返回),则需要使用加载器

代码语言:javascript
运行
复制
var sourceWFS = new ol.source.Vector({
    loader: function () {
        $.ajax('http://localhost:8080/geoserver/itachi/ows', {
            type: 'GET',
            data: {
                service: 'WFS',
                version: '1.0.0',
                request: 'GetFeature',
                typename: 'itachi:wfs_geom',
                maxFeatures: '50'
            }
        }).done(function (response) {
            sourceWFS.addFeatures(formatWFS.readFeatures(response),{
                dataProjection: 'EPSG:4326',
                featureProjection: 'EPSG:3857'
            });
        });
    },
    strategy: ol.loadingstrategy.all
});

如果数据可以更新,则需要调用sourceWFS.refresh();来重新加载

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55599801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档