From 93da80b0c41eb3dbf4d32bd2e32dda53cdd905ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Junod?= Date: Fri, 25 Feb 2011 08:52:28 +0000 Subject: [PATCH] deactivate the Geolocate control on destroy. r=bartvde,elemoine (closes #1185) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11459 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/Geolocate.js | 8 ++++++++ tests/Control/Geolocate.html | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/OpenLayers/Control/Geolocate.js b/lib/OpenLayers/Control/Geolocate.js index 7fb7f534f2..6745ab7595 100644 --- a/lib/OpenLayers/Control/Geolocate.js +++ b/lib/OpenLayers/Control/Geolocate.js @@ -73,6 +73,14 @@ OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, { OpenLayers.Control.prototype.initialize.apply(this, [options]); }, + /** + * Method: destroy + */ + destroy: function() { + this.deactivate(); + OpenLayers.Control.prototype.destroy.apply(this, arguments); + }, + /** * Method: activate * Activates the control. diff --git a/tests/Control/Geolocate.html b/tests/Control/Geolocate.html index d65bbdd3d2..541342076e 100644 --- a/tests/Control/Geolocate.html +++ b/tests/Control/Geolocate.html @@ -113,6 +113,17 @@ map.addControl(control); control.activate(); } + function test_destroy(t) { + t.plan(1); + var control = new OpenLayers.Control.Geolocate({ + geolocation: geolocation, + watch: true + }); + control.activate(); + control.destroy(); + t.ok(control.active === false, "control deactivated before being destroyed"); + } + function loader() { map = new OpenLayers.Map('map'); var layer = new OpenLayers.Layer.WMS("Test Layer",