Ticket #1489: permalink.patch
| File permalink.patch, 3.0 kB (added by tcoulter, 9 months ago) |
|---|
-
lib/OpenLayers/Control/Permalink.js
old new 14 14 * - <OpenLayers.Control> 15 15 */ 16 16 OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, { 17 ARG_PARSER_CLASS_NAME: "OpenLayers.Control.ArgParser", 17 18 18 19 /** 19 20 * Property: element … … 80 81 //make sure we have an arg parser attached 81 82 for(var i=0; i< this.map.controls.length; i++) { 82 83 var control = this.map.controls[i]; 83 if (control.CLASS_NAME == "OpenLayers.Control.ArgParser") {84 if (control.CLASS_NAME == this.ARG_PARSER_CLASS_NAME) { 84 85 85 86 // If a permalink is added to the map, and an ArgParser already 86 87 // exists, we override the displayProjection to be the one 87 // on the permalink.88 // on the ArgParser. 88 89 if (control.displayProjection != this.displayProjection) { 89 90 this.displayProjection = control.displayProjection; 90 91 } … … 93 94 } 94 95 } 95 96 if (i == this.map.controls.length) { 96 this.map.addControl(new OpenLayers.Control.ArgParser(97 this.map.addControl(new eval(this.ARG_PARSER_CLASS_NAME)( 97 98 { 'displayProjection': this.displayProjection })); 98 99 } 99 100 … … 109 110 OpenLayers.Control.prototype.draw.apply(this, arguments); 110 111 111 112 if (!this.element) { 113 this.div.className = this.displayClass; 112 114 this.element = document.createElement("a"); 113 115 this.element.innerHTML = OpenLayers.i18n("permalink"); 114 116 this.element.href=""; … … 120 122 'changebaselayer': this.updateLink, 121 123 scope: this 122 124 }); 125 126 // Make it so there is at least a link even though the map may not have 127 // moved yet. 128 this.updateLink(); 129 123 130 return this.div; 124 131 }, 125 132 … … 127 134 * Method: updateLink 128 135 */ 129 136 updateLink: function() { 130 var center = this.map.getCenter(); 131 132 // Map not initialized yet. Break out of this function. 137 this.element.href = this.createUrl(); 138 }, 139 140 createUrl: function(center) { 141 142 if (center == null) { 143 center = this.map.getCenter(); 144 } 145 146 // If there's still no center, map is not initialized yet. 147 // Break out of this function, and simply return the base link. 133 148 if (!center) { 134 return ;149 return this.base; 135 150 } 136 151 137 152 var params = OpenLayers.Util.getParameters(this.base); … … 168 183 } 169 184 170 185 href += '?' + OpenLayers.Util.getParameterString(params); 171 this.element.href =href;186 return href; 172 187 }, 173 188 174 189 CLASS_NAME: "OpenLayers.Control.Permalink"
