Permalink will now save state if there's no base layer when it's added, and
change the map when the first baselayer loads. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1537 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -36,12 +36,23 @@ OpenLayers.Control.Permalink.prototype =
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
var args = OpenLayers.Util.getArgs();
|
||||
if (args.lat && args.lon) {
|
||||
this.map.setCenter(
|
||||
new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(args.lat))
|
||||
);
|
||||
if (this.map.baseLayer) {
|
||||
this.map.setCenter(
|
||||
new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(args.lat))
|
||||
);
|
||||
} else {
|
||||
this.centerData = new OpenLayers.LonLat(
|
||||
parseFloat(args.lon),
|
||||
parseFloat(args.lat));
|
||||
this.map.events.register( 'changebaselayer', this, this.setCenter);
|
||||
}
|
||||
}
|
||||
if (args.zoom) {
|
||||
this.map.zoomTo(parseInt(args.zoom));
|
||||
if (this.map.baseLayer) {
|
||||
this.map.zoomTo(parseInt(args.zoom));
|
||||
} else {
|
||||
this.zoomData = parseInt(args.zoom);
|
||||
}
|
||||
}
|
||||
if (!this.element) {
|
||||
this.element = document.createElement("a");
|
||||
@@ -70,6 +81,15 @@ OpenLayers.Control.Permalink.prototype =
|
||||
var lon = Math.round(center.lon*100000)/100000;
|
||||
this.element.href = this.base+"?lat="+lat+"&lon="+lon+"&zoom="+zoom;
|
||||
},
|
||||
|
||||
setCenter: function() {
|
||||
if (this.map.baseLayer && this.centerData) {
|
||||
this.map.setCenter(this.centerData, this.zoomData ? this.zoomData : null);
|
||||
this.centerData = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.Permalink"
|
||||
|
||||
Reference in New Issue
Block a user