0

我正在尝试使用 Google Maps API v1(定位姜饼设备)编写一个简单的 MapView

刚刚尝试按照示例hello-mapview进行操作,除了图像没有显示在地图上之外,它都可以正常工作。

有一个覆盖层,因为触摸甚至可以工作并显示文本,但它却没有出现任何图像。

谁能发现我错过了什么?

MyMapView.java

public class MyMapView extends MapActivity {

private MapView mapView;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = getResources().getDrawable(R.drawable.androidmarker);
    NewOverlay itemizedoverlay = new NewOverlay(drawable, this);
    GeoPoint point = new GeoPoint(19240000,-99120000);
    OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

新覆盖.java

public class NewOverlay extends ItemizedOverlay<OverlayItem> {

private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
private Context mContext;

public NewOverlay(Drawable defaultMarker, Context context) {
    super(defaultMarker);
    mContext = context;
}

@Override
protected OverlayItem createItem(int i) {
    return mOverlays.get(i);
}

@Override
public int size() {
    return mOverlays.size();
}

public void addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();
}

public void removeOverlays(){
    mOverlays.clear();
    populate();
}

@Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}
}
4

0 回答 0