[OpenLayers-Users] Deactivate a control by its callback
pribram pribram
pribrampribram at post.cz
Fri Apr 17 10:46:26 EDT 2009
Hi,
I would like to deactivate the control based on OpenLayers.Control.Measure inside its own callback function. After the second click the error appears - "this.point.geometry' is null or not an object" on this.callback("modify",[this.point.geometry,this.getSketch()]);
My code:
var map;
function init(){
map = new OpenLayers.Map('map', {projection: new OpenLayers.Projection("EPSG:900913")});
var ghyb = new OpenLayers.Layer.Google(
"Google",
{ type: G_SATELLITE_MAP }
);
map.addLayers([ghyb]);
var madrid = new OpenLayers.LonLat(5, 40).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
map.setCenter(madrid, 5);
var ctrl = new OpenLayers.Control.MyMeas(OpenLayers.Handler.Path);
map.addControl(ctrl);
ctrl.activate();
}
OpenLayers.Control.MyMeas = OpenLayers.Class(OpenLayers.Control.Measure, {
clicks: 0,
draw: function() {
this.handler.callbacks = { point: this.point };
},
point: function(pnt, geom) {
switch (this.clicks) {
case 0:
this.clicks++;
break;
case 1:
this.deactivate();
break;
}
}
});
Thank you for any idea.
Pribram
More information about the Users
mailing list