[OpenLayers-Users] Node has no parent exception when trying to
draw Polygon
samd
sdoyle_2 at yahoo.com
Thu Jan 17 16:57:38 EST 2008
One more thing, I have built the source uncompressed in the hopes to be able
to step debug using Firebug but the version from svn when built tells me
that rendering is not supported in my browser even though I am using
Firefox.
S.D.
samd wrote:
>
> Apologies but I'm now encountering the same error at a later stage with
> the SelectFeature. So after doing what you suggested the polygons do
> render but mousing over to select the polygon results in the same
> node.parentNode has no properties error. I have even attempted to destroy
> the SelectFeature and recreate it after the points are retrieved as shown
> in the following.
>
> // 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 polygons have been rendered on the map so now recreate the
> SelectFeature even though
> // this should not be required.
>
> map.removeControl( selectControl );
> selectControl.destroy();
> selectControl = new
> OpenLayers.Control.SelectFeature(polygonLayer,
> {hover: true,
> onSelect:
> polySelected})
> map.addControl( selectControl );
> selectControl.activate();
>
> Thanks once again, 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-tp14910427p14934891.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list