See answers inline. On Nov 18, 2011, at 10:55 , JS Ubei wrote:
> Hi dear list, > > I have a vector feature "boxFeature" like : > > ######## > var pointList = [ > new OpenLayers.Geometry.Point(-180, -90), > new OpenLayers.Geometry.Point(180, -90), > new OpenLayers.Geometry.Point(180, 90), > new OpenLayers.Geometry.Point(-180, 90), > new OpenLayers.Geometry.Point(-180, -90) > ]; > var linearRing = new OpenLayers.Geometry.LinearRing(pointList); > boxFeature = new OpenLayers.Feature.Vector(new > OpenLayers.Geometry.Polygon([linearRing])); > ######## > > > After object creation, if I ask feature bounds I have : > > -180,-90,180,90 > > > Ok. > > After I modify my feature like : > > ######## > > boxFeature.geometry.components[0].components[0].x = 0; > boxFeature.geometry.components[0].components[0].y = 0; You have to use the API to modify coordinates. Instead of the above two lines, just do: boxFeature.geometry.components[0].components[0].move(180, 90); Or if you want to set the coordinates directly, you have to call clearBounds() on the geometry you changed, i.e. boxFeature.geometry.components[0].components[0].x = 0; boxFeature.geometry.components[0].components[0].y = 0; boxFeature.geometry.components[0].components[0].clearBounds(); > [etc.] > > myLayer.drawFeature(boxFeature); > > ######## > > > And when I ask for feature bounds I have the old values : > -180,-90,180,90 Now you will still have the same bounds, because these are still the bounds of the polygon. "POLYGON((0 0,180 -90,180 90,-180 90,0 0))" But if you now do boxFeature.geometry.components[0].components[1].move(-180,90); your polygon will be "POLYGON((0 0,0 0,180 90,-180 90,0 0))" and the bounds will be -180,0,180,90 Andreas. > > > I've try to use some functions like : > > ####### > boxFeature.geometry.clearBounds(); > boxFeature.geometry.bounds = new OpenLayers.Bounds(0, 0, 180, 90); > boxFeature.geometry.calculateBounds(); > ####### > > But unfortunatly I always get the old bounds -180,-90,180,90 > ... > > Someone can help me ? > > Thanks and best regards, > > Nono > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
