I have recently updated from OpenLayers 3.0 to 3.7 and I noticed in the 3.5 update the Vector API has changed, I tried to alter the code as per the bottom section of code but i am getting the error below:
XMLHttpRequest cannot load http://PCNAME:8080/geoserver/exampl...39279004,-170676.01567195728,7073596.83725834. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.Code as per below:
var vectorFeatures = function(response) { var features = vectorSource.readFeatures(response); vectorSource.addFeatures(features); }; var geoJSONFormat = new ol.format.GeoJSON(); var vectorSource = new ol.source.Vector({ loader: function(extent, resolution, projection) { var url = 'http://PCNAME:8080/geoserver/Example/ows?service=WFS&' + 'version=1.0.0&request=GetFeature&typeName=Example:layer_1&' + 'outputFormat=text/javascript&format_options=callback:vectorFeatures' + '&srsname=EPSG:3857&bbox=' + extent.join(','); $.ajax({ url: url, success: function(data) { var features = geoJSONFormat.readFeatures(data); vectorSource.addFeatures(features); } }); }, strategy: ol.loadingstrategy.bbox });
أكثر...
XMLHttpRequest cannot load http://PCNAME:8080/geoserver/exampl...39279004,-170676.01567195728,7073596.83725834. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.Code as per below:
var vectorFeatures = function(response) { var features = vectorSource.readFeatures(response); vectorSource.addFeatures(features); }; var geoJSONFormat = new ol.format.GeoJSON(); var vectorSource = new ol.source.Vector({ loader: function(extent, resolution, projection) { var url = 'http://PCNAME:8080/geoserver/Example/ows?service=WFS&' + 'version=1.0.0&request=GetFeature&typeName=Example:layer_1&' + 'outputFormat=text/javascript&format_options=callback:vectorFeatures' + '&srsname=EPSG:3857&bbox=' + extent.join(','); $.ajax({ url: url, success: function(data) { var features = geoJSONFormat.readFeatures(data); vectorSource.addFeatures(features); } }); }, strategy: ol.loadingstrategy.bbox });
أكثر...