Ticket #2445 (closed feature: duplicate)

Opened 3 years ago

Last modified 3 years ago

Deactivating OpenLayers.Control.DrawFeature after featureadded causes error: 'this.layer.renderer' is null or not an object

Reported by: ElijahBitting Owned by:
Priority: minor Milestone: 2.9 Release
Component: Control.DrawFeature Version: 2.8
Keywords: Cc:
State: Review

Description

I am using OpenLayers.Control.DrawFeature control to draw regular polygons (very similar to OpenLayers Example: "OpenLayers Draw Feature Example" (http://openlayers.org/dev/examples/draw-feature.html). But I need to grab and display the drawn polygon's geometry in WKT. This all works fine, but I want to restore the "Navigation" control after a feature is drawn. i.e. I don't want clicking on the map immediately after drawing a polygon to cause a 2nd polygon to be drawn. So at the end of the Method I register as the "featureadded" handler, I call a function that deactivates the DrawFeature control. This causes the following error in IE8.0.6001.18702: "error: 'this.layer.renderer' is null or not an object"

After a little tracing I found the error occurred as a result of the following statement:

this.layer.renderer.clear();

At this point "this" is the control's handler and it's layer has been set to null. So I simply wrapped this statement and the next (which also references this.layer) in a simple if(this.layer != null) check.

Change History

Changed 3 years ago by bartvde

  • status changed from new to closed
  • resolution set to duplicate

duplicate of ticket:2446

Note: See TracTickets for help on using tickets.