1234567891011121314151617181920212223242526272829303132 |
- import {WFS,GeoJSON} from 'ol/format';
- export default class searchWfs{
- constructor(filter){
- this.filter = filter//传入要增删改的图层数据
- }
- requestData(callback){
- var features = null;
- var featureRequest = new WFS().writeGetFeature({
- srsName: 'EPSG:3857',
- featureNS: 'Http://localhost:8084/geoserver/test',
- featurePrefix: 'build',
- featureTypes: ['shop'],
- outputFormat: 'application/json',
- filter: this.filter
- });
-
- console.time('aaa')
- fetch('http://localhost:8084/geoserver/test/ows?', {
- method: 'POST',
- body: new XMLSerializer().serializeToString(featureRequest)
- }).then(function (response) {
- return response.json();
- }).then(function (json) {
- features = new GeoJSON().readFeatures(json);
- callback(features);
- console.log(features);
- }).catch(console.log('查询失败'))
- console.timeEnd('aaa')
- }
- }
|