|
From: Virginie B. <vb...@gi...> - 2005-09-19 12:50:21
|
Hi All !
=20
In my class which extends StyledMapPane, instead of zooming by =
selecting an
area, I draw a polygon (method protected void =
mouseSelectionPerformed(final
Shape area)). What I don't understand is the fact that a zoom + is =
processed
and the new bounding box is the rectangle bounds. I've seen that the =
method
MapContext.addLayer(MapLayer) triggered a LayerListEvent. Is this event
processing the zoom + or is it something else?=20
=20
=20
GeometryFactory geomFac =3D new GeometryFactory();
Coordinate[] polygonCoordinates =3D new Coordinate[5];
=20
polygonCoordinates[0] =3D new Coordinate(xMin, yMin);
polygonCoordinates[1] =3D new Coordinate(xMin, yMax);
polygonCoordinates[2] =3D new Coordinate(xMax, yMax);
polygonCoordinates[3] =3D new Coordinate(xMax, yMin);
polygonCoordinates[4] =3D new Coordinate(xMin, yMin);
LinearRing ring =3D geomFac.createLinearRing(polygonCoordinates);
Polygon polygon =3D geomFac.createPolygon(ring,null);
=20
AttributeType geom =3D =
AttributeTypeFactory.newAttributeType("the_geom",
Polygon.class);
=20
FeatureType ftPoly =3D null;
try {
ftPoly =3D FeatureTypeFactory.newFeatureType(new =
AttributeType[]
{geom}, "poly");
} catch (FactoryConfigurationError e1) {
e1.printStackTrace();
} catch (SchemaException e1) {
e1.printStackTrace();
}
=20
Feature feature1 =3D null;
try {
feature1 =3D ftPoly.create(new Object[] { polygon });
} catch (IllegalAttributeException e) {
e.printStackTrace();
}
=20
//feature collection creation ------------------
FeatureCollection fc =3D FeatureCollections.newCollection();
fc.add(feature1); =20
=20
final StyleBuilder builder =3D new StyleBuilder();
final Style style;
style =3D =
builder.createStyle(builder.createPolygonSymbolizer(Color.ORANGE,
Color.BLACK, 1));
MapLayer layer =3D new DefaultMapLayer(fc, style);
layer.setTitle("Rectangle");
if (_mapContext=3D=3Dnull) {
System.out.println("BUG sur le _mapContext !");
}
=20
_mapContext.clearLayerList();
_mapContext.addLayer(layer); =20
_mapContext.getLayer(0).setVisible(true);
try {
this.setMapContext(_mapContext);
} catch (Exception e) {
e.printStackTrace();
} =20
=20
=20
Thanks!
=20
Virginie Berre / Ing=E9nieur =E9tude et d=E9veloppement
G=E9n=E9rale d'Infographie
ZA Les Erables - B=E2timent 4
66, route de Sartrouville - F-78230 - LE PECQ
T=E9l : (33) (0)1.30.15.40.50 - Fax : (33) (0)1.30.15.40.60
<mailto:vb...@gi...> mailto:vb...@gi...
<http://www.generale-infographie.fr/> =
http://www.generale-infographie.fr/
=20
|