Changeset 4798 for branches/openlayers/2.5
- Timestamp:
- 10/03/07 17:18:39 (1 year ago)
- Files:
-
- branches/openlayers/2.5/lib/OpenLayers/Format/KML.js (modified) (6 diffs)
- branches/openlayers/2.5/tests/Format/test_KML.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/2.5/lib/OpenLayers/Format/KML.js
r4432 r4798 49 49 */ 50 50 extractAttributes: true, 51 52 /** 53 * Property: internalns 54 * {String} KML Namespace to use -- defaults to the namespace of the 55 * Placemark node being parsed, but falls back to kmlns. 56 */ 57 internalns: null, 51 58 52 59 /** … … 84 91 } 85 92 var featureNodes = this.getElementsByTagNameNS(data, 86 this.kmlns,93 '*', 87 94 "Placemark"); 88 95 var numFeatures = featureNodes.length; … … 117 124 for(var i=0; i<order.length; ++i) { 118 125 type = order[i]; 119 nodeList = this.getElementsByTagNameNS(node, this.kmlns, type); 126 this.internalns = node.namespaceURI ? 127 node.namespaceURI : this.kmlns; 128 nodeList = this.getElementsByTagNameNS(node, 129 this.internalns, type); 120 130 if(nodeList.length > 0) { 121 131 // only deal with first geometry of this type … … 166 176 */ 167 177 point: function(node) { 168 var nodeList = this.getElementsByTagNameNS(node, this. kmlns,178 var nodeList = this.getElementsByTagNameNS(node, this.internalns, 169 179 "coordinates"); 170 180 var coords = []; … … 201 211 */ 202 212 linestring: function(node, ring) { 203 var nodeList = this.getElementsByTagNameNS(node, this. kmlns,213 var nodeList = this.getElementsByTagNameNS(node, this.internalns, 204 214 "coordinates"); 205 215 var line = null; … … 255 265 */ 256 266 polygon: function(node) { 257 var nodeList = this.getElementsByTagNameNS(node, this. kmlns,267 var nodeList = this.getElementsByTagNameNS(node, this.internalns, 258 268 "LinearRing"); 259 269 var numRings = nodeList.length; branches/openlayers/2.5/tests/Format/test_KML.html
r4432 r4798 29 29 } 30 30 31 function test_Format_KML_readCdataAttributes (t) {31 function test_Format_KML_readCdataAttributes_20(t) { 32 32 t.plan(2); 33 33 var cdata = '<kml xmlns="http://earth.google.com/kml/2.0"><Document><Placemark><name><![CDATA[Pezinok]]></name><description><![CDATA[Full of text.]]></description><styleUrl>#rel1.0</styleUrl><Point> <coordinates>17.266666, 48.283333</coordinates></Point></Placemark></Document></kml>'; 34 var features = (new OpenLayers.Format.KML()).read(cdata); 35 t.eq(features[0].attributes.description, "Full of text.", "Description attribute in cdata read correctly"); 36 t.eq(features[0].attributes.name, "Pezinok", "title attribute in cdata read correctly"); 37 38 } 39 40 function test_Format_KML_readCdataAttributes_21(t) { 41 t.plan(2); 42 var cdata = '<kml xmlns="http://earth.google.com/kml/2.1"><Document><Placemark><name><![CDATA[Pezinok]]></name><description><![CDATA[Full of text.]]></description><styleUrl>#rel1.0</styleUrl><Point> <coordinates>17.266666, 48.283333</coordinates></Point></Placemark></Document></kml>'; 34 43 var features = (new OpenLayers.Format.KML()).read(cdata); 35 44 t.eq(features[0].attributes.description, "Full of text.", "Description attribute in cdata read correctly");
