MapView mapView = new MapView(this, mapkey);
MapController mc=mapView.getController();
GeoPoint myLocation = null;
Drawable drawable = this.getResources().getDrawable(R.drawable.map_marker);
myItemizedOverlay itemizedoverlay = new myItemizedOverlay(drawable, this);
GeoPoint ppoint = new GeoPoint(platt,plngg); //platt and plngg xml parser value lattitude and Longitude
OverlayItem poverlayitem = new OverlayItem(ppoint,bankname,name of the place);
itemizedoverlay.addOverlay(poverlayitem);
mapOverlays.add(itemizedoverlay);
myLocation = new GeoPoint(platt,plngg);
mc.animateTo(myLocation);
mapView.setBuiltInZoomControls(true);
mapView.setClickable(true);
mc.setZoom(14);
mapView.invalidate();
return mapView;
MyItemizedOverlay類 - >用於在地圖上繪製銷釘
public class myItemizedOverlay extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
private Context mContext;
public myItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}
public myItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
}
public void addOverlay(OverlayItem overlay){
mOverlays.add(overlay);
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
public void removeItem(int i){
mOverlays.remove(i);
populate();
}
@Override
public int size() {
return mOverlays.size();
}
@Override
protected boolean onTap(int i) {
OverlayItem item = mOverlays.get(i);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
}
你在哪裏得到問題? –
實際上maninder,我正在尋找只有幾行提示代碼,因爲我已經使用XML解析器,但總是與列表視圖,但不是與谷歌地圖視圖,因此,我想知道如果我將使用MAPVIEW而不是ListView的是什麼將有所不同閱讀XML數據 – user1736992
http://www.ibm.com/developerworks/cn/opensource/library/x-android/ –