Create an
IlvMapInputStream and use it to read the map file. This takes care
of reconnecting read data with the corresponding read map model (data
sources, map layers and so on).
String mapFilename = "myMap.ivl";
IlvMapInputStream mapInputStream = new IlvMapInputStream (mapFilename);
try {
mapInputStream.read(manager);
} catch (Exception ex) {
// handle reading exceptions here
}
Note that when using the above IlvMapInputStream
constructor,
the .img
file that goes with the .ivl
file
(passed to IlvMapInputStream
) must be in
the same directory as the .ivl
file or
the stream will not be able to find it, leading to missing images
on the map.
If you choose to specify a different name for the
.img
file
when saving the map (see
Saving and reloading a map),
you must also specify the filename to the
IlvMapInputStream
using
the appropriate constructor as follows:
String ivlFilename = "myMap.ivl";
String imgFilename = "myImgFilename.img";
//Create the input stream for the .ivl file.
FileInputStream fis = new FileInputStream(ivlFilename);
//Create the IlvMapInputstream and specify the image file name.
IlvMapInputStream mapInputStream = new IlvMapInputStream(fis, imgFilename);
//Read the map as described previously.
try {
mapInputStream.read(manager);
} catch (Exception ex) {
// Handle reading exceptions here.
}