2

I created a sqlview(villagefilter_view) in GeoServer and added one parameter %vilselected%

select * from niphad_survey where village=%vilselected%

Name: vilselected
Default value: 'Ranwad'
Validation regular expression: /^[a-zA-Z]+$/

I tried to pass the parameter from a selec option onchange value with vilSelectForView name.

Following is my code to genarate request url from GeoServer

var niphadSurveyVectorSource = new ol.source.Vector({
        loader: function(extent) {
            $.ajax('http://localhost:8080/geoserver/postgis_22_sample/wfs', {
                type: 'GET',
                data:{
                    service: 'WFS',
                    version: '1.1.0',
                    request: 'GetFeature',                  
                    typename: 'villagefilter_view',
                    viewparams: "vilselected:"+vilSelectForView,
                    srsname: 'EPSG:3857',                   
                    bbox: extent.join(',') + ',EPSG:3857'
                }
            }).done(function(response) {

         niphadSurveyVectorSource.addFeatures(formatWFS.readFeatures(response));
            });
        },
        strategy: ol.loadingstrategy.bbox,
        projection: 'EPSG:3857'
    });

After page lode the default parameter data is loading on map but onchange my select option the parameter is not passing to request URL.

How can I load the dynamic view data on map by onchange with the village name?

  • what value are you trying to send? please look in the debugger and check the url being sent and add it to the question, then look in the GeoServer log file and see if there is an error there – Ian Turton Feb 28 '18 at 13:25
  • The request url: localhost:8080/geoserver/postgis_22_sample/… – narayanam Mar 1 '18 at 4:04
  • Error is: <ows:Exception exceptionCode="NoApplicableCode"> <ows:ExceptionText> java.lang.RuntimeException: java.io.IOException java.io.IOExceptionERROR: column "welapur" does not exist Position: 94 </ows:ExceptionText> </ows:Exception> – narayanam Mar 1 '18 at 4:06
  • it seems that your table has changed and has lost a column – Ian Turton Mar 1 '18 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.