[OpenMap Users] Problem with layers

From: Saglietti Davide <davide.saglietti_at_guest.telecomitalia.it>
Date: Thu, 11 Oct 2007 13:58:50 +0200

Dear all, I have a problem with layers. I build mi window with the
following code:

mapBean = new BufferedLayerMapBean();

        mapBean.setBorder(border);

        mapBean.setProjection(proiezione);

        mapBean.setPreferredSize(new Dimension(this.larghezza,
this.altezza));

        mapBean.setBackground(Color.WHITE);

        

        //projectionSupport = new ProjectionSupport(this);

        mapHandler = new MapHandler();

        

        //Preparo ed aggiungo il layer che contiene l'ingombro degli
edifici

        shapeLayerEdifici = new ShapeLayer();

        

        String fileEdifici = PropertySet.getProperty(fileConfGPS,
"fileEdifici", "to_str");

        

        String codiceColoreEdifici =
PropertySet.getProperty(fileConfGPS, "ColoreEdifici", "E4D184");

        String codiceColoreBordoEdifici =
PropertySet.getProperty(fileConfGPS, "ColoreBordoEdifici", "000000");

        

        Properties shapeLayerProps = new Properties();

        shapeLayerProps.put("prettyName", "Edifici");

        shapeLayerProps.put("lineColor", codiceColoreBordoEdifici);

        shapeLayerProps.put("fillColor", codiceColoreEdifici);

        shapeLayerProps.put("shapeFile", "mappe/" + fileEdifici +
".shp");

        shapeLayerProps.put("spatialIndex", "mappe/" + fileEdifici +
".ssx");

        

        shapeLayerEdifici.setProperties(shapeLayerProps);

        shapeLayerEdifici.setVisible(true);

        

        //Ora preparo ed aggiungo il layer che contiene il grafo
stradale

        shapeLayerStrade = new ShapeLayer();

        

        String fileStrade = PropertySet.getProperty(fileConfGPS,
"fileStrade", "mi_str");

        

        String codiceColoreStrade = PropertySet.getProperty(fileConfGPS,
"coloreMezzaria", "000000");

        

        Properties shapeLayerStradeProps = new Properties();

        shapeLayerStradeProps.put("prettyName", "Stradario");

        shapeLayerStradeProps.put("lineColor", codiceColoreStrade);

        shapeLayerStradeProps.put("fillColor", "FFFFFF");

        shapeLayerStradeProps.put("shapeFile", "mappe/" + fileStrade +
".shp");

        shapeLayerStradeProps.put("spatialIndex", "mappe/" + fileStrade
+ ".ssx");

        

        shapeLayerStrade.setProperties(shapeLayerStradeProps);

        shapeLayerStrade.setVisible(true);

        

        // Last on top.

        mapHandler.add(mapBean);

        mapHandler.add(this);

        layerHandler = new LayerHandler();

        layerHandler.addLayer(shapeLayerEdifici);

        layerHandler.addLayer(shapeLayerStrade);

        mapHandler.add(layerHandler);

        

        double latitudine =
PropertySet.getDoubleProperty(fileConfGPS,"latitudine",0.0);

        double longitudine = PropertySet.getDoubleProperty(fileConfGPS,
"longitudine", 0.0);

        

        livelloBus = new LivelloBus(latitudine,longitudine,
this.principale);

                mapHandler.add(livelloBus);

 

 

Then I have to remove and add the layer called "shapeLayerEdifici". How
can I do that? I tried with the following code but it removes the layer
correctly but it doesn't add the layer (or better, it doesn't repaint
the layer)

 

if(this.mapHandler.contains(shapeLayerEdifici)){

 
((LayerHandler)this.mapHandler.get(LayerHandler.class)).removeLayer(shap
eLayerEdifici);

                        }else{

((LayerHandler)this.mapHandler.get(LayerHandler.class)).addLayer(shapeLa
yerEdifici,0);

                        }

 

 

Davide Saglietti

 

c/o Telecom Italia Lab

Via Guglielmo Reiss Romoli 274

10148 TORINO

 

tel: +39 011 228 5523

e-mail: davide.saglietti_at_guest.telecomitalia.it

 



--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Oct 11 2007 - 08:11:02 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:08 EDT