0

通过类 Overlay 并从该类调用 onTap 方法,我可以在我的地图上显示可绘制对象。我想要做的只是在用户点击地图(第一次点击)时显示一个drawable,而不是通过点击在不同的地方一次又一次地显示drawable。这可能吗?

4

1 回答 1

0
override you onTap() method of Overlay

    @Override
    protected boolean onTap(int index) {
         Drawable srcdrawable = getApplicationContext().getResources().getDrawable(R.drawable.pin_blue);
    CustomItemizedOverlay srcitemizedOverlay = new CustomItemizedOverlay(srcdrawable, getApplicationContext());
    forloop(setoflocations){
    GeoPoint srcpoint = new GeoPoint((int)( Double.parseDouble(lat) * 1E6),(int)( //latitude and longitude of user tapped location...
Double.parseDouble(lng)* 1E6));
    OverlayItem srcoverlayitem = new OverlayItem(srcpoint, "Hello!", "This is your Location.");
    if(srcitemizedOverlay!=null && mapController!=null){
    srcitemizedOverlay.addOverlay(overlayitem);
    mapController.animateTo(point);
    animatePoint = point;
    }
    }
    mapView.getOverlays().clear();
    mapView.getOverlays().add(srcitemizedOverlay);

   // pop up a alert dialog here and ask user for confirmation

    }
于 2013-01-23T10:22:35.327 回答