make sure permalink updates itself when layers change name/visibility or when a baselayer switch is made. (Closes #359)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4228 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -93,6 +93,8 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.div.appendChild(this.element);
|
||||
}
|
||||
this.map.events.register('moveend', this, this.updateLink);
|
||||
this.map.events.register('changelayer', this, this.updateLink);
|
||||
this.map.events.register('changebaselayer', this, this.updateLink);
|
||||
return this.div;
|
||||
},
|
||||
|
||||
@@ -101,6 +103,12 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
updateLink: function() {
|
||||
var center = this.map.getCenter();
|
||||
|
||||
// Map not initialized yet. Break out of this function.
|
||||
if (!center) {
|
||||
return;
|
||||
}
|
||||
|
||||
var zoom = "zoom=" + this.map.getZoom();
|
||||
var lat = "lat=" + Math.round(center.lat*100000)/100000;
|
||||
var lon = "lon=" + Math.round(center.lon*100000)/100000;
|
||||
|
||||
Reference in New Issue
Block a user