Hi All !

 

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?

 

 

GeometryFactory geomFac = new GeometryFactory();

Coordinate[] polygonCoordinates = new Coordinate[5];

                  

polygonCoordinates[0] = new Coordinate(xMin, yMin);

polygonCoordinates[1] = new Coordinate(xMin, yMax);

polygonCoordinates[2] = new Coordinate(xMax, yMax);

polygonCoordinates[3] = new Coordinate(xMax, yMin);

polygonCoordinates[4] = new Coordinate(xMin, yMin);

LinearRing ring = geomFac.createLinearRing(polygonCoordinates);

Polygon polygon = geomFac.createPolygon(ring,null);

 

AttributeType geom = AttributeTypeFactory.newAttributeType("the_geom", Polygon.class);

 

FeatureType ftPoly = null;

try {

         ftPoly = FeatureTypeFactory.newFeatureType(new AttributeType[] {geom}, "poly");

} catch (FactoryConfigurationError e1) {

         e1.printStackTrace();

} catch (SchemaException e1) {

         e1.printStackTrace();

}

    

Feature feature1 = null;

try {

         feature1 = ftPoly.create(new Object[] { polygon });

} catch (IllegalAttributeException e) {

         e.printStackTrace();

}

                                     

//feature collection creation ------------------

FeatureCollection fc = FeatureCollections.newCollection();

fc.add(feature1);    

       

final StyleBuilder builder = new StyleBuilder();

final Style style;

style = builder.createStyle(builder.createPolygonSymbolizer(Color.ORANGE, Color.BLACK, 1));

MapLayer layer = new DefaultMapLayer(fc, style);

layer.setTitle("Rectangle");

if (_mapContext==null) {

        System.out.println("BUG sur le _mapContext !");

}

       

_mapContext.clearLayerList();

_mapContext.addLayer(layer);    

_mapContext.getLayer(0).setVisible(true);

try {

           this.setMapContext(_mapContext);

} catch (Exception e) {

e.printStackTrace();

}       

 

 

Thanks!

 

Virginie Berre / Ingénieur étude et développement

Générale d’Infographie

ZA Les Erables – Bâtiment 4

66, route de Sartrouville – F-78230 – LE PECQ

Tél : (33) (0)1.30.15.40.50 – Fax : (33) (0)1.30.15.40.60

mailto:[EMAIL PROTECTED]

http://www.generale-infographie.fr/

 

Reply via email to