2

I try to be as simple as possible with my problem. It's just to display a json layer from my Geoserver on a OSM layer with a ol3.16 page.

I take the example from this page: http://openlayers.org/en/latest/example … -wfs.html

I take the code of this page and change ONLY the geoserver query to my layer. I get the OSM layer and nothing else.

I open the inspector window in Firefox for both pages (the example and mine).

With the example page, the query call is done and I get a response of 200ko. With my page, the call is done and the response size is 0ko.

To check my query I copy-paste the url from the inspector window in the adress bar, and then I get the json data. If I save it in a file, I have no problem to loads it in another ol3.16 page as a local file.

Then, the query is well formed, it's sent to geoserver and Geoserver dont sent the response only to my page. Anyone have an idea why????

  • Do the demos work from your geoserver instance? Possible CORS issue, but difficult to say unless you show the actual configuration / query. – BradHards Jul 1 '16 at 8:21
1

the problem could be from the CORS not enabled, if your web page is in a web server not in geoserver, you can either:

1- put your web page in the www folder inside geoserver/data_dir and lauch it from there

2 - or if you need to launch it from a web server ( apache for example ) you will have to enable JSONP in your geoserver configuration like this :

  • go to yourGeoServer\webapps\geoserver\WEB-INF\web.xml
  • look for JSONP and uncomment the balises
 <context-param>
    <param-name>ENABLE_JSONP</param-name>
    <param-value>true</param-value>
 </context-param>
  • now in your JS code change the format of data to text/javascript instead of application/json. and add in your ajax call

    dataType: 'jsonp'

now restart geoserver and your WFS layer will appear

  • I put it in the WWW folder ans it's working Thanks a lot! – atilio francois Jul 3 '16 at 8:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.