[OpenLayers-Users] Deactivate Draw-Control after feature added

Christopher Schmidt crschmidt at metacarta.com
Fri Apr 11 09:22:01 EDT 2008


On Fri, Apr 11, 2008 at 09:55:55PM +1000, Zac Spitzer wrote:
> I'm seeing the same issue with the trunk code at the moment, removing
> the deactivate from the
> featureAdded handler stops the error but i need a work around?

Did this work in 2.5? (Is it a regression?)

-- Chris

> any ideas?
> 
> 
> On Mon, Apr 7, 2008 at 6:13 PM, Kevin Kempfer <mail at kevinkempfer.de> wrote:
> > Hi,
> >
> >  I'm trying to let the user draw a line feature and deactivate the draw
> > feature after the feature was added to the map. Here's my code:
> >
> >  var drawControls = {
> >                 point: new OpenLayers.Control.DrawFeature(vectors,
> >                             OpenLayers.Handler.Point),
> >                 line: new OpenLayers.Control.DrawFeature(vectors,
> >
> >  OpenLayers.Handler.Path,{featureAdded:
> > toggle }
> >                         ),
> >                 rectangle: new OpenLayers.Control.DrawFeature(vectors,
> >                             OpenLayers.Handler.Box),
> >                 select: new OpenLayers.Control.SelectFeature(vectors),
> >             };
> >
> >             for(var key in drawControls) {
> >                 map.addControl(drawControls[key]);
> >             }
> >
> >
> >  function toggle(feature){
> >         var linecontrol = drawControls['line'];
> >         linecontrol.deactivate();
> >  }
> >
> >  I get an error as soon as the control gets deactivated:
> >  this.point has no properties
> >  -> this.point.destroy();
> >
> >  Here's the trace from FireBug:
> >  destroyFeature()Point.js (line 128)
> >  destroyFeature()Path.js (line 81)
> >  finalize()Point.js (line 139)
> >  dblclick(dblclick clientX=0, clientY=0)Path.js (line 240)
> >  triggerEvent("dblclick", dblclick clientX=0, clientY=0)Events.js (line 612)
> >  handleBrowserEvent(dblclick clientX=0, clientY=0)Events.js (line 640)
> >  bindAsEventListener(dblclick clientX=0, clientY=0)
> >
> >  Looks like the control gets deactivated too early in the feature-adding
> > process. Is there any advice on how to deactivate a draw control after
> > drawing a feature?
> >
> >  Thanks,
> >
> >  Kevin
> >
> > _______________________________________________
> >  Users mailing list
> >  Users at openlayers.org
> >  http://openlayers.org/mailman/listinfo/users
> >
> >
> 
> 
> 
> -- 
> Zac Spitzer -
> http://zacster.blogspot.com (My Blog)
> +61 405 847 168
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list