通过wfs方式向后台geoserver请求矢量数据,然后在前端通过vectorlayer展示出来,增强交互效果。
function getParkingLayerFunc(mapUrl,parkingLayerName){
//获取该坐标系下地图边界
var projectionExtent = ****.projection.getExtent();
var namespace = ****.mapSpace;
//wfs请求获取矢量图层gml数据信息
****.vectorSource = new ol.source.Vector({
loader : function(resolution, projection) {
var dataUrl = mapUrl+'/geoserver/wfs?'
+ 'service=WFS&request=GetFeature&'
+ 'version=1.1.0&typename='
+namespace
+ ':'
+ parkingLayerName;
$.ajax({
url : dataUrl
}).done(function(response) {
var format = new ol.format.WFS({
featureNS : 'http://www.'+namespace+'.com',
featureType : parkingLayerName
});
var features = format.readFeatur