openlayers wfs服务点加载

fetch('geoserver/gzzjygis/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=layername&maxFeatures=100000&outputFormat=application%2Fjson', {
          method: 'GET',
        }).then(function(response) {
            return response.json();
        }).then(function(json) {
            var features = new GeoJSON().readFeatures(json);  
            var testLayer = new VectorLayer({
              source: new VectorSource({
                features
              }),
              style: function(feature) {
                var value=feature.getProperties().price;
                if(value>1000|| value<200){                  
                  return new Style({
                    image: new CircleStyle({
                      radius: 5,
                      fill: new Fill({color: `rgba(255,0,0,0.7)`}),
                      //stroke: new Stroke({color: '#bada55', width: 1})
                    })
                  });
                }
                return new Style({
                  image: new CircleStyle({
                    radius: 2,
                    fill: new Fill({color: `rgba(100,100,100,0.4)`}),
                    //stroke: new Stroke({color: '#bada55', width: 1})
                  })
                });
              }
            });
            map.addLayer(testLayer);
        });

 

转载自:https://blog.csdn.net/whq12789/article/details/86699917

You may also like...