Hello,
 
With the script down i try to go cross domain and add a wfs to my map:
 
This is my WFS call and this one *don't works* because it must go *cross 
domain*.. 
With open sites it works. 
 
*javascript*:

   var layerWFS = new ol.layer.Vector({
      source: new ol.source.Vector({
    loader: function(extent) {
      $.ajax("http://gisopenbaar.overijssel.nl/data/B4/wfs? 
<https://geodata.nationaalgeoregister.nl/ahn2/wfs>", {

     type: 'GET',
     data: {
       service: 'WFS',
       version: '1.1.0',
       request: 'getfeature',
       typename: 'B4:Heidegebieden',     
       srsname: 'EPSG:3857',
       bbox: extent.join(',') + ',EPSG:3857'
     },
      })
      .done(function(data) {
     layerWFS
     .getSource()
     .addFeatures(new ol.format.WFS()
       .readFeatures(data));    
      });      
    },
    strategy: ol.loadingstrategy.bbox,
     })
   });
            
 function WfsOn(){        
     map.addLayer(layerWFS);
 }
____________________________________
*This is what i tried till now to get it crossdomain with YQL:*
 
*html:*

<textarea id="wfsdata"></textarea>
 
*javascript*:

function wfsdata() {
    var site = "http://gisopenbaar.overijssel.nl/data/B4/wfs? 
<https://geodata.nationaalgeoregister.nl/ahn2/wfs>
request=GetFeature&typename=B4:Heidegebieden 
<https://geodata.nationaalgeoregister.nl/ahn2/wfs?request=GetFeature&typename=ahn2:ahn2_bladindex>
";
   // 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]) {
      var headline = data.results[0];
      wfsdata.value = headline;
       wfsgetdata();
      
     }
     // ELSE Foutmelding
     else alert('error.');
    }
   };
 
function wfsgetdata() {
    var value = $("#wfsdata").val().replace(/\n/g, '</br>')
    $('#wfsdata).append(value);
    WfsOn();

}
 
   var layerWFS = new ol.layer.Vector({
      source: new ol.source.Vector({
    loader: function(extent) {
      $.ajax(document.getElementById("wfsdata").value, {
     type: 'GET',
     data: {
       service: 'WFS',
       version: '1.1.0',
       request: 'getfeature',
       typename: 'B4:Heidegebieden',     
       srsname: 'EPSG:3857',
       bbox: extent.join(',') + ',EPSG:3857'
     },
      })
      .done(function(data) {
     layerWFS
     .getSource()
     .addFeatures(new ol.format.WFS()
       .readFeatures(data));   
      });      
    },
    strategy: ol.loadingstrategy.bbox,
     })
   });
 
 function WfsOn(){        
     map.addLayer(layerWFS);
 }
The method: 
1) with the YQL i get the xml data (hope the right data to load a wfs) 
cross domain and place it in the id=wfsdata
2) then i use the data from the id to do the add layerWFS call 

But it don't works..
I thought maybe also works something like this way:

function wfsdata() {
    var site = "http://gisopenbaar.overijssel.nl/data/B4/wfs? 
<https://geodata.nationaalgeoregister.nl/ahn2/wfs>
request=GetFeature&typename=B4:Heidegebieden 
<https://geodata.nationaalgeoregister.nl/ahn2/wfs?request=GetFeature&typename=ahn2:ahn2_bladindex>
";
   // 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]) {
    >>>>>>Push the data on the right place in the ajax call and add the wfs 
to the map. <<<<<<    
     }
     // ELSE Foutmelding
     else alert('error.');
    }
   };


Maybe someone can look at this....
I hope to hear from you.

 
Best regards

-- 
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/821bc926-7f38-4877-94df-f3c9659d2af9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to