Changeset 3090
- Timestamp:
- 04/22/07 12:46:38 (2 years ago)
- Files:
-
- sandbox/tschaub/tc/lib/OpenLayers/Control/DrawFeature.js (modified) (1 diff)
- sandbox/tschaub/tc/lib/OpenLayers/Control/LayerSwitcher.js (modified) (1 diff)
- sandbox/tschaub/tc/lib/OpenLayers/Control/OverviewMap.js (modified) (3 diffs)
- sandbox/tschaub/tc/lib/OpenLayers/Control/SelectFeature.js (modified) (1 diff)
- sandbox/tschaub/tc/lib/OpenLayers/Feature/Vector.js (modified) (2 diffs)
- sandbox/tschaub/tc/lib/OpenLayers/Handler/Drag.js (modified) (2 diffs)
- sandbox/tschaub/tc/lib/OpenLayers/Layer/KaMap.js (modified) (1 diff)
- sandbox/tschaub/tc/lib/OpenLayers/Layer/Vector.js (modified) (2 diffs)
- sandbox/tschaub/tc/lib/OpenLayers/Layer/WFS.js (modified) (1 diff)
- sandbox/tschaub/tc/lib/OpenLayers/Popup.js (modified) (1 diff)
- sandbox/tschaub/tc/lib/OpenLayers/Renderer.js (modified) (5 diffs)
- sandbox/tschaub/tc/lib/OpenLayers/Renderer/Elements.js (modified) (3 diffs)
- sandbox/tschaub/tc/lib/OpenLayers/Renderer/SVG.js (modified) (9 diffs)
- sandbox/tschaub/tc/lib/OpenLayers/Util.js (modified) (1 diff)
- sandbox/tschaub/tc/tests/Layer/test_KaMap.html (modified) (2 diffs)
- sandbox/tschaub/tc/tests/Layer/test_Vector.html (modified) (2 diffs)
- sandbox/tschaub/tc/tests/Layer/test_WFS.html (copied) (copied from trunk/openlayers/tests/Layer/test_WFS.html)
- sandbox/tschaub/tc/tests/list-tests.html (modified) (1 diff)
- sandbox/tschaub/tc/theme/default/style.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/tschaub/tc/lib/OpenLayers/Control/DrawFeature.js
r2978 r3090 23 23 * @type {Object} The functions that are sent to the handler for callback 24 24 */ 25 callbacks: {},25 callbacks: null, 26 26 27 27 /** sandbox/tschaub/tc/lib/OpenLayers/Control/LayerSwitcher.js
r2934 r3090 337 337 //configure main div 338 338 this.div.style.position = "absolute"; 339 this.div.style.top = " 10px";339 this.div.style.top = "25px"; 340 340 this.div.style.right = "0px"; 341 341 this.div.style.left = ""; sandbox/tschaub/tc/lib/OpenLayers/Control/OverviewMap.js
r2964 r3090 47 47 * @type Array(OpenLayers.Layer) 48 48 */ 49 layers: [],49 layers: null, 50 50 51 51 /** … … 69 69 * @type: Object 70 70 */ 71 mapOptions: {},71 mapOptions: null, 72 72 73 73 /** … … 76 76 */ 77 77 initialize: function(options) { 78 this.layers = new Array(); 78 79 OpenLayers.Control.prototype.initialize.apply(this, [options]); 79 80 }, sandbox/tschaub/tc/lib/OpenLayers/Control/SelectFeature.js
r3043 r3090 46 46 * @type {Object} The functions that are sent to the handler for callback 47 47 */ 48 callbacks: {},48 callbacks: null, 49 49 50 50 /** sandbox/tschaub/tc/lib/OpenLayers/Feature/Vector.js
r3043 r3090 28 28 geometry:null, 29 29 30 /** @type array*/31 attributes: {},32 33 /** @type strinng */30 /** @type Object */ 31 attributes: null, 32 33 /** @type String */ 34 34 state: null, 35 35 … … 49 49 this.geometry = geometry; 50 50 this.state = null; 51 this.attributes = new Object(); 51 52 if (data) { 52 OpenLayers.Util.extend(this.attributes, data);53 } 53 this.attributes = OpenLayers.Util.extend(this.attributes, data); 54 } 54 55 this.style = style ? style : null; 55 56 }, sandbox/tschaub/tc/lib/OpenLayers/Handler/Drag.js
r3042 r3090 94 94 if (this.started) { 95 95 this.started = false; 96 this.dragging = false;97 96 // TBD replace with CSS classes 98 97 this.map.div.style.cursor = ""; … … 133 132 click: function (evt) { 134 133 // throw away the first left click event that happens after a mouse up 135 if ( OpenLayers.Event.isLeftClick(evt) &&this.dragging) {136 this.dragging = true;134 if (this.dragging) { 135 this.dragging = false; 137 136 return false; 138 137 } sandbox/tschaub/tc/lib/OpenLayers/Layer/KaMap.js
r2240 r3090 146 146 147 147 }, 148 149 /** 150 * @param {Object} obj 151 * 152 * @returns An exact clone of this OpenLayers.Layer.Grid 153 * @type OpenLayers.Layer.Grid 154 */ 155 clone: function (obj) { 156 157 if (obj == null) { 158 obj = new OpenLayers.Layer.KaMap(this.name, 159 this.url, 160 this.params, 161 this.options); 162 } 163 164 //get all additions from superclasses 165 obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]); 166 167 // copy/set any non-init, non-simple values here 168 if (this.tileSize != null) { 169 obj.tileSize = this.tileSize.clone(); 170 } 171 172 // we do not want to copy reference to grid, so we make a new array 173 obj.grid = new Array(); 174 175 return obj; 176 }, 177 148 178 149 179 /** @final @type String */ sandbox/tschaub/tc/lib/OpenLayers/Layer/Vector.js
r3045 r3090 27 27 28 28 /** @type Array(OpenLayers.Feature.Vector) */ 29 selectedFeatures: [],29 selectedFeatures: null, 30 30 31 31 /** @type {Boolean} */ … … 253 253 254 254 /** 255 * Destroy all features on the layer and empty the selected features array. 255 256 */ 256 257 destroyFeatures: function () { 258 this.selectedFeatures = new Array(); 257 259 for (var i = this.features.length - 1; i >= 0; i--) { 258 260 this.features[i].destroy(); sandbox/tschaub/tc/lib/OpenLayers/Layer/WFS.js
r2996 r3090 203 203 } 204 204 }, 205 205 206 /** 207 * Call the onMapResize method of the appropriate parent class. 208 */ 209 onMapResize: function() { 210 if(this.vectorMode) { 211 OpenLayers.Layer.Vector.prototype.onMapResize.apply(this, arguments); 212 } else { 213 OpenLayers.Layer.Markers.prototype.onMapResize.apply(this, arguments); 214 } 215 }, 216 206 217 /** 207 218 * @param {Object} obj sandbox/tschaub/tc/lib/OpenLayers/Popup.js
r2994 r3090 105 105 this.div.appendChild(closeImg); 106 106 107 var closeEvents = new OpenLayers.Events(this, closeImg); 108 closeEvents.register("mousedown", this, this.hide); 107 var closePopup = function(e) { 108 this.hide(); 109 OpenLayers.Event.stop(e); 110 } 111 OpenLayers.Event.observe(closeImg, "click", 112 closePopup.bindAsEventListener(this)); 109 113 110 114 } sandbox/tschaub/tc/lib/OpenLayers/Renderer.js
r3043 r3090 110 110 * Draw the feature. The optional style argument can be used 111 111 * to override the feature's own style. This method should only 112 * be called from layer.drawFeature(). Implemented by a renderer 113 * subclass. 112 * be called from layer.drawFeature(). 114 113 * 115 114 * @param {OpenLayers.Feature.Vector} feature 116 115 * @param {Object} style 116 * @private 117 117 */ 118 drawFeature: function(feature, style) {}, 118 drawFeature: function(feature, style) { 119 if(style == null) { 120 style = feature.style; 121 } 122 this.drawGeometry(feature.geometry, style, feature.id); 123 }, 124 119 125 120 126 /** … … 126 132 * @param geometry {OpenLayers.Geometry} 127 133 * @param style {Object} 134 * @param {String} featureId 128 135 * @private 129 136 */ 130 drawGeometry: function(geometry, style ) {},137 drawGeometry: function(geometry, style, featureId) {}, 131 138 132 139 /** … … 134 141 * 135 142 * Clear all vectors from the renderer 136 * 143 * @private 137 144 */ 138 145 clear: function() {}, … … 154 161 155 162 /** 163 * This is called by the layer to erase features 164 * @param {Array(OpenLayers.Feature.Vector)} features 165 * @private 166 */ 167 eraseFeatures: function(features) { 168 if(!(features instanceof Array)) { 169 features = [features]; 170 } 171 for(var i=0; i<features.length; ++i) { 172 this.eraseGeometry(features[i].geometry); 173 } 174 }, 175 176 /** 156 177 * virtual function 157 178 * … … 159 180 * 160 181 * @param geometry {OpenLayers.Geometry} 182 * @private 161 183 */ 162 184 eraseGeometry: function(geometry) {}, sandbox/tschaub/tc/lib/OpenLayers/Renderer/Elements.js
r3043 r3090 207 207 * @returns A geometry from an event that happened on a layer 208 208 * @type OpenLayers.Geometry 209 * @private 209 210 */ 210 211 getFeatureIdFromEvent: function(evt) { … … 219 220 * 220 221 * @param {OpenLayers.Geometry} geometry 222 * @private 221 223 */ 222 224 eraseGeometry: function(geometry) { … … 253 255 * @returns A new node of the given type and id 254 256 * @type DOMElement 257 * @private 255 258 */ 256 259 nodeFactory: function(id, type, geometry) { sandbox/tschaub/tc/lib/OpenLayers/Renderer/SVG.js
r3043 r3090 14 14 /** @type String */ 15 15 xmlns: "http://www.w3.org/2000/svg", 16 16 17 // Firefox has a limitation where values larger or smaller than about 18 // 15000 in an SVG document lock the browser up. This works around it. 19 /** @type Integer */ 20 maxPixel: 15000, 21 22 23 /** @type Float 24 @private */ 25 localResolution: null, 26 17 27 /** 18 28 * @constructor … … 55 65 var resolution = this.getResolution(); 56 66 57 var extentString = extent.left / resolution + " " + -extent.top / resolution + " " + 67 68 // If the resolution has changed, start over changing the corner, because 69 // the features will redraw. 70 if (!this.localResolution || resolution != this.localResolution) { 71 this.left = -extent.left / resolution; 72 this.top = extent.top / resolution; 73 } 74 75 76 var left = 0; 77 var top = 0; 78 79 // If the resolution has not changed, we already have features, and we need 80 // to adjust the viewbox to fit them. 81 if (this.localResolution && resolution == this.localResolution) { 82 left = (this.left) - (-extent.left / resolution); 83 top = (this.top) - (extent.top / resolution); 84 } 85 86 // Store resolution for use later. 87 this.localResolution = resolution; 88 89 // Set the viewbox -- the left/top will be pixels-dragged-since-res change, 90 // the width/height will be pixels. 91 var extentString = left + " " + top + " " + 58 92 extent.getWidth() / resolution + " " + extent.getHeight() / resolution; 93 //var extentString = extent.left / resolution + " " + -extent.top / resolution + " " + 59 94 this.rendererRoot.setAttributeNS(null, "viewBox", extentString); 60 95 }, … … 237 272 drawCircle: function(node, geometry, radius) { 238 273 var resolution = this.getResolution(); 239 node.setAttributeNS(null, "cx", geometry.x / resolution); 240 node.setAttributeNS(null, "cy", geometry.y / resolution); 241 node.setAttributeNS(null, "r", radius); 274 var x = (geometry.x / resolution + this.left); 275 var y = (geometry.y / resolution - this.top); 276 var draw = true; 277 if (x < -this.maxPixel || x > this.maxPixel) { draw = false; } 278 if (y < -this.maxPixel || y > this.maxPixel) { draw = false; } 279 280 if (draw) { 281 node.setAttributeNS(null, "cx", x); 282 node.setAttributeNS(null, "cy", y); 283 node.setAttributeNS(null, "r", radius); 284 } else { 285 node.setAttributeNS(null, "cx", ""); 286 node.setAttributeNS(null, "cy", ""); 287 node.setAttributeNS(null, "r", 0); 288 } 289 242 290 }, 243 291 … … 267 315 drawPolygon: function(node, geometry) { 268 316 var d = ""; 317 var draw = true; 269 318 for (var j = 0; j < geometry.components.length; j++) { 270 319 var linearRing = geometry.components[j]; 271 320 d += " M"; 272 321 for (var i = 0; i < linearRing.components.length; i++) { 273 d += " " + this.getShortString(linearRing.components[i]); 322 var component = this.getShortString(linearRing.components[i]) 323 if (component) { 324 d += " " + component; 325 } else { 326 draw = false; 327 } 274 328 } 275 329 } 276 330 d += " z"; 277 278 node.setAttributeNS(null, "d", d); 279 node.setAttributeNS(null, "fill-rule", "evenodd"); 331 if (draw) { 332 node.setAttributeNS(null, "d", d); 333 node.setAttributeNS(null, "fill-rule", "evenodd"); 334 } else { 335 node.setAttributeNS(null, "d", ""); 336 } 280 337 }, 281 338 … … 286 343 */ 287 344 drawRectangle: function(node, geometry) { 288 node.setAttributeNS(null, "x", geometry.x / resolution); 289 node.setAttributeNS(null, "y", geometry.y / resolution); 290 node.setAttributeNS(null, "width", geometry.width); 291 node.setAttributeNS(null, "height", geometry.height); 345 // This needs to be reworked 346 var x = (geometry.x / resolution + this.left); 347 var y = (geometry.y / resolution - this.top); 348 var draw = true; 349 if (x < -this.maxPixel || x > this.maxPixel) { draw = false; } 350 if (y < -this.maxPixel || y > this.maxPixel) { draw = false; } 351 if (draw) { 352 node.setAttributeNS(null, "x", x); 353 node.setAttributeNS(null, "y", y); 354 node.setAttributeNS(null, "width", geometry.width); 355 node.setAttributeNS(null, "height", geometry.height); 356 } else { 357 node.setAttributeNS(null, "x", ""); 358 node.setAttributeNS(null, "y", ""); 359 node.setAttributeNS(null, "width", 0); 360 node.setAttributeNS(null, "height", 0); 361 } 362 292 363 }, 293 364 … … 300 371 drawCurve: function(node, geometry) { 301 372 var d = null; 373 var draw = true; 302 374 for (var i = 0; i < geometry.components.length; i++) { 303 375 if ((i%3) == 0 && (i/3) == 0) { 304 d = "M " + this.getShortString(geometry.components[i]); 376 var component = this.getShortString(geometry.components[i]); 377 if (!component) { draw = false; } 378 d = "M " + component; 305 379 } else if ((i%3) == 1) { 306 d += " C " + this.getShortString(geometry.components[i]); 380 var component = this.getShortString(geometry.components[i]); 381 if (!component) { draw = false; } 382 d += " C " + component; 307 383 } else { 308 d += " " + this.getShortString(geometry.components[i]); 384 var component = this.getShortString(geometry.components[i]); 385 if (!component) { draw = false; } 386 d += " " + component; 309 387 } 310 388 } 311 node.setAttributeNS(null, "d", d); 389 if (draw) { 390 node.setAttributeNS(null, "d", d); 391 } else { 392 node.setAttributeNS(null, "d", ""); 393 } 312 394 }, 313 395 … … 321 403 // create the svg path string representation 322 404 var d = null; 405 var draw = true; 323 406 for (var i = 0; i < geometry.components.length; i++) { 324 407 if ((i%3) == 0 && (i/3) == 0) { 325 d = "M " + this.getShortString(geometry.components[i]); 408 var component = this.getShortString(geometry.components[i]); 409 if (!component) { draw = false; } 410 d = "M " + component; 326 411 } else if ((i%3) == 1) { 327 d += " C " + this.getShortString(geometry.components[i]); 412 var component = this.getShortString(geometry.components[i]); 413 if (!component) { draw = false; } 414 d += " C " + component; 328 415 } else { 329 d += " " + this.getShortString(geometry.components[i]); 416 var component = this.getShortString(geometry.components[i]); 417 if (!component) { draw = false; } 418 d += " " + component; 330 419 } 331 420 } 332 421 d += " Z"; 333 node.setAttributeNS(null, "d", d); 422 if (draw) { 423 node.setAttributeNS(null, "d", d); 424 } else { 425 node.setAttributeNS(null, "d", ""); 426 } 334 427 }, 335 428 … … 341 434 var strings = []; 342 435 for(var i = 0; i < components.length; i++) { 343 strings.push(this.getShortString(components[i])); 436 var component = this.getShortString(components[i]); 437 if (!component) { return false; } 438 strings.push(component); 344 439 } 345 440 return strings.join(","); … … 353 448 getShortString: function(point) { 354 449 var resolution = this.getResolution(); 355 return point.x / resolution + "," + point.y / resolution; 450 var x = (point.x / resolution + this.left); 451 var y = (point.y / resolution - this.top); 452 if (x < -this.maxPixel || x > this.maxPixel) { return false; } 453 if (y < -this.maxPixel || y > this.maxPixel) { return false; } 454 var string = x + "," + y; 455 return string; 356 456 357 457 }, sandbox/tschaub/tc/lib/OpenLayers/Util.js
r2994 r3090 174 174 opacity, delayDisplay) { 175 175 176 image = document.createElement("img");176 var image = document.createElement("img"); 177 177 178 178 //set generic properties sandbox/tschaub/tc/tests/Layer/test_KaMap.html
r2803 r3090 148 148 149 149 function test_10_Layer_KaMap_clone(t) { 150 t.plan( 4);150 t.plan(5); 151 151 152 152 var options = {tileSize: new OpenLayers.Size(500,50)}; … … 169 169 170 170 t.eq( clone.alpha, layer.alpha, "alpha copied correctly"); 171 172 t.eq( clone.CLASS_NAME, "OpenLayers.Layer.KaMap", "Clone is a ka-map layer"); 171 173 172 174 layer.grid = null; sandbox/tschaub/tc/tests/Layer/test_Vector.html
r3043 r3090 102 102 103 103 function test_Layer_Vector_destroyFeatures (t) { 104 t.plan( 2);104 t.plan(3); 105 105 layer = new OpenLayers.Layer.Vector(name); 106 106 var map = new OpenLayers.Map('map'); … … 113 113 layer.addFeatures(features); 114 114 t.eq(layer.features.length, 5, "addFeatures adds 5 features"); 115 layer.selectedFeatures.push(features[0]); 115 116 layer.destroyFeatures(); 116 117 t.eq(layer.features.length, 0, "destroyFeatures triggers removal"); 118 t.eq(layer.selectedFeatures, [], "Destroy features removes selected features"); 117 119 } 118 120 sandbox/tschaub/tc/tests/list-tests.html
r3026 r3090 43 43 <li>Layer/test_Text.html</li> 44 44 <li>Layer/test_WMS.html</li> 45 <li>Layer/test_WFS.html</li> 45 46 <li>Layer/test_TMS.html</li> 46 47 <li>Layer/test_Vector.html</li> sandbox/tschaub/tc/theme/default/style.css
r2978 r3090 90 90 .olControlNavToolbar .olControlNavigationItemActive { 91 91 background-image: url("img/panning-hand-on.png"); 92 background-repeat: no-repeat; 92 93 } 93 94 .olControlNavToolbar .olControlNavigationItemInactive { 94 95 background-image: url("img/panning-hand-off.png"); 96 background-repeat: no-repeat; 95 97 } 96 98 .olControlNavToolbar .olControlZoomBoxItemActive { 97 99 background-image: url("img/drag-rectangle-on.png"); 98 100 background-color: orange; 101 background-repeat: no-repeat; 99 102 } 100 103 .olControlNavToolbar .olControlZoomBoxItemInactive { 101 104 background-image: url("img/drag-rectangle-off.png"); 105 background-repeat: no-repeat; 102 106 } 103 107 .olControlEditingToolbar { … … 115 119 .olControlEditingToolbar .olControlNavigationItemActive { 116 120 background-image: url("img/pan_on.png"); 121 background-repeat: no-repeat; 117 122 } 118 123 .olControlEditingToolbar .olControlNavigationItemInactive { 119 124 background-image: url("img/pan_off.png"); 125 background-repeat: no-repeat; 120 126 } 121 127 .olControlEditingToolbar .olControlDrawFeaturePointItemActive { 122 128 background-image: url("img/draw_point_on.png"); 129 background-repeat: no-repeat; 123 130 } 124 131 .olControlEditingToolbar .olControlDrawFeaturePointItemInactive { 125 132 background-image: url("img/draw_point_off.png"); 133 background-repeat: no-repeat; 126 134 } 127 135 .olControlEditingToolbar .olControlDrawFeaturePathItemInactive { 128 136 background-image: url("img/draw_line_off.png"); 137 background-repeat: no-repeat; 129 138 } 130 139 .olControlEditingToolbar .olControlDrawFeaturePathItemActive { 131 140 background-image: url("img/draw_line_on.png"); 141 background-repeat: no-repeat; 132 142 } 133 143 .olControlEditingToolbar .olControlDrawFeaturePolygonItemInactive { 134 144 background-image: url("img/draw_polygon_off.png"); 145 background-repeat: no-repeat; 135 146 } 136 147 .olControlEditingToolbar .olControlDrawFeaturePolygonItemActive { 137 148 background-image: url("img/draw_polygon_on.png"); 149 background-repeat: no-repeat; 138 150 }
