我在使用XML解析在android地图应用程序中添加多个标记时遇到问题
这是我的XML文件
<PA>
<node>
<id>1</id>
<nama>SMP 8 Cimahi</nama>
<longitude>-6.905424</longitude>
<latitude>107.527678</latitude>
<kategori>sekolah</kategori>
</node>
<node>
<id>2</id>
<nama>SMA 4 Cimahi</nama>
<longitude>-6.903954</longitude>
<latitude>107.521816</latitude>
<kategori>sekolah</kategori>
</node>
这是我在Java中的代码
public void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.petacimahi);
mapView = (MapView) findViewById(R.id.mapView);
mapView.setSatellite(false);
mapView.setBuiltInZoomControls(true);
mapView.displayZoomControls(true);
MapController mapController = mapView.getController();
mapController.setCenter(new GeoPoint(-6894581,107536519));
mapController.setZoom(15);
TextView id[];
TextView nama[];
TextView longitude[];
TextView latitude[];
TextView kategori[];
try {
DocumentBuilderFactory DBF;
DocumentBuilder DB;
Document dom;
Element elt;
DBF = DocumentBuilderFactory.newInstance();
DB = DBF.newDocumentBuilder();
dom = DB.parse(new InputSource(getAssets().open("database.xml")));
elt = dom.getDocumentElement();
NodeList nodeList = elt.getElementsByTagName("node");
/** Assign textview array lenght by arraylist size */
id = new TextView[nodeList.getLength()];
nama = new TextView[nodeList.getLength()];
longitude = new TextView[nodeList.getLength()];
latitude = new TextView[nodeList.getLength()];
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
}
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
如何在Android谷歌地图应用程序中解析位置(langitude,纬度)以添加多个标记?
答案 0 :(得分:0)
https://github.com/commonsguy/cw-advandroid/tree/master/Maps/ILuvNooYawk/在单个ItemizedOverlay上显示多个不同的PNG。您只需要覆盖一些绘图方法来处理不同的PNG。