Исходные данные - сервер ArcGis, отдает WFS с несколькими слоями, OpenLayers (2.11) отображает.
Необоходимо отобразить через OpenLayers.Layer.Vector несколько слоев.
Пример подключения:
Код: Выделить всё
var layer3 = new OpenLayers.Layer.Vector('test', {
styleMap: style,
strategies: [new OpenLayers.Strategy.BBOX()],
projection: new OpenLayers.Projection('EPSG:4326'),
protocol: new OpenLayers.Protocol.WFS({
version: '1.1.0',
srsName: 'EPSG:4326',
url: 'http://XX.XX.XX.XX/ArcGIS/services/TestService/MapServer/WFSServer?request=GetFeature&typeName=mypref:type_a,mypref:type_b',
featureType: ['type_a', 'type_b'],
singleFeatureType: false,
featurePrefix: 'mypref',
geometryName: 'Shape',
readFormat: new OpenLayers.Format.GML.v3({ xy: false })
})
});
Но в результате отображаются только type_a. При отладке выяснилось что при инициализации OpenLayers.Format.GML получает featureType как массив, но при чтении и разборе ответа от сервера featureType уже является строкой "type_a".
Фикс в виде жесткого прописывания внутри парсера
Код: Выделить всё
// lib/OpenLayers/Format/GML/Base.js:380
"*": function(node, obj) {
var name;
var local = node.localName || node.nodeName.split(":").pop();
this.featureType = ['type_a', 'type_b']; // <<<
if (obj.features) {
if (!this.singleFeatureType &&
(OpenLayers.Util.indexOf(this.featureType, local) !== -1)) {
name = "_typeName";
} else if(local === this.featureType) {
name = "_typeName";
}
} else {
// Assume attribute elements have one child node and that the child
// is a text node. Otherwise assume it is a geometry node.
if(node.childNodes.length == 0 ||
(node.childNodes.length == 1 && node.firstChild.nodeType == 3)) {
if(this.extractAttributes) {
name = "_attribute";
}
} else {
name = "_geometry";
}
}
if(name) {
this.readers.feature[name].apply(this, [node, obj]);
}
},
Но возможно кто-то сталкивался с подобной задачей и странным поведением OpenLayers?
Или это некорректной настройка с моей стороны?