skip to main content
Defense > Programmer's documentation > Programming with JViews Maps > Creating a map application using the API > Clearing map data
 
Clearing map data
When creating data sources and map layers, many different manager properties are modified and refer to the data structures needed to manage the map at its different scales. Furthermore, many graphic objects and manager layers are created in the IlvManager object. You may later want to clear the data.
The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir> /jviews-maps/samples/mapbuilder/index.html
To clear the map data entirely:
1. Stop all potential threaded image loaders by looking for IlvThreadedTileLoader which may still be running:
 
for (int il=0;il<manager.getLayersCount();il++) {
  IlvManagerLayer layer = manager.getManagerLayer(il);
  if (layer instanceof IlvTiledLayer) {
    IlvTileLoader loader = ((IlvTiledLayer) layer).getTileLoader();
    if (loader instanceof IlvThreadedTileLoader) {
      ((IlvThreadedTileLoader) loader).dispose();
    }
  }
}
2. Clear the map layer model by removing all manager layers and graphic objects:
 
IlvMapLayerTreeModel model =
IlvMapLayerTreeProperty.GetMapLayerTreeModel(manager);
model.clearAllObjects();
while (manager.getLayersCount() > 0) {
 manager.removeLayer(0, false);
}
manager.removeNamedProperty(IlvMapLayerTreeProperty.NAME);
3. Clear the data source model:
 
manager.removeNamedProperty(IlvMapDataSourceProperty.NAME);
4. Clear the area of interest model:
 
manager.removeNamedProperty(IlvAreasOfInterestProperty.NAME);
5. Clear the style controller:
 
manager.removeNamedProperty(IlvMapStyleControllerProperty.NAME);
6. Remove all temporary raster files. JViews Maps relies on a memory mapped data file for quick access to raster pixel data. Temporary files are not removed when applications exit abnormally, and they remain in the temporary directory forever unless removed. To prevent this, the IlvRasterTemporaryFileManager class provides a method to remove all temporary files created by JViews Maps that are no longer in use:
 
IlvRasterTemporaryFileManager.removeAllFiles();

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.