[OpenLayers-Users] Selecting polygon error.

Eric Lemoine eric.c2c at gmail.com
Fri Jan 18 03:48:08 EST 2008


Do you have the problem if you remove the onSelect and onUnselect
callbaks from the select feature control options?

2008/1/18, samd <sdoyle_2 at yahoo.com>:
>
> 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.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list