openlayer 加载wfs 2种方式

来源:互联网 发布:如何解除冻结淘宝封号 编辑:程序博客网 时间:2024/05/01 18:38

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 中预览视图中得到

0 0
原创粉丝点击