Factor out getArgs into Util class, since we use it in other places as well. Modify Permalink Control to fit.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@848 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-07-01 14:05:34 +00:00
parent 15a47c6513
commit 7f6ffe8164
2 changed files with 16 additions and 16 deletions

View File

@@ -18,7 +18,7 @@ OpenLayers.Control.Permalink.prototype =
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
var args = this.getArgs();
var args = OpenLayers.Util.getArgs();
if (args.lat && args.lon) {
this.map.setCenter(
new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(args.lat))
@@ -44,21 +44,6 @@ OpenLayers.Control.Permalink.prototype =
return this.div;
},
getArgs: function() {
var args = new Object();
var query = location.search.substring(1); // Get query string.
var pairs = query.split("&"); // Break at ampersand. //+pjl
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('='); // Look for "name=value".
if (pos == -1) continue; // If not found, skip.
var argname = pairs[i].substring(0,pos); // Extract the name.
var value = pairs[i].substring(pos+1); // Extract the value.
args[argname] = unescape(value); // Store as a property.
}
return args; // Return the object.
},
updateLink: function() {
center = this.map.getCenter();
zoom = this.map.getZoom();

View File

@@ -1008,3 +1008,18 @@ OpenLayers.Util.distVincenty=function(p1, p2) {
var d = s.toFixed(3)/1000; // round to 1mm precision
return d;
};
OpenLayers.Util.getArgs = function() {
var args = new Object();
var query = location.search.substring(1); // Get query string.
var pairs = query.split("&"); // Break at ampersand. //+pjl
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('='); // Look for "name=value".
if (pos == -1) continue; // If not found, skip.
var argname = pairs[i].substring(0,pos); // Extract the name.
var value = pairs[i].substring(pos+1); // Extract the value.
args[argname] = unescape(value); // Store as a property.
}
return args; // Return the object.
};