Just done a quick test on the urls and the only one that supports CORS is: https://geodata.nationaalgeoregister.nl/ahn2/wfs so looks like proxy is your only option.
On Saturday, October 22, 2016 at 1:49:34 PM UTC+1, crossdomain wrote: > > Hello, Thanks for your answer! > > I tried your example but it doesn't work with for example this site: > > " > http://gisopenbaar.overijssel.nl/data/B4/wfs?request=getcapabilities&typename=weidegebieden > > <http://www.google.com/url?q=http%3A%2F%2Fgisopenbaar.overijssel.nl%2Fdata%2FB4%2Fwfs%3Frequest%3Dgetcapabilities%26typename%3Dweidegebieden&sa=D&sntz=1&usg=AFQjCNHbmNYk5kbNCd1TmsMXlitPbZ10EQ> > " > > get a error: CORS-header ‘Access-Control-Allow-Origin’ is not > enabled........ > > I know that you can pass this through Yql. Because i use it for > GetCapabilities to recieve the layers. Ad thats working fine. > But i don't know how to use the recieved data to make the weidegebieden > visible.:: > > var site = " > http://gisopenbaar.overijssel.nl/data/B4/wfs?request=getcapabilities&typename=weidegebieden > > <https://www.google.com/url?q=https%3A%2F%2Fgeodata.nationaalgeoregister.nl%2Fahn2%2Fwfs&sa=D&sntz=1&usg=AFQjCNHXymQUwL0sPuPtaqM42NJvHcp6oA> > "; > // Take the provided url, and add it to a YQL query. Make sure you > encode it! > var yql1 = 'http://query.yahooapis.com/v1/public/yql?q=' + > encodeURIComponent('select * from xml where url="' + site + '"') + > '&format=xml&callback=?'; > > // Request that YSQL string, and run a callback function. > $.getJSON(yql, cbFunc); > > function cbFunc(data) { > // what to do with the data..... > if (data.results[0]) { > >>>>>>Use the data to make the wfs weidegebieden visible!!!!!!! But > how???<<<<<< > WfsOn(); <<<<<call the WFS like this or??????? > } > // ELSE Foutmelding > else alert('error.'); > } > }; > > WFS call: > var layerWFS = new ol.layer.Vector({ > source: new ol.source.Vector({ > loader: function(extent) {; > $.ajax( document.getElementById("url").value, { > data: { > service: 'WFS', > version: '1.1.0', > request: 'getfeature', > typename: document.getElementById("layer").value, > > srsname: 'EPSG:3857', > bbox: extent.join(',') + ',EPSG:3857' > }, > }) > .done(function(response) { > layerWFS > .getSource() > .addFeatures(new ol.format.WFS() > .readFeatures(response)); > }); > }, > strategy: ol.loadingstrategy.bbox, > }) > }); > > function WfsOn(){ > map.addLayer(layerWFS); > } > -- You received this message because you are subscribed to the Google Groups "OL3 Dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/ol3-dev. To view this discussion on the web visit https://groups.google.com/d/msgid/ol3-dev/2b6ac7db-7045-4620-89eb-75eab982dac4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
