Changeset 2960
- Timestamp:
- 04/01/07 20:15:59 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Renderer/SVG.js (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Renderer/SVG.js
r2818 r2960 51 51 OpenLayers.Renderer.Elements.prototype.setExtent.apply(this, 52 52 arguments); 53 var extentString = extent.left + " " + -extent.top + " " + 54 extent.getWidth() + " " + extent.getHeight(); 53 54 var resolution = this.getResolution(); 55 56 var extentString = extent.left / resolution + " " + -extent.top / resolution + " " + 57 extent.getWidth() / resolution + " " + extent.getHeight() / resolution; 55 58 this.rendererRoot.setAttributeNS(null, "viewBox", extentString); 56 59 }, … … 109 112 */ 110 113 reprojectNode: function(node) { 111 //just reset style (stroke width and point radius), since coord 112 // system has not changed 113 this.setStyle(node); 114 this.drawGeometryNode(node); 114 115 }, 115 116 … … 131 132 132 133 if (node.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { 133 var newRadius = style.pointRadius * this.getResolution(); 134 node.setAttributeNS(null, "r", newRadius); 134 node.setAttributeNS(null, "r", style.pointRadius); 135 135 } 136 136 … … 145 145 node.setAttributeNS(null, "stroke", style.strokeColor); 146 146 node.setAttributeNS(null, "stroke-opacity", style.strokeOpacity); 147 var newStrokeWidth = style.strokeWidth * this.getResolution(); 148 node.setAttributeNS(null, "stroke-width", newStrokeWidth); 147 node.setAttributeNS(null, "stroke-width", style.strokeWidth); 149 148 } else { 150 149 node.setAttributeNS(null, "stroke", "none"); … … 232 231 */ 233 232 drawCircle: function(node, geometry, radius) { 234 node.setAttributeNS(null, "cx", geometry.x); 235 node.setAttributeNS(null, "cy", geometry.y); 233 var resolution = this.getResolution(); 234 node.setAttributeNS(null, "cx", geometry.x / resolution); 235 node.setAttributeNS(null, "cy", geometry.y / resolution); 236 236 node.setAttributeNS(null, "r", radius); 237 237 }, … … 242 242 */ 243 243 drawLineString: function(node, geometry) { 244 node.setAttributeNS(null, "points", geometry.getComponentsString());244 node.setAttributeNS(null, "points", this.getComponentsString(geometry.components)); 245 245 }, 246 246 … … 250 250 */ 251 251 drawLinearRing: function(node, geometry) { 252 node.setAttributeNS(null, "points", geometry.getComponentsString());252 node.setAttributeNS(null, "points", this.getComponentsString(geometry.components)); 253 253 }, 254 254 … … 263 263 d += " M"; 264 264 for (var i = 0; i < linearRing.components.length; i++) { 265 d += " " + linearRing.components[i].toShortString();265 d += " " + this.getShortString(linearRing.components[i]); 266 266 } 267 267 } … … 277 277 */ 278 278 drawRectangle: function(node, geometry) { 279 node.setAttributeNS(null, "x", geometry.x );280 node.setAttributeNS(null, "y", geometry.y );279 node.setAttributeNS(null, "x", geometry.x / resolution); 280 node.setAttributeNS(null, "y", geometry.y / resolution); 281 281 node.setAttributeNS(null, "width", geometry.width); 282 282 node.setAttributeNS(null, "height", geometry.height); … … 292 292 for (var i = 0; i < geometry.components.length; i++) { 293 293 if ((i%3) == 0 && (i/3) == 0) { 294 d = "M " + geometry.components[i].toShortString();294 d = "M " + this.getShortString(geometry.components[i]); 295 295 } else if ((i%3) == 1) { 296 d += " C " + geometry.components[i].toShortString();296 d += " C " + this.getShortString(geometry.components[i]); 297 297 } else { 298 d += " " + geometry.components[i].toShortString();298 d += " " + this.getShortString(geometry.components[i]); 299 299 } 300 300 } … … 312 312 for (var i = 0; i < geometry.components.length; i++) { 313 313 if ((i%3) == 0 && (i/3) == 0) { 314 d = "M " + geometry.components[i].toShortString();314 d = "M " + this.getShortString(geometry.components[i]); 315 315 } else if ((i%3) == 1) { 316 d += " C " + geometry.components[i].toShortString();316 d += " C " + this.getShortString(geometry.components[i]); 317 317 } else { 318 d += " " + geometry.components[i].toShortString();318 d += " " + this.getShortString(geometry.components[i]); 319 319 } 320 320 } … … 323 323 }, 324 324 325 /** 326 * @param {Array} components array of points 327 */ 328 getComponentsString: function(components) { 329 var strings = []; 330 for(var i = 0; i < components.length; i++) { 331 strings.push(this.getShortString(components[i])); 332 } 333 return strings.join(","); 334 }, 335 336 337 /** 338 * @param {OpenLayers.Geometry.Point} point 339 */ 340 getShortString: function(point) { 341 var resolution = this.getResolution(); 342 return point.x / resolution + "," + point.y / resolution; 343 344 }, 345 325 346 /** @final @type String */ 326 347 CLASS_NAME: "OpenLayers.Renderer.SVG"
