[OpenLayers-Users] Node has no parent exception when trying to draw Polygon

samd sdoyle_2 at yahoo.com
Thu Jan 17 14:13:14 EST 2008


Excellent Chris, thanks this worked.

S.D.



Christopher Schmidt-4 wrote:
> 
> On Thu, Jan 17, 2008 at 10:25:09AM -0800, samd wrote:
>> 
>> Hi, I originally had thought this but looking at the drawFeature function
>> of
>> OpenLayers.Control.DrawFeature on wiki it creates it.
> 
> Um. I don't know what you're trying to do, but using the drawFeature
> control to add features to your layer is not the right solution. 
> 
>>          var polygonAreaPoints = incidents[i].areaPoints;
>>          var pointArray = new Array();
>>          
>>          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 );
>   -> now do this:
>   var f = new OpenLayers.Feature.Vector(feature);
>   layer.addFeatures(f);
> 
> where layer is a Layer.Vector which has been added to your map.
> 
> Regards,
> -- 
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://www.nabble.com/Node-has-no-parent-exception-when-trying-to-draw-Polygon-tp14910427p14929765.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list