Implemented activate, deactivate and destroy methods; use autoActivate option with a default of true. p=jorix,r=me (closes #2567)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10510 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -17,6 +17,13 @@
|
||||
*/
|
||||
OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: autoActivate
|
||||
* {Boolean} Activate the control when it is added to a map. Default is
|
||||
* true.
|
||||
*/
|
||||
autoActivate: true,
|
||||
|
||||
/**
|
||||
* APIProperty: intervals
|
||||
* {Array(Float)} A list of possible graticule widths in degrees.
|
||||
@@ -27,8 +34,8 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: displayInLayerSwitcher
|
||||
* {Boolean} Allows the Graticule control to be switched on and off.
|
||||
* defaults to true.
|
||||
* {Boolean} Allows the Graticule control to be switched on and off by
|
||||
* LayerSwitcher control. Defaults is true.
|
||||
*/
|
||||
displayInLayerSwitcher: true,
|
||||
|
||||
@@ -53,9 +60,10 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: layerName
|
||||
* {String} the name to be displayed in the layer switcher
|
||||
* {String} The name to be displayed in the layer switcher, default is set
|
||||
* by {<OpenLayers.Lang>}.
|
||||
*/
|
||||
layerName: "Graticule",
|
||||
layerName: null,
|
||||
|
||||
/**
|
||||
* APIProperty: labelled
|
||||
@@ -102,6 +110,8 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
* to extend the control.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
options.layerName = options.layerName || OpenLayers.i18n("graticule");
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
|
||||
this.labelSymbolizer.stroke = false;
|
||||
@@ -112,6 +122,18 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.labelSymbolizer.labelYOffset = "${yOffset}";
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
this.deactivate();
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
if (this.gratLayer) {
|
||||
this.gratLayer.destroy();
|
||||
this.gratLayer = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
*
|
||||
@@ -134,13 +156,36 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
visibility: this.visible,
|
||||
displayInLayerSwitcher: this.displayInLayerSwitcher
|
||||
});
|
||||
this.map.addLayer(this.gratLayer);
|
||||
}
|
||||
this.map.events.register('moveend', this, this.update);
|
||||
this.update();
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: activate
|
||||
*/
|
||||
activate: function() {
|
||||
if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {
|
||||
this.map.addLayer(this.gratLayer);
|
||||
this.map.events.register('moveend', this, this.update);
|
||||
this.update();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: deactivate
|
||||
*/
|
||||
deactivate: function() {
|
||||
if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {
|
||||
this.map.events.unregister('moveend', this, this.update);
|
||||
this.map.removeLayer(this.gratLayer);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Method: update
|
||||
*
|
||||
|
||||
@@ -87,6 +87,7 @@ OpenLayers.Lang.en = {
|
||||
'E': 'E',
|
||||
'N': 'N',
|
||||
'S': 'S',
|
||||
'graticule': 'Graticule',
|
||||
|
||||
// console message
|
||||
'layerAlreadyAdded':
|
||||
@@ -121,9 +122,11 @@ OpenLayers.Lang.en = {
|
||||
// console message
|
||||
'pagePositionFailed':
|
||||
"OpenLayers.Util.pagePosition failed: element with id ${elemId} may be misplaced.",
|
||||
|
||||
'end': '',
|
||||
|
||||
// console message
|
||||
'filterEvaluateNotImplemented': "evaluate is not implemented for this filter type."
|
||||
'filterEvaluateNotImplemented': "evaluate is not implemented for this filter type.",
|
||||
|
||||
// **** end ****
|
||||
'end': ''
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user