Changeset 4432
- Timestamp:
- 09/21/07 09:32:42 (1 year ago)
- Files:
-
- branches/openlayers/2.5/examples/kml-layer-linestring.html (deleted)
- branches/openlayers/2.5/examples/kml-layer.html (modified) (1 diff)
- branches/openlayers/2.5/lib/OpenLayers/Control/MousePosition.js (modified) (1 diff)
- branches/openlayers/2.5/lib/OpenLayers/Format/GML.js (modified) (3 diffs)
- branches/openlayers/2.5/lib/OpenLayers/Format/KML.js (modified) (1 diff)
- branches/openlayers/2.5/lib/OpenLayers/Format/XML.js (modified) (1 diff)
- branches/openlayers/2.5/lib/OpenLayers/Handler/Drag.js (modified) (2 diffs)
- branches/openlayers/2.5/tests/Control/test_MousePosition.html (copied) (copied from trunk/openlayers/tests/Control/test_MousePosition.html)
- branches/openlayers/2.5/tests/Format/test_GML.html (modified) (1 diff)
- branches/openlayers/2.5/tests/Format/test_KML.html (modified) (1 diff)
- branches/openlayers/2.5/tests/Handler/test_Drag.html (modified) (3 diffs)
- branches/openlayers/2.5/tests/list-tests.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/2.5/examples/kml-layer.html
r4222 r4432 20 20 "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} ); 21 21 map.addLayer(layer); 22 map.addLayer(new OpenLayers.Layer.GML("KML", "kml/ mc-search.kml", {format: OpenLayers.Format.KML}));23 map.zoomTo MaxExtent();22 map.addLayer(new OpenLayers.Layer.GML("KML", "kml/lines.kml", {format: OpenLayers.Format.KML})); 23 map.zoomToExtent(new OpenLayers.Bounds(-112.306698,36.017792,-112.03204,36.18087)); 24 24 } 25 25 </script> branches/openlayers/2.5/lib/OpenLayers/Control/MousePosition.js
r4234 r4432 63 63 64 64 /** 65 * Method: destroy 66 */ 67 destroy: function() { 68 if (this.map) { 69 this.map.events.unregister('mousemove', this, this.redraw); 70 } 71 OpenLayers.Control.prototype.destroy.apply(this, arguments); 72 }, 73 74 /** 65 75 * Method: draw 66 76 * {DOMElement} branches/openlayers/2.5/lib/OpenLayers/Format/GML.js
r4390 r4432 296 296 nodeList = this.getElementsByTagNameNS(node, this.gmlns, "posList"); 297 297 if(nodeList.length > 0) { 298 coordString = nodeList[0].firstChild.nodeValue;298 coordString = this.concatChildValues(nodeList[0]); 299 299 coordString = coordString.replace(this.regExes.trimSpace, ""); 300 300 coords = coordString.split(this.regExes.splitSpace); … … 315 315 "coordinates"); 316 316 if(nodeList.length > 0) { 317 coordString = nodeList[0].firstChild.nodeValue;317 coordString = this.concatChildValues(nodeList[0]); 318 318 coordString = coordString.replace(this.regExes.trimSpace, 319 319 ""); … … 454 454 if(grandchildren.length == 1) { 455 455 grandchild = grandchildren[0]; 456 if(grandchild.nodeType == 3) { 456 if(grandchild.nodeType == 3 || 457 grandchild.nodeType == 4) { 457 458 name = (child.prefix) ? 458 459 child.nodeName.split(":")[1] : branches/openlayers/2.5/lib/OpenLayers/Format/KML.js
r4390 r4432 327 327 if(grandchildren.length == 1) { 328 328 grandchild = grandchildren[0]; 329 if(grandchild.nodeType == 3 ) {329 if(grandchild.nodeType == 3 || grandchild.nodeType == 4) { 330 330 name = (child.prefix) ? 331 331 child.nodeName.split(":")[1] : branches/openlayers/2.5/lib/OpenLayers/Format/XML.js
r4302 r4432 257 257 return attributeValue; 258 258 }, 259 260 /** 261 * APIMethod: getChildValue 262 * Get the value of the first child node if it exists, or return an 263 * optional default string. Returns an empty string if no first child 264 * exists and no default value is supplied. 265 * 266 * Parameters: 267 * node - {DOMElement} The element used to look for a first child value. 268 * def - {String} Optional string to return in the event that no 269 * first child value exists. 270 * 271 * Returns: 272 * {String} The value of the first child of the given node. 273 */ 274 getChildValue: function(node, def) { 275 var value; 276 try { 277 value = node.firstChild.nodeValue; 278 } catch(e) { 279 value = (def != undefined) ? def : ""; 280 } 281 return value; 282 }, 283 284 /** 285 * APIMethod: concatChildValues 286 * Concatenate the value of all child nodes if any exist, or return an 287 * optional default string. Returns an empty string if no children 288 * exist and no default value is supplied. Not optimized for large 289 * numbers of child nodes. 290 * 291 * Parameters: 292 * node - {DOMElement} The element used to look for child values. 293 * def - {String} Optional string to return in the event that no 294 * child exist. 295 * 296 * Returns: 297 * {String} The concatenated value of all child nodes of the given node. 298 */ 299 concatChildValues: function(node, def) { 300 var value = ""; 301 var child = node.firstChild; 302 var childValue; 303 while(child) { 304 childValue = child.nodeValue; 305 if(childValue) { 306 value += childValue; 307 } 308 child = child.nextSibling; 309 } 310 if(value == "" && def != undefined) { 311 value = def; 312 } 313 return value; 314 }, 259 315 260 316 /** branches/openlayers/2.5/lib/OpenLayers/Handler/Drag.js
r4390 r4432 144 144 */ 145 145 mousedown: function (evt) { 146 var propagate = true; 147 this.dragging = false; 146 148 if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) { 147 149 this.started = true; 148 this.dragging = false;149 150 this.start = evt.xy; 150 151 this.last = evt.xy; … … 160 161 } 161 162 162 return false; 163 } 164 return true; 163 propagate = false; 164 } else { 165 this.started = false; 166 this.start = null; 167 this.last = null; 168 } 169 return propagate; 165 170 }, 166 171 branches/openlayers/2.5/tests/Format/test_GML.html
r4206 r4432 148 148 } 149 149 function test_Format_GML_read_attributes(t) { 150 t.plan( 1);150 t.plan(2); 151 151 var parser = new OpenLayers.Format.GML(); 152 152 data = parser.read(test_content[0]); 153 153 t.eq(data[0].attributes['NAME'], "WY", "Simple Attribute data is read correctly."); 154 t.eq(data[0].attributes['LONGNAME'], "Wyoming", "Attribute data is read from CDATA node correctly."); 154 155 } 155 156 156 var test_content = ['<?xml version="1.0" encoding="utf-8" ?>\n<ogr:FeatureCollection\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://ogr.maptools.org/ testoutput.xsd"\n xmlns:ogr="http://ogr.maptools.org/"\n xmlns:gml="http://www.opengis.net/gml">\n <gml:boundedBy>\n <gml:Box>\n <gml:coord><gml:X>-1254041.389711702</gml:X><gml:Y>250906.9515983529</gml:Y></gml:coord>\n <gml:coord><gml:X>-634517.1199908922</gml:X><gml:Y>762236.2940800377</gml:Y></gml:coord>\n </gml:Box>\n </gml:boundedBy> \n <gml:featureMember>\n <ogr:states fid="F0">\n <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>\n <ogr:NAME>WY</ogr:NAME>\n < /ogr:states>\n </gml:featureMember>\n</ogr:FeatureCollection>\n',157 var test_content = ['<?xml version="1.0" encoding="utf-8" ?>\n<ogr:FeatureCollection\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://ogr.maptools.org/ testoutput.xsd"\n xmlns:ogr="http://ogr.maptools.org/"\n xmlns:gml="http://www.opengis.net/gml">\n <gml:boundedBy>\n <gml:Box>\n <gml:coord><gml:X>-1254041.389711702</gml:X><gml:Y>250906.9515983529</gml:Y></gml:coord>\n <gml:coord><gml:X>-634517.1199908922</gml:X><gml:Y>762236.2940800377</gml:Y></gml:coord>\n </gml:Box>\n </gml:boundedBy> \n <gml:featureMember>\n <ogr:states fid="F0">\n <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>\n <ogr:NAME>WY</ogr:NAME>\n <ogr:LONGNAME><![CDATA[Wyoming]]></ogr:LONGNAME>\n </ogr:states>\n </gml:featureMember>\n</ogr:FeatureCollection>\n', 157 158 '<wfs:FeatureCollection' + 158 159 ' xmlns:fs="http://example.com/featureserver"' + branches/openlayers/2.5/tests/Format/test_KML.html
r4219 r4432 29 29 } 30 30 31 function test_Format_KML_readCdataAttributes(t) { 32 t.plan(2); 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 31 40 function test_Format_KML_write(t) { 32 41 // make sure id, name, and description are preserved branches/openlayers/2.5/tests/Handler/test_Drag.html
r4390 r4432 88 88 89 89 function test_Handler_Drag_callbacks(t) { 90 t.plan( 27);90 t.plan(33); 91 91 92 92 var map = new OpenLayers.Map('map', {controls: []}); … … 116 116 handler.activate(); 117 117 118 // test mousedown119 118 var oldIsLeftClick = OpenLayers.Event.isLeftClick; 120 119 var oldStop = OpenLayers.Event.stop; 121 120 var oldCheckModifiers = handler.checkModifiers; 121 122 // test mousedown with right click 123 OpenLayers.Event.isLeftClick = function() { 124 return false; 125 } 126 handler.checkModifiers = function() { 127 return true; 128 } 129 handler.started = true; 130 handler.start = {x: "foo", y: "bar"}; 131 handler.last = {x: "foo", y: "bar"}; 132 map.events.triggerEvent("mousedown", testEvents.down); 133 t.ok(!handler.started, "right-click sets started to false"); 134 t.eq(handler.start, null, "right-click sets start to null"); 135 t.eq(handler.last, null, "right-click sets last to null"); 136 137 // test mousedown with improper modifier 138 OpenLayers.Event.isLeftClick = function() { 139 return true; 140 } 141 handler.checkModifiers = function() { 142 return false; 143 } 144 handler.started = true; 145 handler.start = {x: "foo", y: "bar"}; 146 handler.last = {x: "foo", y: "bar"}; 147 map.events.triggerEvent("mousedown", testEvents.down); 148 t.ok(!handler.started, "bad modifier sets started to false"); 149 t.eq(handler.start, null, "bad modifier sets start to null"); 150 t.eq(handler.last, null, "bad modifier sets last to null"); 151 152 // test mousedown 122 153 handler.checkModifiers = function(evt) { 123 154 t.ok(evt.xy.x == testEvents.down.xy.x && … … 152 183 handler.last.y == testEvents.down.xy.y, 153 184 "mouse down sets handler.last correctly"); 185 186 OpenLayers.Event.stop = oldStop; 154 187 OpenLayers.Event.isLeftClick = oldIsLeftClick; 155 OpenLayers.Event.stop = oldStop;156 188 handler.checkModifiers = oldCheckModifiers; 157 189 branches/openlayers/2.5/tests/list-tests.html
r4272 r4432 72 72 <li>Control/test_NavToolbar.html</li> 73 73 <li>Control/test_MouseToolbar.html</li> 74 <li>Control/test_MousePosition.html</li> 74 75 <li>Control/test_LayerSwitcher.html</li> 75 76 <li>Control/test_Panel.html</li>
