openlayer 加载wfs 2种方式
1.geojson
var geo = new OpenLayers.Layer.Vector("EarthQuake", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: 'http://172.31.170.98:8088/geoserver/weidong/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=weidong:weidong-vectorlayer&maxFeatures=50&outputFormat=application/json',
format: new OpenLayers.Format.GeoJSON({ignoreExtraDims: true})
})
});
2.KML
buildsLayer = new OpenLayers.Layer.Vector('矢量图层', {
projection: new OpenLayers.Projection('EPSG:4326'),
protocol: new OpenLayers.Protocol.HTTP({
url: 'http://172.31.170.98:8088/geoserver/weidong/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=weidong:weidong-vectorlayer&maxFeatures=50',
format: new OpenLayers.Format.GML({
extractAttributes:true
})
}),
strategies: [new OpenLayers.Strategy.BBOX()]
});
var buildsLayer_style = new OpenLayers.Style({
'fillOpacity': 0,
'fillColor':"yellow",
'strokeColor': 'yellow',
'strokeWidth': 0,
'pointRadius': 8
});
var buildsLayer_style_map = new OpenLayers.StyleMap({
'default': buildsLayer_style
});
buildsLayer.styleMap = buildsLayer_style_map;
url可以在geoserver 中预览视图中得到
转载自:https://blog.csdn.net/wd4java/article/details/46602583