The problem occurs when saving a node leaving the WTK field empty: openlayers_behavior_drawfeatures_update() populates the WTK field with an empty geometry: GEOMETRYCOLLECTION().

When the same node is edited the empty geometry retrieved from the WTK field causes:

TypeError: features[i] is undefined { message="features[i] is undefined",  more...}

in openlayers_behavior_drawfeatures.js and it also prevents the "Draw Feature" behavior to show up correctly on the WTK map. A patch is attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ademarco’s picture

Title: Population WTK field with empty geometry GEOMETRYCOLLECTION() » WTK field populated with empty geometry GEOMETRYCOLLECTION()

Choosing a better title. :)

tmcw’s picture

Would a fix on the other side of this problem: making sure that drawfeatures can handle an empty features array - a GEOMETRYCOLLECTION() value - work as well for your use case? The code written in drawfeatures, and indeed, in the module needs to be robust to handle every valid/reasonable WKT input, I'd think.

ademarco’s picture

Yes, it would work anyway and, indeed, the module must be able to handle any kind of valid WKT value. Which kind of solution you'd suggest?

tmcw’s picture

Status: Active » Needs review

Here's a patch that makes sure that the module will readily accept GEOMETRYCOLLECTION(), by checking against the [undefined] array that it generates. This works for the types of input I can think of: single elements, blank, geometrycollection(elements) and geometrycollection().

tmcw’s picture

Whoops, here's the patch.

ademarco’s picture

The patch works great for me. Thanks!

tmcw’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Francewhoa’s picture

@Maintainers: Could you release a new version 6.x-2.0-alpha11? This patch missed the latest stable release by a few days.