Changeset 7349
- Timestamp:
- 06/11/08 09:48:50 (7 months ago)
- Files:
-
- sandbox/camptocamp/unhcr/build/full.cfg (modified) (1 diff)
- sandbox/camptocamp/unhcr/build/library.cfg (modified) (1 diff)
- sandbox/camptocamp/unhcr/build/license.txt (modified) (1 diff)
- sandbox/camptocamp/unhcr/build/lite.cfg (modified) (1 diff)
- sandbox/camptocamp/unhcr/examples/spherical-mercator.html (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Ajax.js (modified) (5 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Control/PanZoomBar.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Format/KML.js (modified) (3 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Format/SLD/v1.js (modified) (3 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GML.js (modified) (2 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GeoRSS.js (modified) (3 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/KaMap.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapGuide.js (modified) (2 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapServer.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Text.js (modified) (4 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/VirtualEarth.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WFS.js (modified) (2 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WorldWind.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Map.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/SVG.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/VML.js (modified) (7 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Request.js (modified) (10 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Style.js (modified) (1 diff)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Tile/WFS.js (modified) (5 diffs)
- sandbox/camptocamp/unhcr/lib/OpenLayers/Util.js (modified) (4 diffs)
- sandbox/camptocamp/unhcr/tests/Ajax.html (modified) (1 diff)
- sandbox/camptocamp/unhcr/tests/Format/SLD/v1_0_0.html (modified) (1 diff)
- sandbox/camptocamp/unhcr/tests/Renderer/VML.html (modified) (1 diff)
- sandbox/camptocamp/unhcr/tests/Request (copied) (copied from sandbox/vector-behavior/tests/Request)
- sandbox/camptocamp/unhcr/tests/Request.html (copied) (copied from sandbox/vector-behavior/tests/Request.html)
- sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html (copied) (copied from sandbox/vector-behavior/tests/Request/XMLHttpRequest.html)
- sandbox/camptocamp/unhcr/tests/Tile/WFS.html (modified) (2 diffs)
- sandbox/camptocamp/unhcr/tests/Util.html (modified) (7 diffs)
- sandbox/camptocamp/unhcr/tests/list-tests.html (modified) (1 diff)
- sandbox/camptocamp/unhcr/tests/manual/ajax.html (modified) (3 diffs)
- sandbox/camptocamp/unhcr/tests/xml_eq.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/camptocamp/unhcr/build/full.cfg
r6569 r7349 14 14 Firebug/firebug.js 15 15 Firebug/firebugx.js 16 OpenLayers/Lang/cs-CZ.js 16 17 OpenLayers/Lang/de.js 17 18 OpenLayers/Lang/en-CA.js 18 19 OpenLayers/Lang/fr.js 19 OpenLayers/Lang/cs-CZ.js 20 OpenLayers/Lang/it.js 21 OpenLayers/Lang/pt-BR.js 22 OpenLayers/Lang/sv-SE.js sandbox/camptocamp/unhcr/build/library.cfg
r6569 r7349 47 47 OpenLayers/Renderer/VML.js 48 48 OpenLayers/Renderer.js 49 OpenLayers/Lang/cs-CZ.js 49 50 OpenLayers/Lang/de.js 50 51 OpenLayers/Lang/en-CA.js 51 52 OpenLayers/Lang/fr.js 52 OpenLayers/Lang/cs-CZ.js 53 OpenLayers/Lang/it.js 54 OpenLayers/Lang/pt-BR.js 55 OpenLayers/Lang/sv-SE.js 53 56 54 sandbox/camptocamp/unhcr/build/license.txt
r7029 r7349 73 73 * 74 74 */ 75 76 /** 77 * Contains XMLHttpRequest.js <http://code.google.com/p/xmlhttprequest/> 78 * Copyright 2007 Sergey Ilinsky (http://www.ilinsky.com) 79 * 80 * Licensed under the Apache License, Version 2.0 (the "License"); 81 * you may not use this file except in compliance with the License. 82 * You may obtain a copy of the License at 83 * http://www.apache.org/licenses/LICENSE-2.0 84 */ sandbox/camptocamp/unhcr/build/lite.cfg
r6569 r7349 22 22 Firebug/firebug.js 23 23 Firebug/firebugx.js 24 OpenLayers/Lang/cs-CZ.js 24 25 OpenLayers/Lang/de.js 25 26 OpenLayers/Lang/en-CA.js 26 27 OpenLayers/Lang/fr.js 27 OpenLayers/Lang/cs-CZ.js 28 OpenLayers/Lang/it.js 29 OpenLayers/Lang/pt-BR.js 30 OpenLayers/Lang/sv-SE.js 28 31 sandbox/camptocamp/unhcr/examples/spherical-mercator.html
r7237 r7349 5 5 <style type="text/css"> 6 6 .olControlAttribution { bottom: 0px!important } 7 #map { 8 height: 512px; 9 } 7 10 </style> 8 11 sandbox/camptocamp/unhcr/lib/OpenLayers.js
r7304 r7349 85 85 "Rico/Corner.js", 86 86 "Rico/Color.js", 87 "OpenLayers/Ajax.js", 87 88 "OpenLayers/Request.js", 88 89 "OpenLayers/Request/XMLHttpRequest.js", 89 "OpenLayers/Ajax.js",90 90 "OpenLayers/Events.js", 91 91 "OpenLayers/Projection.js", sandbox/camptocamp/unhcr/lib/OpenLayers/Ajax.js
r7052 r7349 3 3 * full text of the license. */ 4 4 5 /** 6 * @requires OpenLayers/Request/XMLHttpRequest.js 7 */ 5 8 6 9 OpenLayers.ProxyHost = ""; … … 31 34 32 35 33 /** 34 * @param {} request 35 */ 36 /** 37 * Function: OpenLayers.nullHandler 38 * @param {} request 39 */ 36 40 OpenLayers.nullHandler = function(request) { 37 41 alert(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText})); … … 40 44 /** 41 45 * Function: loadURL 42 * Background load a document. 46 * Background load a document. For more flexibility in using XMLHttpRequest, 47 * see the <OpenLayers.Request> methods. 43 48 * 44 49 * Parameters: … … 50 55 * onComplete - {Function} Optional callback for success. The callback 51 56 * will be called with this set to caller and will receive the request 52 * object as an argument. 57 * object as an argument. Note that if you do not specify an onComplete 58 * function, <OpenLayers.nullHandler> will be called (which pops up an 59 * alert dialog). 53 60 * onFailure - {Function} Optional callback for failure. In the event of 54 61 * a failure, the callback will be called with this set to caller and will 55 * receive the request object as an argument. 62 * receive the request object as an argument. Note that if you do not 63 * specify an onComplete function, <OpenLayers.nullHandler> will be called 64 * (which pops up an alert dialog). 56 65 * 57 66 * Returns: 58 * { XMLHttpRequest} The request object. To abort loading, call59 * request.abort().67 * {<OpenLayers.Request.XMLHttpRequest>} The request object. To abort loading, 68 * call request.abort(). 60 69 */ 61 70 OpenLayers.loadURL = function(uri, params, caller, 62 71 onComplete, onFailure) { 63 64 var success = (onComplete) ? OpenLayers.Function.bind(onComplete, caller) 65 : OpenLayers.nullHandler; 66 67 var failure = (onFailure) ? OpenLayers.Function.bind(onFailure, caller) 68 : OpenLayers.nullHandler; 69 70 // from prototype.js 71 var request = new OpenLayers.Ajax.Request( 72 uri, 73 { 74 method: 'get', 75 parameters: params, 76 onComplete: success, 77 onFailure: failure 78 } 79 ); 80 return request.transport; 72 73 if(typeof params == 'string') { 74 params = OpenLayers.Util.getParameters(params); 75 } 76 var success = (onComplete) ? onComplete : OpenLayers.nullHandler; 77 var failure = (onFailure) ? onFailure : OpenLayers.nullHandler; 78 79 return OpenLayers.Request.GET({ 80 url: uri, params: params, 81 success: success, failure: failure, scope: caller 82 }); 81 83 }; 82 84 … … 264 266 /** 265 267 * Class: OpenLayers.Ajax.Request 268 * *Deprecated*. Use <OpenLayers.Request> method instead. 266 269 * 267 270 * Inherit: sandbox/camptocamp/unhcr/lib/OpenLayers/Control/PanZoomBar.js
r6833 r7349 187 187 imgLocation + "zoombar.png", 188 188 "absolute", null, "crop"); 189 div.style.height = sz.h ;189 div.style.height = sz.h + "px"; 190 190 } else { 191 191 div = OpenLayers.Util.createDiv( sandbox/camptocamp/unhcr/lib/OpenLayers/Format/KML.js
r6748 r7349 10 10 * @requires OpenLayers/Geometry/Polygon.js 11 11 * @requires OpenLayers/Geometry/Collection.js 12 * @requires OpenLayers/Request/XMLHttpRequest.js 12 13 */ 13 14 … … 250 251 */ 251 252 fetchLink: function(href) { 252 var request = new OpenLayers.Ajax.Request(href, 253 {method: 'get', asynchronous: false }); 254 255 if (request && request.transport) { 256 return request.transport.responseText; 253 var request = OpenLayers.Request.GET({url: href, async: false}); 254 if (request) { 255 return request.responseText; 257 256 } 258 257 }, … … 551 550 var inlineStyle= this.parseStyle(inlineStyleNode); 552 551 if (inlineStyle) { 553 feature.style = OpenLayers.Util.extend( {},554 feature.style);555 OpenLayers.Util.extend(feature.style, inlineStyle);552 feature.style = OpenLayers.Util.extend( 553 feature.style, inlineStyle 554 ); 556 555 } 557 556 } sandbox/camptocamp/unhcr/lib/OpenLayers/Format/SLD/v1.js
r7156 r7349 235 235 symbolizer.externalGraphic = graphic.href; 236 236 } 237 if(graphic.rotation != undefined) { 238 symbolizer.rotation = graphic.rotation; 239 } 237 240 }, 238 241 "ExternalGraphic": function(node, graphic) { … … 291 294 "stroke-linecap": "strokeLinecap", 292 295 "fill": "fillColor", 293 "fill-opacity": "fillOpacity" 296 "fill-opacity": "fillOpacity", 297 "font-family": "fontFamily", 298 "font-size": "fontSize" 294 299 }, 295 300 … … 597 602 value: obj.symbolizer[obj.key] 598 603 }); 604 }, 605 "TextSymbolizer": function(symbolizer) { 606 var node = this.createElementNSPlus("TextSymbolizer"); 607 // add in optional Label 608 if(symbolizer.label != null) { 609 this.writeNode(node, "Label", symbolizer.label); 610 } 611 // add in optional Font 612 if(symbolizer.fontFamily != null || 613 symbolizer.fontSize != null) { 614 this.writeNode(node, "Font", symbolizer); 615 } 616 // add in optional Fill 617 if(symbolizer.fillColor != null || 618 symbolizer.fillOpacity != null) { 619 this.writeNode(node, "Fill", symbolizer); 620 } 621 return node; 622 }, 623 "Font": function(symbolizer) { 624 var node = this.createElementNSPlus("Font"); 625 // add in CssParameters 626 if(symbolizer.fontFamily) { 627 this.writeNode( 628 node, "CssParameter", 629 {symbolizer: symbolizer, key: "fontFamily"} 630 ); 631 } 632 if(symbolizer.fontSize) { 633 this.writeNode( 634 node, "CssParameter", 635 {symbolizer: symbolizer, key: "fontSize"} 636 ); 637 } 638 return node; 639 }, 640 "Label": function(label) { 641 // only the simplest of ogc:expression handled 642 // {label: "some text and a ${propertyName}"} 643 var node = this.createElementNSPlus("Label"); 644 var tokens = label.split("${"); 645 node.appendChild(this.createTextNode(tokens[0])); 646 var item, last; 647 for(var i=1; i<tokens.length; i++) { 648 item = tokens[i]; 649 last = item.indexOf("}"); 650 if(last > 0) { 651 this.writeNode( 652 node, "ogc:PropertyName", 653 {property: item.substring(0, last)} 654 ); 655 node.appendChild( 656 this.createTextNode(item.substring(++last)) 657 ); 658 } else { 659 // no ending }, so this is a literal ${ 660 node.appendChild( 661 this.createTextNode("${" + item) 662 ); 663 } 664 } 665 return node; 599 666 }, 600 667 "PolygonSymbolizer": function(symbolizer) { sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GML.js
r6573 r7349 5 5 /** 6 6 * @requires OpenLayers/Layer/Vector.js 7 * @requires OpenLayers/ Ajax.js7 * @requires OpenLayers/Request/XMLHttpRequest.js 8 8 */ 9 9 … … 101 101 loadGML: function() { 102 102 if (!this.loaded) { 103 var results = OpenLayers.loadURL(this.url, null, this, this.requestSuccess, this.requestFailure); 103 OpenLayers.Request.GET({ 104 url: this.url, 105 success: this.requestSuccess, 106 failure: this.requestFailure, 107 scope: this 108 }); 104 109 this.loaded = true; 105 110 } sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GeoRSS.js
r7052 r7349 6 6 /** 7 7 * @requires OpenLayers/Layer/Markers.js 8 * @requires OpenLayers/ Ajax.js8 * @requires OpenLayers/Request/XMLHttpRequest.js 9 9 */ 10 10 … … 101 101 if (!this.loaded) { 102 102 this.events.triggerEvent("loadstart"); 103 OpenLayers.loadURL(this.location, null, this, this.parseData); 103 OpenLayers.Request.GET({ 104 url: this.location, 105 success: this.parseData, 106 scope: this 107 }); 104 108 this.loaded = true; 105 109 } … … 128 132 * 129 133 * Parameters: 130 * ajaxRequest - { XMLHttpRequest}134 * ajaxRequest - {<OpenLayers.Request.XMLHttpRequest>} 131 135 */ 132 136 parseData: function(ajaxRequest) { sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/KaMap.js
r6748 r7349 65 65 newArguments.push(name, url, params, options); 66 66 OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); 67 this.params = (params ? params : {}); 68 if (params) { 69 OpenLayers.Util.applyDefaults( 70 this.params, 71 this.DEFAULT_PARAMS 72 ); 73 } 67 this.params = OpenLayers.Util.applyDefaults( 68 this.params, this.DEFAULT_PARAMS 69 ); 74 70 }, 75 71 sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapGuide.js
r6748 r7349 4 4 5 5 /** 6 * @requires OpenLayers/ Ajax.js6 * @requires OpenLayers/Request/XMLHttpRequest.js 7 7 * @requires OpenLayers/Layer/Grid.js 8 8 */ … … 203 203 getVisParams.format = 'text/xml'; 204 204 getVisParams = OpenLayers.Util.extend(getVisParams, params); 205 206 new OpenLayers.Ajax.Request(this.url, 207 { parameters: getVisParams, 208 method: 'get', 209 asynchronous: false //must be synchronous call to return control here 210 }); 205 206 OpenLayers.Request.GET({ 207 url: this.url, params: getVisParams, async: false 208 }); 211 209 } 212 210 sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapServer.js
r6418 r7349 43 43 OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); 44 44 45 if (arguments.length > 0) { 46 OpenLayers.Util.applyDefaults( 47 this.params, 48 this.DEFAULT_PARAMS 49 ); 50 } 45 this.params = OpenLayers.Util.applyDefaults( 46 this.params, this.DEFAULT_PARAMS 47 ); 51 48 52 49 // unless explicitly set in options, if the layer is transparent, sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Text.js
r7052 r7349 6 6 /** 7 7 * @requires OpenLayers/Layer/Markers.js 8 * @requires OpenLayers/ Ajax.js8 * @requires OpenLayers/Request/XMLHttpRequest.js 9 9 */ 10 10 … … 110 110 111 111 this.events.triggerEvent("loadstart"); 112 OpenLayers.loadURL(this.location, null, 113 this, this.parseData, onFail); 112 OpenLayers.Request.GET({ 113 url: this.location, 114 success: this.parseData, 115 failure: onFail, 116 scope: this 117 }); 114 118 this.loaded = true; 115 119 } … … 138 142 * 139 143 * Parameters: 140 * ajaxRequest - { XMLHttpRequest}144 * ajaxRequest - {<OpenLayers.Request.XMLHttpRequest>} 141 145 */ 142 146 parseData: function(ajaxRequest) { … … 171 175 172 176 // FIXME: At the moment, we only use this if we have an 173 // externalGraphic, because icon has no setOffset API Method. 174 if (feature.style.graphicXOffset !== null 175 && feature.style.graphicYOffset !== null) { 177 // externalGraphic, because icon has no setOffset API Method. 178 /** 179 * FIXME FIRST!! 180 * The Text format does all sorts of parseFloating 181 * The result of a parseFloat for a bogus string is NaN. That 182 * means the three possible values here are undefined, NaN, or a 183 * number. The previous check was an identity check for null. This 184 * means it was failing for all undefined or NaN. A slightly better 185 * check is for undefined. An even better check is to see if the 186 * value is a number (see #1441). 187 */ 188 if (feature.style.graphicXOffset !== undefined 189 && feature.style.graphicYOffset !== undefined) { 176 190 iconOffset = new OpenLayers.Pixel( 177 191 feature.style.graphicXOffset, sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/VirtualEarth.js
r6313 r7349 96 96 var veDiv = OpenLayers.Util.createDiv(this.name); 97 97 var sz = this.map.getSize(); 98 veDiv.style.width = sz.w ;99 veDiv.style.height = sz.h ;98 veDiv.style.width = sz.w + "px"; 99 veDiv.style.height = sz.h + "px"; 100 100 this.div.appendChild(veDiv); 101 101 sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WFS.js
r6495 r7349 139 139 } 140 140 141 this.params = params; 142 OpenLayers.Util.applyDefaults( 143 this.params, 144 OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) 145 ); 141 this.params = OpenLayers.Util.applyDefaults( 142 params, 143 OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) 144 ); 146 145 this.url = url; 147 146 }, … … 457 456 458 457 var data = this.writer.write(this.features); 459 460 var url = this.url; 461 462 var success = OpenLayers.Function.bind(this.commitSuccess, this); 463 464 var failure = OpenLayers.Function.bind(this.commitFailure, this); 465 466 // from prototype.js 467 new OpenLayers.Ajax.Request(url, 468 { method: 'post', 469 postBody: data, 470 onComplete: success, 471 onFailure: failure 472 } 473 ); 458 459 OpenLayers.Request.POST({ 460 url: this.url, 461 data: data, 462 success: this.commitSuccess, 463 failure: this.commitFailure, 464 scope: this 465 }); 474 466 }, 475 467 sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WorldWind.js
r6418 r7349 55 55 newArguments.push(name, url, params, options); 56 56 OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); 57 this.params = (params ? params : {}); 58 if (params) { 59 OpenLayers.Util.applyDefaults( 60 this.params, 61 this.DEFAULT_PARAMS 62 ); 63 } 57 this.params = OpenLayers.Util.applyDefaults( 58 this.params, this.DEFAULT_PARAMS 59 ); 64 60 }, 65 61 /** sandbox/camptocamp/unhcr/lib/OpenLayers/Map.js
r7241 r7349 1336 1336 */ 1337 1337 pan: function(dx, dy, options) { 1338 // this should be pushed to applyDefaults and extend 1339 if (!options) { 1340 options = {}; 1341 } 1342 OpenLayers.Util.applyDefaults(options, { 1338 options = OpenLayers.Util.applyDefaults(options, { 1343 1339 animate: true, 1344 1340 dragging: false sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/SVG.js
r6581 r7349 223 223 node.setAttributeNS(null, "r", style.pointRadius); 224 224 } 225 226 if (style.rotation) { 227 var rotation = OpenLayers.String.format( 228 "rotate(${0} ${1} ${2})", [style.rotation, x, y]); 229 node.setAttributeNS(null, "transform", rotation); 230 } 225 231 } 226 232 sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/VML.js
r6764 r7349 99 99 OpenLayers.Renderer.prototype.setSize.apply(this, arguments); 100 100 101 this.rendererRoot.style.width = this.size.w ;102 this.rendererRoot.style.height = this.size.h ;103 104 this.root.style.width = this.size.w ;105 this.root.style.height = this.size.h ;101 this.rendererRoot.style.width = this.size.w + "px"; 102 this.rendererRoot.style.height = this.size.h + "px"; 103 104 this.root.style.width = this.size.w + "px"; 105 this.root.style.height = this.size.h + "px"; 106 106 }, 107 107 … … 170 170 node.style.left = ((geometry.x/resolution)+xOffset).toFixed(); 171 171 node.style.top = ((geometry.y/resolution)-(yOffset+height)).toFixed(); 172 node.style.width = width; 173 node.style.height = height; 172 node.style.width = width + "px"; 173 node.style.height = height + "px"; 174 node.style.flip = "y"; 174 175 175 176 // modify style/options for fill and stroke styling below … … 210 211 fill.setAttribute("src", style.externalGraphic); 211 212 fill.setAttribute("type", "frame"); 212 node.style.flip = "y";213 213 214 214 if (!(style.graphicWidth && style.graphicHeight)) { 215 215 fill.aspect = "atmost"; 216 216 } 217 218 // additional rendering for rotated graphics 219 if (style.rotation) { 220 this.graphicRotate(node, xOffset, yOffset); 221 // make the fill fully transparent, because we now have 222 // the graphic as imagedata element. We cannot just remove 223 // the fill, because this is part of the hack described 224 // in graphicRotate 225 fill.setAttribute("opacity", 0); 226 } 217 227 } 218 228 if (fill.parentNode != node) { … … 248 258 } 249 259 return node; 260 }, 261 262 /** 263 * Method: graphicRotate 264 * If a point is to be styled with externalGraphic and rotation, VML fills 265 * cannot be used to display the graphic, because rotation of graphic 266 * fills is not supported by the VML implementation of Internet Explorer. 267 * This method creates a olv:imagedata element inside the VML node, 268 * DXImageTransform.Matrix and BasicImage filters for rotation and 269 * opacity, and a 3-step hack to remove rendering artefacts from the 270 * graphic and preserve the ability of graphics to trigger events. 271 * Finally, OpenLayers methods are used to determine the correct 272 * insertion point of the rotated image, because DXImageTransform.Matrix 273 * does the rotation without the ability to specify a rotation center 274 * point. 275 * 276 * Parameters: 277 * node - {DOMElement} 278 * xOffset - {Number} rotation center relative to image, x coordinate 279 * yOffset - {Number} rotation center relative to image, y coordinate 280 */ 281 graphicRotate: function(node, xOffset, yOffset) { 282 var style = style || node._style; 283 var options = node._options; 284 285 var aspectRatio, size; 286 if (!(style.graphicWidth && style.graphicHeight)) { 287 // load the image to determine its size 288 var img = new Image(); 289 img.onreadystatechange = OpenLayers.Function.bind(function() { 290 if(img.readyState == "complete" || 291 img.readyState == "interactive") { 292 aspectRatio = img.width / img.height; 293 size = Math.max(style.pointRadius * 2, 294 style.graphicWidth || 0, 295 style.graphicHeight || 0); 296 xOffset = xOffset * aspectRatio; 297 style.graphicWidth = size * aspectRatio; 298 style.graphicHeight = size; 299 this.graphicRotate(node, xOffset, yOffset) 300 } 301 }, this); 302 img.src = style.externalGraphic; 303 304 // will be called again by the onreadystate handler 305 return; 306 } else { 307 size = Math.max(style.graphicWidth, style.graphicHeight); 308 aspectRatio = style.graphicWidth / style.graphicHeight; 309 } 310 311 var width = Math.round(style.graphicWidth || size * aspectRatio); 312 var height = Math.round(style.graphicHeight || size); 313 node.style.width = width + "px"; 314 node.style.height = height + "px"; 315 316 // Three steps are required to remove artefacts for images with 317 // transparent backgrounds (resulting from using DXImageTransform 318 // filters on svg objects), while preserving awareness for browser 319 // events on images: 320 // - Use the fill as usual (like for unrotated images) to handle 321 // events 322 // - specify an imagedata element with the same src as the fill 323 // - style the imagedata element with an AlphaImageLoader filter 324 // with empty src 325 var image = document.getElementById(node.id + "_image"); 326 if (!image) { 327 image = this.createNode("olv:imagedata", node.id + "_image"); 328 node.appendChild(image); 329 } 330 image.style.width = width + "px"; 331 image.style.height = height + "px"; 332 image.src = style.externalGraphic; 333 image.style.filter = 334 "progid:DXImageTransform.Microsoft.AlphaImageLoader(" + 335 "src='', sizingMethod='scale')"; 336 337 var rotation = style.rotation * Math.PI / 180; 338 var sintheta = Math.sin(rotation); 339 var costheta = Math.cos(rotation); 340 341 // do the rotation on the image 342 var filter = 343 "progid:DXImageTransform.Microsoft.Matrix(M11=" + costheta + 344 ",M12=" + (-sintheta) + ",M21=" + sintheta + ",M22=" + costheta + 345 ",SizingMethod='auto expand')\n" 346 347 // set the opacity (needed for the imagedata) 348 var opacity = style.graphicOpacity || style.fillOpacity; 349 if (opacity && opacity != 1) { 350 filter += 351 "progid:DXImageTransform.Microsoft.BasicImage(opacity=" + 352 opacity+")\n"; 353 } 354 node.style.filter = filter; 355 356 // do the rotation again on a box, so we know the insertion point 357 var centerPoint = new OpenLayers.Geometry.Point(-xOffset, -yOffset); 358 var imgBox = new OpenLayers.Bounds(0, 0, width, height).toGeometry(); 359 imgBox.rotate(style.rotation, centerPoint); 360 var imgBounds = imgBox.getBounds(); 361 362 node.style.left = Math.round( 363 parseInt(node.style.left) + imgBounds.left) + "px"; 364 node.style.top = Math.round( 365 parseInt(node.style.top) - imgBounds.bottom) + "px"; 250 366 }, 251 367 … … 296 412 297 413 // Set the internal coordinate system to draw the path 298 node.style.left = scaledBox.left ;299 node.style.top = scaledBox.top ;300 node.style.width = scaledBox.getWidth() ;301 node.style.height = scaledBox.getHeight() ;414 node.style.left = scaledBox.left + "px"; 415 node.style.top = scaledBox.top + "px"; 416 node.style.width = scaledBox.getWidth() + "px"; 417 node.style.height = scaledBox.getHeight() + "px"; 302 418 303 419 node.coordorigin = scaledBox.left + " " + scaledBox.top; … … 415 531 var resolution = this.getResolution(); 416 532 417 node.style.left = ( geometry.x /resolution).toFixed() - radius;418 node.style.top = ( geometry.y /resolution).toFixed() - radius;533 node.style.left = ((geometry.x /resolution).toFixed() - radius) + "px"; 534 node.style.top = ((geometry.y /resolution).toFixed() - radius) + "px"; 419 535 420 536 var diameter = radius * 2; 421 537 422 node.style.width = diameter ;423 node.style.height = diameter ;538 node.style.width = diameter + "px"; 539 node.style.height = diameter + "px"; 424 540 } 425 541 }, … … 523 639 var resolution = this.getResolution(); 524 640 525 node.style.left = geometry.x/resolution ;526 node.style.top = geometry.y/resolution ;527 node.style.width = geometry.width/resolution ;528 node.style.height = geometry.height/resolution ;641 node.style.left = geometry.x/resolution + "px"; 642 node.style.top = geometry.y/resolution + "px"; 643 node.style.width = geometry.width/resolution + "px"; 644 node.style.height = geometry.height/resolution + "px"; 529 645 }, 530 646 sandbox/camptocamp/unhcr/lib/OpenLayers/Request.js
r7177 r7349 26 26 data: null, 27 27 callback: function() {}, 28 success: null, 29 failure: null, 28 30 scope: null 29 31 }, … … 37 39 * config - {Object} Object containing properties for configuring the 38 40 * request. Al
