我是OpenLayers3的初学者,我在这个网站上是新的,所以这是我的第一个问题,希望我在这里正确地放弃它。对我不起作用的是打开一个(不是瓷砖?)OpenLayers3中的WFS层。我使用了一个开放层站点的WFS示例(这也是因为它似乎是一个相对简单的代码)。我试图在我的教科书OpenLayers3中找到一个解决方案,在开放层的网站上,与谷歌和这个网站,但没有成功。下面是我用OpenLayers的例子编写的代码,但是现在我认为打开这个WFS应该是另一个WFS。我做错了什么?
// working example from: http://openlayers.org/en/v3.13.1/examples/vector-wfs.html
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: function(extent) {
return 'http://demo.boundlessgeo.com/geoserver/wfs?service=WFS&' +
'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
'outputFormat=application/json&srsname=EPSG:3857&' +
'bbox=' + extent.join(',') + ',EPSG:3857';
},
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
maxZoom: 19
}))
});
var vector1 = new ol.layer.Vector({
source: vectorSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(0, 255, 255, 1.0)',
width: 2
})
})
}); //基于上述示例代码的不工作代码
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: function(extent) {
return 'https://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?service=WFS&' +
'version=1.1.0&request=GetFeature&typename=bestuurlijkegrenzen:gemeenten&' +
'outputFormat=application/json&srsname=EPSG:28992&' +
'bbox=' + extent.join(',') + ',EPSG:28992';
},
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
maxZoom: 19
}))
});
var vector = new ol.layer.Vector({
source: vectorSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(0, 255, 255, 1.0)',
width: 2
})
})
});发布于 2016-02-15 13:29:24
除非你提供完整的代码,否则我只能做一些猜测。你的两层有不同的投影。我猜您使用epsg:3857作为视图投影,因此使用此范围的坐标将返回0特性。首先要尝试的是使用视图的投影从geoserver请求您的层。
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: function(extent) {
return 'https://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?service=WFS&' +
'version=1.1.0&request=GetFeature&typename=bestuurlijkegrenzen:gemeenten&' +
'outputFormat=application/json&srsname=EPSG:3857&' +
'bbox=' + extent.join(',') + ',EPSG:3857';
},
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
maxZoom: 19
}))
});这将迫使geoserver在服务器端进行重投影。我建议先试试上面的方法,确保这是你的案子。然后,无论您想要在客户端还是服务器端进行重新注入,您都必须退却。
https://stackoverflow.com/questions/35409506
复制相似问题