[OpenLayers-Users] How to handle a GeometryCollection Feature
Eric Lemoine
eric.lemoine at camptocamp.com
Wed Aug 26 01:24:45 EDT 2009
On Tue, Aug 25, 2009 at 3:00 PM, Max Weidemann<max.weidemann at freenet.de> wrote:
>
> Hi everybody
>
> my problem is that i dont know how i could at a new geometry to an
> GeometryCollection-Feature wich exists in an Vector layer.
>
> i have added the collection to the layer in a way like this:
>
> var gc_geometry = new OpenLayers.Geometry.Collection(
> [
> new OpenLayers.Geometry.Point( 1379550.27259943,
> 6678794.95971749),
> new OpenLayers.Geometry.LineString( [p1,p2,p3] ),
> new OpenLayers.Geometry.Polygon([
> new OpenLayers.Geometry.LinearRing([
> new
> OpenLayers.Geometry.Point(1378491.75288927, 6678659.00305747),
> new
> OpenLayers.Geometry.Point(1378491.75288927, 6679154.27374754),
> new
> OpenLayers.Geometry.Point(1379161.82499937, 6679154.27374754),
> new
> OpenLayers.Geometry.Point(1379161.82499937, 6678659.00305747),
> new
> OpenLayers.Geometry.Point(1378491.75288927, 6678659.00305747)])
> // etc.
> ])
> ]);
>
> var gc_feature = new OpenLayers.Feature.Vector( gc_geometry );
>
> vectorLayer.addFeatures( [ gc_feature ] );
>
>>>> In other function i would like to add or remove some of the components
>
> i get the feature with code like this:
> var feature = layer.getFeatureById(id);
>
>
> At this Point i do not know what is the smartest way to add or remove some
> components to the geometrycollection??
feature.geometry.addComponents([
new OpenLayers.Geometry.Point(...),
new OpenLayers.Geometry.Polygon(...)
]);
I think addComponents is documented in the API docs.
Cheers,
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list