Changeset 3112
- Timestamp:
- 05/02/07 10:06:41 (2 years ago)
- Files:
-
- branches/openlayers/2.4/examples/outOfRangeMarkers.html (copied) (copied from trunk/openlayers/examples/outOfRangeMarkers.html)
- branches/openlayers/2.4/examples/outOfRangeMarkers.txt (copied) (copied from trunk/openlayers/examples/outOfRangeMarkers.txt)
- branches/openlayers/2.4/examples/panel.html (modified) (1 diff)
- branches/openlayers/2.4/lib/OpenLayers/Control/OverviewMap.js (modified) (1 diff)
- branches/openlayers/2.4/lib/OpenLayers/Control/Panel.js (modified) (2 diffs)
- branches/openlayers/2.4/lib/OpenLayers/Format/GML.js (modified) (6 diffs)
- branches/openlayers/2.4/lib/OpenLayers/Layer.js (modified) (1 diff)
- branches/openlayers/2.4/lib/OpenLayers/Layer/Markers.js (modified) (2 diffs)
- branches/openlayers/2.4/lib/OpenLayers/Layer/Vector.js (modified) (1 diff)
- branches/openlayers/2.4/tests/Format/test_GML.html (copied) (copied from trunk/openlayers/tests/Format/test_GML.html)
- branches/openlayers/2.4/tests/Layer/test_Vector.html (modified) (4 diffs)
- branches/openlayers/2.4/tests/Marker/test_Box.html (modified) (1 diff)
- branches/openlayers/2.4/tests/list-tests.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/2.4/examples/panel.html
r2978 r3112 70 70 71 71 zb = new OpenLayers.Control.ZoomBox(); 72 panel = new OpenLayers.Control.Panel({defaultControl: zb});72 var panel = new OpenLayers.Control.Panel({defaultControl: zb}); 73 73 panel.addControls([ 74 74 new OpenLayers.Control.MouseDefaults(), branches/openlayers/2.4/lib/OpenLayers/Control/OverviewMap.js
r3088 r3112 521 521 this.extentRectangle.style.top = parseInt(top) + 'px'; 522 522 this.extentRectangle.style.left = parseInt(left) + 'px'; 523 this.extentRectangle.style.height = parseInt( bottom - top)+ 'px';524 this.extentRectangle.style.width = parseInt( right - left) + 'px';523 this.extentRectangle.style.height = parseInt(Math.max(bottom - top, 0))+ 'px'; 524 this.extentRectangle.style.width = parseInt(Math.max(right - left, 0)) + 'px'; 525 525 }, 526 526 branches/openlayers/2.4/lib/OpenLayers/Control/Panel.js
r2978 r3112 130 130 // Access to this div is via the panel_div attribute of the 131 131 // control added to the panel. 132 // Also, stop mousedowns and clicks, but don't stop mouseup, 133 // since they need to pass through. 132 134 for (var i = 0; i < controls.length; i++) { 133 135 var element = document.createElement("div"); … … 138 140 OpenLayers.Event.observe(controls[i].panel_div, "mousedown", 139 141 OpenLayers.Event.stop.bindAsEventListener()); 140 OpenLayers.Event.observe(controls[i].panel_div, "mouseup",141 OpenLayers.Event.stop.bindAsEventListener());142 142 } 143 143 branches/openlayers/2.4/lib/OpenLayers/Format/GML.js
r3088 r3112 85 85 var feature = new OpenLayers.Feature.Vector(); 86 86 87 if (xmlNode.firstChild.attributes && xmlNode.firstChild.attributes['fid']) {88 feature.fid = xmlNode.firstChild.attributes['fid'].nodeValue;89 }90 91 87 // match MultiPolygon 92 88 if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon").length != 0) { 93 89 var multipolygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon")[0]; 90 feature.fid = multipolygon.parentNode.parentNode.getAttribute('fid'); 91 94 92 geom = new OpenLayers.Geometry.MultiPolygon(); 95 93 var polygons = OpenLayers.Ajax.getElementsByTagNameNS(multipolygon, … … 105 103 var multilinestring = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 106 104 this.gmlns, "gml", "MultiLineString")[0]; 105 feature.fid = multilinestring.parentNode.parentNode.getAttribute('fid'); 107 106 108 107 geom = new OpenLayers.Geometry.MultiLineString(); … … 123 122 var multiPoint = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 124 123 this.gmlns, "gml", "MultiPoint")[0]; 124 feature.fid = multiPoint.parentNode.parentNode.getAttribute('fid'); 125 125 126 126 geom = new OpenLayers.Geometry.MultiPoint(); … … 139 139 var polygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 140 140 this.gmlns, "gml", "Polygon")[0]; 141 feature.fid = polygon.parentNode.parentNode.getAttribute('fid'); 141 142 142 143 geom = this.parsePolygonNode(polygon); … … 147 148 var lineString = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 148 149 this.gmlns, "gml", "LineString")[0]; 150 feature.fid = lineString.parentNode.parentNode.getAttribute('fid'); 151 149 152 p = this.parseCoords(lineString); 150 153 if (p.points) { … … 158 161 var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 159 162 this.gmlns, "gml", "Point")[0]; 163 feature.fid = point.parentNode.parentNode.getAttribute('fid'); 160 164 161 165 p = this.parseCoords(point); branches/openlayers/2.4/lib/OpenLayers/Layer.js
r3088 r3112 287 287 if (!this.isBaseLayer) { 288 288 this.inRange = this.calculateInRange(); 289 var show = ((this.visibility) && (this.inRange)); 290 this.div.style.display = show ? "" : "none"; 289 291 } 290 292 branches/openlayers/2.4/lib/OpenLayers/Layer/Markers.js
r1721 r3112 22 22 * @type Array(OpenLayers.Marker) */ 23 23 markers: null, 24 25 26 /** internal state of drawing. This is a workaround for the fact 27 * that the map does not call moveTo with a zoomChanged when the 28 * map is first starting up. This lets us catch the case where we 29 * have *never* drawn the layer, and draw it even if the zoom hasn't 30 * changed. 31 * @type Boolean */ 32 drawn: false, 24 33 25 34 /** … … 52 61 OpenLayers.Layer.prototype.moveTo.apply(this, arguments); 53 62 54 if (zoomChanged ) {63 if (zoomChanged || !this.drawn) { 55 64 this.redraw(); 65 this.drawn = true; 56 66 } 57 67 }, branches/openlayers/2.4/lib/OpenLayers/Layer/Vector.js
r3088 r3112 249 249 250 250 this.renderer.eraseGeometry(feature.geometry); 251 252 //in the case that this feature is one of the selected features, 253 // remove it from that array as well. 254 if (OpenLayers.Util.indexOf(this.selectedFeatures, feature) != -1){ 255 OpenLayers.Util.removeItem(this.selectedFeatures, feature); 256 } 251 257 } 252 258 }, branches/openlayers/2.4/tests/Layer/test_Vector.html
r3088 r3112 30 30 31 31 function test_03_Layer_Vector_removeFeatures(t) { 32 t.plan( 2);32 t.plan(3); 33 33 34 34 var layer = new OpenLayers.Layer.Vector(name); … … 44 44 t.ok(layer.features.length == 1, "OpenLayers.Layer.Vector.removeFeatures removes a feature from the features array"); 45 45 layer.addFeatures([pointFeature1.clone(), pointFeature2.clone()]); 46 layer.selectedFeatures.push(layer.features[0]); 47 layer.removeFeatures(layer.features[0]); 48 t.eq(layer.selectedFeatures, [], "Remove features removes selected features"); 46 49 var features = layer.removeFeatures(layer.features); 47 50 … … 70 73 71 74 var f, s; 75 76 // Layer renderer needs a destroy, and draw, for functional tests. 72 77 layer.renderer = { 73 78 drawFeature: function(feature, style) { 74 79 f = feature; 75 80 s = style; 76 } 81 }, 82 destroy: function() { } 77 83 }; 84 78 85 79 86 layer.drawFeature(feature); … … 113 120 eraseFeatures: function(features) { 114 121 f = features[0]; 115 } 122 }, 123 destroy: function() { } 116 124 }; 117 125 branches/openlayers/2.4/tests/Marker/test_Box.html
r3088 r3112 180 180 </body> 181 181 </html> 182 <html>183 <head>184 <script src="../../lib/OpenLayers.js"></script>185 <script type="text/javascript"><!--186 var box;187 188 function test_01_Box_constructor (t) {189 t.plan( 7 );190 191 OpenLayers.Marker.Box.prototype._setBorder =192 OpenLayers.Marker.Box.prototype.setBorder;193 OpenLayers.Marker.Box.prototype.setBorder = function (x,y) {194 g_Color = x;195 g_Width = y;196 };197 198 var bounds = new OpenLayers.Bounds(1,2,3,4);199 var borderColor = "blue";200 var borderWidth = 55;201 202 203 g_Color = g_Width = null;204 box = new OpenLayers.Marker.Box(bounds, borderColor, borderWidth);205 206 t.ok( box instanceof OpenLayers.Marker.Box, "new OpenLayers.Marker.Box returns Box object" );207 t.ok( box.bounds.equals(bounds), "bounds object correctly set");208 t.ok( box.div != null, "div created");209 t.eq( box.div.style.overflow, "hidden", "div style overflow hidden");210 t.ok( box.events != null, "events object created");211 t.eq( g_Color, borderColor, "setBorder called with correct border color");212 t.eq( g_Width, borderWidth, "setBorder called with correct border width");213 214 215 OpenLayers.Marker.Box.prototype.setBorder =216 OpenLayers.Marker.Box.prototype._setBorder;217 }218 219 220 function test_02_Box_setBorder(t) {221 t.plan( 2 );222 223 var box = {224 div: {225 style: {}226 }227 };228 229 //defaults230 var args = [];231 OpenLayers.Marker.Box.prototype.setBorder.apply(box, args);232 t.eq(box.div.style.border, "2px solid red", "style correctly set with no good values (defaults work)");233 234 //good vals235 var borderColor = "blue";236 var borderWidth = 55;237 238 args = [borderColor, borderWidth];239 OpenLayers.Marker.Box.prototype.setBorder.apply(box, args);240 t.eq(box.div.style.border, borderWidth + "px solid " + borderColor, "style correctly set with both good values");241 242 }243 function test_03_Box_draw(t) {244 t.plan( 5 );245 246 OpenLayers.Util._modifyDOMElement =247 OpenLayers.Util.modifyDOMElement;248 OpenLayers.Util.modifyDOMElement =249 function (element, id, px, sz) {250 g_Element = element;251 g_Id = id;252 g_Px = px;253 g_Sz = sz;254 };255 256 var box = {257 div: {}258 };259 260 261 var px = {};262 var sz = {};263 var args = [px, sz];264 265 g_Element = g_Id = g_Px = g_Sz = null;266 var retVal = OpenLayers.Marker.Box.prototype.draw.apply(box, args);267 268 t.eq(g_Element, box.div, "modifyDOMElement passes box's div for element");269 t.eq(g_Id, null, "modifyDOMElement passes null for id");270 t.eq(g_Px, px, "modifyDOMElement passes new px value for px");271 t.eq(g_Sz, sz, "modifyDOMElement passes new sz value for sz");272 t.ok(retVal == box.div, "draw returns box's div");273 274 OpenLayers.Util.modifyDOMElement =275 OpenLayers.Util._modifyDOMElement;276 277 }278 279 function test_04_Box_onScreen(t) {280 t.plan( 2 );281 282 var map = new OpenLayers.Map("map");283 284 var url = "http://octo.metacarta.com/cgi-bin/mapserv";285 layer = new OpenLayers.Layer.WMS(name, url);286 287 map.addLayer(layer);288 289 mlayer = new OpenLayers.Layer.Boxes('Test Layer');290 map.addLayer(mlayer);291 292 map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50));293 294 //onscreen box295 var bounds = new OpenLayers.Bounds(-1,-1,1,1);296 var box = new OpenLayers.Marker.Box(bounds);297 mlayer.addMarker(box);298 299 t.ok( box.onScreen(), "box knows it's onscreen" );300 301 //offscreen box302 var bounds = new OpenLayers.Bounds(100,100,150,150);303 var box2 = new OpenLayers.Marker.Box(bounds);304 mlayer.addMarker(box2);305 306 t.ok( !box2.onScreen(), "box knows it's offscreen" );307 map.destroy();308 }309 310 function test_05_Box_display(t) {311 t.plan( 2 );312 313 var box = {314 div: {315 style: {}316 }317 };318 319 //display(true)320 var args = [true];321 OpenLayers.Marker.Box.prototype.display.apply(box, args);322 t.eq(box.div.style.display, "", "style.display correctly set to '' when display(true)");323 324 //display(false)325 var args = [false];326 OpenLayers.Marker.Box.prototype.display.apply(box, args);327 t.eq(box.div.style.display, "none", "style.display correctly set to 'none' when display(false)");328 }329 330 function test_99_Box_destroy(t) {331 t.plan(3);332 333 OpenLayers.Marker.prototype._destroy =334 OpenLayers.Marker.prototype.destroy;335 OpenLayers.Marker.prototype.destroy = function() {336 g_Destroy = true;337 }338 339 var bounds = new OpenLayers.Bounds(1,2,3,4);340 var borderColor = "blue";341 var borderWidth = 55;342 343 g_Destroy = null;344 box = new OpenLayers.Marker.Box(bounds, borderColor, borderWidth);345 box.destroy();346 347 t.eq(box.bounds, null, "bounds nullified");348 t.eq(box.div, null, "div nullified");349 t.ok(g_Destroy == true, "OpenLayers.Marker.destroy() called");350 351 352 OpenLayers.Marker.prototype.destroy =353 OpenLayers.Marker.prototype._destroy;354 }355 356 // -->357 </script>358 </head>359 <body>360 <div id="map" style="width:500px;height:550px"></div>361 </body>362 </html>branches/openlayers/2.4/tests/list-tests.html
r3088 r3112 18 18 <li>Geometry/test_Surface.html</li> 19 19 <li>test_Format.html</li> 20 <li>Format/test_GML.html</li> 20 21 <li>Format/test_WKT.html</li> 21 22 <li>test_Icon.html</li>
