GMLデータを提供する公開されているWFSサーバーを照会することで、OpenLayersマップに機能を追加しようとしています。ベクトルデータを追加する - WMLトランスポートを使用したGMLフォーマット
// initalize the map
var map = new ol.Map({
layers: [
new ol.layer.Tile({
// OpenLayers public map server
source: new ol.source.OSM()
}),
],
target: 'map',
view: new ol.View({
// center on Murica
center: [-10997148, 4569099],
zoom: 4
})
});
var xmlhttp = new XMLHttpRequest();
// execute this once the remote GML xml document has loaded
xmlhttp.onload = function() {
console.log("GML XML document retrieved. executing onload handler:");
var format = new ol.format.GML3();
var xmlDoc = xmlhttp.responseXML;
console.log("you will see multiple features in the xml: ");
console.log(xmlDoc);
// Read and parse all features in XML document
var features = format.readFeatures(xmlDoc, {
featureProjection: 'EPSG:4326',
dataProjection: 'EPSG:3857'
});
console.log("for some reason only a single feature will have been added: ")
console.log(features);
console.log("Why is this?");
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
format: format
})
});
// Add features to the layer's source
vector.getSource().addFeatures(features);
map.addLayer(vector);
};
// configure a GET request
xmlhttp.open("GET", "http://geoint.nrlssc.navy.mil/dnc/wfs/DNC-WORLD/feature/merged?version=1.1.0&request=GetFeature&typename=DNC_APPROACH_LIBRARY_BOUNDARIES&srsname=3857",
true);
// trigger the GET request
xmlhttp.send();
ここには、このバグが実証されたCodePenがあります。ここで
http://codepen.io/anon/pen/yamOEK
あなたはそれが単一のHTMLファイルにパッケージダウンロードすることができます。 https://drive.google.com/open?id=0B6L3fhx8G3H_cmp1d3hHOXNKNHM
私は正常に有効な型名を使用して、私の変数XMLDOCに複数の機能を備えた全体の機能のコレクションをダウンロードすることができます。しかし、私がformat.ReadFeatures(xmlDoc)を使用すると、OpenLayers GML形式のパーサーはフィーチャーコレクションから単一のフィーチャーを抽出しているように見えますが、より多くを抽出する必要があります。
誰かが見て、私が何かばかげて間違ってやっているのか、それともOpenLayers3の正当なバグなのかわかるかどうかは分かります。助けてくれる人のためにありがとう!
クロスポストhttps://gis.stackexchange.com/q/216125/115 – PolyGeo