Details
Description
I made a small modification from the example GeoTools map GUI:
instead of loading map data from shapefile during frame creation, I display the JMapPane empty, and allow the user to select a shapefile.
When the shapefile is added to the map (see below), the MapLayerTable does not display the newly added layer unless the addLayer method is called twice.
public void addShapefile(File shapefile) throws Exception {
FileDataStore store = FileDataStoreFinder.getDataStore(shapefile);
FeatureSource featureSource = store.getFeatureSource();
//CachingFeatureSource cache = new CachingFeatureSource(featureSource);
Style style = createStyle(shapefile, featureSource);
if (this.mapData == null)
this.mapData.addLayer(featureSource, style);
}