我有Kml文件有一些lat lngs但我不知道如何在android中解析它?
我查了这个链接 How to draw a path on a map using kml file?
但它有所不同。它以kml格式从服务器获取数据。但是我将kml文件存储在资产中。
提前致谢..
答案 0 :(得分:0)
阅读KML:
public String loadKMLFromAsset() {
String kmlData = null;
try {
InputStream is = getAssets().open("yourKMLFile");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
kmlData = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return kmlData;
}