Hi, I originally had thought this but looking at the drawFeature function of
OpenLayers.Control.DrawFeature on wiki it creates it.
drawFeature: function(geometry) {
var feature = new OpenLayers.Feature.Vector(geometry);
this.layer.addFeatures([feature]);
this.featureAdded(feature);
},
So here is my code.
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 );
drawFeature.drawFeature( feature );
Where drawFeature is:
var drawFeature = new OpenLayers.Control.DrawFeature(polygonLayer,
OpenLayers.Handler.Polygon,
{handlerOptions: {'freehand':
false},
'displayClass':
'olControlDrawFeaturePolygon'});
Thanks, S.D.
Christopher Schmidt-4 wrote:
>
> On Thu, Jan 17, 2008 at 11:47:46AM +0100, Pierre GIRAUD wrote:
>> I think you are missing one last step :
>> 4.) Creating a Feature.Vector given the created polygon.
>>
>> I may be wrong though.
>
> You're right, based on the description.
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Users mailing list
> [email protected]
> 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-tp14910427p14927690.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users