Hello Florian,

There did used to be such a chain of events which JMapPane took
advantage of, but it was unfortunately dropped some time ago when the
feature collection classes were reworked.

The following thread may be helpful:

http://osgeo-org.1560.x6.nabble.com/Geotools-8-0-to-9-4-difference-with-SimpleFeatureCollection-and-Map-refresh-td5073829.html#a5073908

Michael


On 4 April 2014 01:31, fmd85 <florian-di...@gmx.de> wrote:
> Hi,
>
> I am currently trying to add/delete features on a feature layer and display
> them on a JMapFrame. It works fine, but the MapPane doesn't repaint on
> adding new features to the collection. I've read on this forum (1) that
> there should be a chain of events from the FeatureCollection to the MapPane,
> but it doesn't work for me, even the manual call of
> frame.getMapPane.repaint() doesn't help.
>
> Heres how i do it:
>
> *//1.  Create a JMapFrame*
> MapContent map = new MapContent();
> JMapFrame frame = new JMapFrame(map);
>
> *//2.  Create a SimpleFeatureList and a SimpleFeatureCollection*
> List<SimpleFeature> listSF = new ArrayList<SimpleFeature>();
> listSF.add(someFeatures);
>
> ListFeatureCollection colPoints = new
> ListFeatureCollection(myhelper.getFeatureTypePoint, listSF);
>
> Layer layer = new FeatureLayer(colPoints, SLD.createPointStyle("Circle",
> SLD.createPointStyle(...));
>                         map.addLayer(messlayer);
>
> *// 3. Now i add some more Points to the collection*
>
> colPoints.add(someFeatures);
> frame.getMapPane.repaint();
>
>
> *4. ..and nothing happens. *
>
> There's two ways how i could make the new points visible, but none of them
> seems to be a good idea:
> 1. Remove the layer from the Pane and add ist again (map.addLayer(layer)).
> 2. Enable the layertable of JMapFrame and click the toggle visibility button
> two times.
>
>
> Can anyone please help me and show me the fault in my code/strategy? Is the
> a better (and faster?) way to display dynamic features in geotools?
>
> Best regards,
>
> Florian
>
>
>
> (1)
> http://osgeo-org.1560.x6.nabble.com/Adding-geometry-to-layer-td4324729.html
> <http://osgeo-org.1560.x6.nabble.com/Adding-geometry-to-layer-td4324729.html>
>
>
>
> --
> View this message in context: 
> http://osgeo-org.1560.x6.nabble.com/No-Repaint-of-MapPane-on-manipulating-the-layer-tp5132892.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

------------------------------------------------------------------------------
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to