0

我对 Java 还比较陌生,并且正在尝试使用地址处的代码。http://proyectouvipool.googlecode.com/svn-history/r87/trunk/Android/PFC/src/pablo/developer/BalloonItemizedOverlay.java

不幸的是,我收到以下错误消息

Bound mismatch:类型 Item 不是 BalloonOverlayView 类型的有界参数的有效替代品

在代码

protected BalloonOverlayView<Item> createBalloonOverlayView() {
      return new BalloonOverlayView<Item>(getMapView().getContext(), getBalloonBottomOffset());
     }

希望对如何解决此问题提供一些帮助?

4

1 回答 1

0
public class CustomBalloonItemizedOverlay extends
            BalloonItemizedOverlay<OverlayItem> {

        private ArrayList<OverlayItem> m_overlays = new ArrayList<OverlayItem>();
        private Context c;

        public MyFavoritePlacesItemizedOverlay(Drawable defaultMarker,
                MapView mapView) {
            super(boundCenter(defaultMarker), mapView);
            c = mapView.getContext();
        }

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

        @Override
        public void draw(Canvas canvas, MapView mapView, boolean shadow) {
            if (!shadow) {
                super.draw(canvas, mapView, false);
            }
        }

        public void removeOverlay(OverlayItem overlay) {
            m_overlays.remove(overlay);
            populate();
        }

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

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

        @Override
        protected boolean onBalloonTap(int index, OverlayItem item) {
            // Your code... 
            return true;
        }
    }

下面是如何使用它...

initGeoPoint = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));

            mapOverlays = myMapView.getOverlays();
drawableImage = this.getResources().getDrawable(R.drawable.any_icon);

CustomBalloonItemizedOverlay customItemizedOverlayObject = new public class CustomBalloonItemizedOverlay(
                    drawableImage, myMapView);
            OverlayItem overlayItem = new OverlayItem(initGeoPoint, name,
                    address);

            customItemizedOverlayObject.addOverlay(overlayItem);
            mapOverlays.add(customItemizedOverlayObject);

        }
于 2012-09-17T17:58:23.333 回答