Commit fa7e3715 authored by Giuseppe La Scaleia's avatar Giuseppe La Scaleia

Add Complete Mapping for OL 2.12

parent ba05a9fd
......@@ -82,7 +82,8 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
*/
initialize: function(options) {
if(window.ActiveXObject) {
this.xmldom = new ActiveXObject("Microsoft.XMLDOM");
// this.xmldom = new ActiveXObject("Microsoft.XMLDOM");
this.xmldom = this._getIEXmlDom();
}
OpenLayers.Format.prototype.initialize.apply(this, [options]);
// clone the namespace object and set all namespace aliases
......@@ -93,6 +94,41 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
}
},
/** PrivateFunction: _getIEXmlDom
* Gets IE xml doc object
*
* Returns:
* A Microsoft XML DOM Object
* See Also:
* http://msdn.microsoft.com/en-us/library/ms757837%28VS.85%29.aspx
*/
_getIEXmlDom : function() {
var doc = null;
var docStrings = [
"Msxml2.DOMDocument.6.0",
"Msxml2.DOMDocument.5.0",
"Msxml2.DOMDocument.4.0",
"MSXML2.DOMDocument.3.0",
"MSXML2.DOMDocument",
"MSXML.DOMDocument",
"Microsoft.XMLDOM"
];
for (var d = 0; d < docStrings.length; d++) {
if (doc === null) {
try {
doc = new ActiveXObject(docStrings[d]);
} catch (e) {
doc = null;
}
} else {
break;
}
}
return doc;
},
/**
* APIMethod: destroy
* Clean up.
......@@ -147,21 +183,21 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
xmldom.loadXML(text);
return xmldom;
}
), this),
), this),
function() {
return new DOMParser().parseFromString(text, 'text/xml');
},
function() {
var req = new XMLHttpRequest();
req.open("GET", "data:" + "text/xml" +
";charset=utf-8," + encodeURIComponent(text), false);
";charset=utf-8," + encodeURIComponent(text), false);
if(req.overrideMimeType) {
req.overrideMimeType("text/xml");
}
req.send(null);
return req.responseXML;
}
);
);
if(this.keepData) {
this.data = node;
......@@ -281,7 +317,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
for(var i=0, len=allNodes.length; i<len; ++i) {
potentialNode = allNodes[i];
fullName = (potentialNode.prefix) ?
(potentialNode.prefix + ":" + name) : name;
(potentialNode.prefix + ":" + name) : name;
if((name == "*") || (fullName == potentialNode.nodeName)) {
if((uri == "*") || (uri == potentialNode.namespaceURI)) {
elements.push(potentialNode);
......@@ -315,7 +351,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
potentialNode = attributes[i];
if(potentialNode.namespaceURI == uri) {
fullName = (potentialNode.prefix) ?
(potentialNode.prefix + ":" + name) : name;
(potentialNode.prefix + ":" + name) : name;
if(fullName == potentialNode.nodeName) {
attributeNode = potentialNode;
break;
......@@ -414,7 +450,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
*/
contentType: function(node) {
var simple = false,
complex = false;
complex = false;
var type = OpenLayers.Format.XML.CONTENT_TYPE.EMPTY;
......@@ -485,7 +521,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
if(uri) {
var attribute = node.ownerDocument.createNode(
2, name, uri
);
);
attribute.nodeValue = value;
node.setAttributeNode(attribute);
} else {
......@@ -721,7 +757,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
switch(sibling.nodeType) {
case 1: // Element
if((!name || name === (sibling.localName || sibling.nodeName.split(":").pop())) &&
(!uri || uri === sibling.namespaceURI)) {
(!uri || uri === sibling.namespaceURI)) {
// matches
break outer;
}
......@@ -740,7 +776,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
break outer;
} // ignore comments and processing instructions
}
return sibling || null;
return sibling || null;
},
/**
......@@ -803,7 +839,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
case 10: // DOCUMENT_TYPE_NODE
case 11: // DOCUMENT_FRAGMENT_NODE
break outer;
default:
default:
// TEXT_NODE (3), CDATA_SECTION_NODE (4), ENTITY_REFERENCE_NODE (5),
// PROCESSING_INSTRUCTION_NODE (7), COMMENT_NODE (8)
uri = this.lookupNamespaceURI(node.parentNode, prefix);
......@@ -829,7 +865,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
if (!OpenLayers.Format.XML.document && !this.xmldom) {
if (document.implementation && document.implementation.createDocument) {
OpenLayers.Format.XML.document =
document.implementation.createDocument("", "", null);
document.implementation.createDocument("", "", null);
} else if (!this.xmldom && window.ActiveXObject) {
this.xmldom = new ActiveXObject("Microsoft.XMLDOM");
}
......@@ -841,7 +877,12 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
});
OpenLayers.Format.XML.CONTENT_TYPE = {EMPTY: 0, SIMPLE: 1, COMPLEX: 2, MIXED: 3};
OpenLayers.Format.XML.CONTENT_TYPE = {
EMPTY: 0,
SIMPLE: 1,
COMPLEX: 2,
MIXED: 3
};
/**
* APIFunction: OpenLayers.Format.XML.lookupNamespaceURI
......@@ -867,7 +908,7 @@ OpenLayers.Format.XML.CONTENT_TYPE = {EMPTY: 0, SIMPLE: 1, COMPLEX: 2, MIXED: 3}
OpenLayers.Format.XML.lookupNamespaceURI = OpenLayers.Function.bind(
OpenLayers.Format.XML.prototype.lookupNamespaceURI,
OpenLayers.Format.XML.prototype
);
);
/**
* Property: OpenLayers.Format.XML.document
......
......@@ -1116,7 +1116,7 @@ OpenLayers.Map = OpenLayers.Class({
}
}
this.resetLayersZIndex();
// this.resetLayersZIndex();
this.events.triggerEvent("removelayer", {layer: layer});
layer.events.triggerEvent("removed", {map: this, layer: layer});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment