readFeatures的内容是一个空数组, 读取gml3格式似乎有问题? 然后如何在这些点上放置可点击的符号?
var basiasWfsSource = new ol.source.Vector({
format: new ol.format.GML3(),
loader: function(extent, resolution, projection) {
var proj = projection.getCode();
var url = 'http://geoservices.brgm.fr/risques?&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&typename=BASIAS_LOCALISE&SRSNAME=EPSG:4326&outputformat=gml3&bbox='
+ extent.join(',') + ',' + proj ;
console.log( 'url', url);
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
var onError = function() {
console.log( 'error');
basiasWfsSource.removeLoadedExtent(extent);
}
xhr.onerror = onError;
xhr.onload = function() {
if (xhr.status == 200) {
console.log( 'format', basiasWfsSource.getFormat());
basiasWfsSource.addFeatures(
basiasWfsSource.getFormat().readFeatures(xhr.responseText,{
dataProjection: 'EPSG:4326',
featureProjection:'EPSG:3857' })); //pour adapter la projection à celle de la view
console.log( 'resultat', xhr.responseText);
console.log( 'features', basiasWfsSource.getFormat().readFeatures(xhr.responseText,{
dataProjection: 'EPSG:4326',
featureProjection:'EPSG:3857' }));} else {
onError();
}
}
xhr.send();
},
strategy: ol.loadingstrategy.bbox
});