Fix "center" processing - broke it with URL args change :<

This commit is contained in:
Mike Primm 2011-06-27 20:38:26 -05:00
parent bf29c09522
commit edf898ae1a

View File

@ -131,18 +131,15 @@ DynMap.prototype = {
if(urlarg != "") { if(urlarg != "") {
me.defaultworld.defaultmap = me.defaultworld.maps[urlarg] || me.defaultworld.defaultmap; me.defaultworld.defaultmap = me.defaultworld.maps[urlarg] || me.defaultworld.defaultmap;
} }
urlarg = parseInt(me.getParameterByName('x'),10); urlarg = me.getIntParameterByName('x');
if(urlarg != NaN) { if(urlarg != null)
me.defaultworld.center.x = urlarg; me.defaultworld.center.x = urlarg;
} urlarg = me.getIntParameterByName('y');
urlarg = parseInt(me.getParameterByName('y'),10); if(urlarg != null)
if(urlarg != NaN) {
me.defaultworld.center.y = urlarg; me.defaultworld.center.y = urlarg;
} urlarg = me.getIntParameterByName('z');
urlarg = parseInt(me.getParameterByName('z'), 10); if(urlarg != null)
if(urlarg != NaN) {
me.defaultworld.center.z = urlarg; me.defaultworld.center.z = urlarg;
}
}, },
initialize: function() { initialize: function() {
var me = this; var me = this;
@ -155,8 +152,9 @@ DynMap.prototype = {
.addClass('map') .addClass('map')
.appendTo(container); .appendTo(container);
var urlzoom = parseInt(me.getParameterByName('zoom'),10); var urlzoom = me.getIntParameterByName('zoom');
if(urlzoom != NaN) { me.options.defaultzoom = urlzoom; } if(urlzoom != null)
me.options.defaultzoom = urlzoom;
var map = this.map = new google.maps.Map(mapContainer.get(0), { var map = this.map = new google.maps.Map(mapContainer.get(0), {
zoom: me.options.defaultzoom || 0, zoom: me.options.defaultzoom || 0,
@ -625,6 +623,16 @@ DynMap.prototype = {
return ""; return "";
else else
return decodeURIComponent(results[1].replace(/\+/g, " ")); return decodeURIComponent(results[1].replace(/\+/g, " "));
},
getIntParameterByName: function(name) {
var v = this.getParameterByName(name);
if(v != "") {
v = parseInt(v, 10);
if(v != NaN) {
return v;
}
}
return null;
} }
// TODO: Enable hash-links. // TODO: Enable hash-links.
/* updateLink: function() { /* updateLink: function() {