[OpenLayers-Users] Selecting polygon error.

samd sdoyle_2 at yahoo.com
Thu Jan 17 22:56:43 EST 2008


Hi I was discussing this in a previous message but created a new one since it
is a different topic.

When I am using a select control on a polygonLayer such as the following:

selectControl = new OpenLayers.Control.SelectFeature(polygonLayer,
                                                            {hover: true,
                                                            onSelect:
polySelected,
                                                            onUnselect:
polyUnselected})
map.addControl( selectControl );
selectControl.activate();

And I regenerate a polygon from points retrieved from the server such as the
following:

 for ( var j = 0; j < polygonAreaPoints.length; j++ )
         {
            var x = polygonAreaPoints[j].x;
            var y = polygonAreaPoints[j].y;

            pointArray.push( new OpenLayers.Geometry.Point( x, y ) );
         }

         // Create the linear ring
         var ring = new OpenLayers.Geometry.LinearRing( pointArray );

         // Create the polygon
         var feature = new OpenLayers.Geometry.Polygon( ring );

         var f = new OpenLayers.Feature.Vector(feature);
         polygonLayer.addFeatures( f );

The SelectFeature generates the following error on hover:

node.parentNode has no properties

Tracing in Firebug the error occurs here in the OpenLayers.Renderer.Elements
class

nodeFactory: function(id, type) {
        var node = OpenLayers.Util.getElement(id);
        if (node) {
            if (!this.nodeTypeCompare(node, type)) {
                node.parentNode.removeChild(node); // ERROR OCCURS HERE
                node = this.nodeFactory(id, type);
            }
        } else {
            node = this.createNode(type, id);
        }
        return node;
    },

Now examining the debugger the node attribute is a number such as 103,105
etc and the type is "path"

The only thing that I can conclude is there is something missing from the
construction of the polygon or the addition to the layer in some aspect
since obviously the node just being a numeric value does not have a parent
attribute.

Once again the values are rendered on the map but the SelectFeature results
in this odd error. 

Anyone have any ideas?

Thanks,

S.D.



-- 
View this message in context: http://www.nabble.com/Selecting-polygon-error.-tp14946220p14946220.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list