I'm building an android application in which I want to show data from a KML file on a Mapfragment.
I'm using the example code from Google's documentation on the KmlLayer class. But sadly the documentation on the class is abysmal.
I'm using the following method to add the layer to the map:
private void loadKml(File file) {
try {
InputStream is = new BufferedInputStream(new FileInputStream(file));
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
Log.i("Status", "Setting KML layer.");
KmlLayer layer = new KmlLayer(map, is, context);
layer.addLayerToMap();
is.close();
} catch (IOException ex) {
ex.printStackTrace();
// TODO: handle error
} catch (XmlPullParserException e) {
// TODO: handle error
e.printStackTrace();
}
}
The KML file is not complicated. It has 20 connected points at the most.
No exceptions are thrown. Also no error messages are shown in logcat. And the layer is not shown on the map, what am I doing wrong here?