点击地图中的放置针时,我在叠加层中显示了一个图像。可能地,两个或更多个图像属于相同的纬度和经度。在这种情况下,我想显示属于那个特定纬度和经度的所有图像..!我怎样才能做到这一点。?
这就是我试过的......!
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());
}
}