2

单击地图中的放置图钉时,我有一张图像要显示在叠加层中。可能,两幅或多幅图像属于同一经纬度。在这种情况下,我想显示所有属于该特定纬度和经度的图像..!我怎样才能做到这一点。?

这是我尝试过的..!

   for (int i = 0; i < AllData.neardeallist.size(); i++) {
        mapOverlays = mapview.getOverlays();

        drawable = this.getResources().getDrawable(R.drawable.pin);
        itemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(
                drawable, mapview);

        point = new GeoPoint((int) (Double.parseDouble(AllData.neardeallist
                .get(i).getLatitude()) * 1E6),
                (int) (Double.parseDouble(AllData.neardeallist
                        .get(i).getLongitude()) * 1E6));
        CustomOverlayItem overlayItem = new CustomOverlayItem(point,
                StringEscapeUtils.unescapeXml(StringEscapeUtils
                        .unescapeHtml4(AllData.neardeallist.get(i)
                                .getDealTitle())),

                StringEscapeUtils.unescapeXml(StringEscapeUtils
                        .unescapeHtml4(AllData.neardeallist.get(i)
                                .getDescription()))
                        + ":"
                        + AllData.neardeallist.get(i).getDealId()
                        + ":" + AllData.neardeallist.get(i).getDealKey(),
                AllData.neardeallist.get(i).getDealImg());

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

我的自定义覆盖类..!

公共类 CustomItemizedOverlay 扩展 BalloonItemizedOverlay {

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

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

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

protected CustomOverlayItem createItem(int i) {
    return m_overlays.get(i);
}

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

protected boolean onBalloonTap(int i, CustomOverlayItem item) {


        String[] Address = m_overlays.get(i).getSnippet().split(":");

        Intent intent = new Intent(c, DealDetails.class);
        intent.putExtra("deal_id", Address[1]);
        intent.putExtra("deal_key", Address[2]);
        c.startActivity(intent);


    return true;
}

@Override
protected BalloonOverlayView<CustomOverlayItem> createBalloonOverlayView() {
    // use our custom balloon view with our custom overlay item type:
    return new CustomBalloonOverlayView<CustomOverlayItem>(getMapView()
            .getContext(), getBalloonBottomOffset());
}

}

4

0 回答 0