What i do is to take data from an xml file and then using a Custom ItemizedOverlay i add the items.
public CustomItemizedOverlay callme(List<Places> result){
Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
latitudeE6 = result.get(i).latitude;
longitudeE6 = result.get(i).longitude;
GeoPoint point = new GeoPoint(latitudeE6a, longitudeE6a);
OverlayItem overlayitem = new OverlayItem(point, result.get(i).title, result.get(i).text);
CustomItemizedOverlay itemizedOverlay = new CustomItemizedOverlay(drawable);
itemizedOverlay.addOverlay(overlayitem);//add point
i++;
latitudeE6 =0;
longitudeE6 =0;
return itemizedOverlay;
}
While i am on the UI Thread i use a while() loop to print :
int j=0;
List<Overlay> mapOverlays = mapView.getOverlays();
while( j < 5 ) {
test1 = callme(result1);
mapOverlays.add(test1);
j++;
}
MapController mapController = mapView.getController();
mapController.setZoom(12);
Having to display only five items the loop stops while j < 5 .
The problem is that it only displays the last item from the xml data.
No comments:
Post a Comment