[Commits] r807 - apps/opengeo/geoexplorer/trunk/lib
commits at geoext.org
commits at geoext.org
Mon May 18 22:00:53 CEST 2009
Author: tschaub
Date: 2009-05-18 22:00:53 +0200 (Mon, 18 May 2009)
New Revision: 807
Modified:
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
Log:
Show measure tip immediately upon click.
Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-05-18 17:39:08 UTC (rev 806)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-05-18 20:00:53 UTC (rev 807)
@@ -775,16 +775,7 @@
})]
})
});
-
- var measureControl = new OpenLayers.Control.Measure(handlerType, {
- persist: true,
- handlerOptions: {layerOptions: {styleMap: styleMap}}
- });
- var measureToolTip;
-
- var tooltipTitle = title;
-
var cleanup = function() {
if (measureToolTip) {
measureToolTip.destroy();
@@ -812,48 +803,56 @@
return metric.toFixed(2) + " " + metricUnit + dim + "<br>" +
english.toFixed(2) + " " + englishUnit + dim;
};
-
- measureControl.events.register("measurepartial", this, function(data) {
- cleanup();
-
- measureToolTip = new Ext.ToolTip({
- target: Ext.getBody(),
- html: makeString(data),
- title: tooltipTitle,
- autoHide: false,
- closable: true,
- draggable: false,
- showDelay: 5
- });
-
- measureToolTip.on("hide", function(evt) {
- cleanup();
- });
+
+ var measureToolTip;
+ var measureControl = new OpenLayers.Control.Measure(handlerType, {
+ persist: true,
+ handlerOptions: {layerOptions: {styleMap: styleMap}},
+ eventListeners: {
+ measurepartial: function(event) {
+ cleanup();
+ measureToolTip = new Ext.ToolTip({
+ target: Ext.getBody(),
+ html: makeString(event),
+ title: title,
+ autoHide: false,
+ closable: true,
+ draggable: false,
+ mouseOffset: [0, 0],
+ showDelay: 1,
+ listeners: {hide: cleanup}
+ });
+ if(event.measure > 0) {
+ var px = measureControl.handler.lastUp;
+ var p0 = this.mapPanel.getPosition();
+ measureToolTip.targetXY = [p0[0] + px.x, p0[1] + px.y];
+ measureToolTip.show();
+ }
+ },
+ measure: function(event) {
+ cleanup();
+ measureToolTip = new Ext.ToolTip({
+ target: Ext.getBody(),
+ html: makeString(event),
+ title: title,
+ autoHide: false,
+ closable: true,
+ draggable: false,
+ mouseOffset: [0, 0],
+ showDelay: 1,
+ listeners: {
+ hide: function() {
+ measureControl.cancel();
+ cleanup();
+ }
+ }
+ });
+ },
+ deactivate: cleanup,
+ scope: this
+ }
});
- measureControl.events.register("measure", this, function(data) {
- cleanup();
-
- measureToolTip = new Ext.ToolTip({
- target: Ext.getBody(),
- html: makeString(data),
- title: tooltipTitle,
- autoHide: false,
- closable: true,
- draggable: false,
- showDelay: 5
- });
-
-
- feature = new OpenLayers.Feature.Vector(data.geometry, {}, {});
-
- measureToolTip.on("hide", function() {
- measureControl.cancel();
- cleanup();
- }, this);
- });
-
- measureControl.events.register("deactivate", this, cleanup);
return measureControl;
},
More information about the Commits
mailing list