4

I have a map view with several pins plotted on different addresses. All works very well. The issue arises when you have more than one item pointing to the same address. For example,

Unit 1/ 45 ABC Street, XYZ
Unit 7/ 45 ABC Street, XYZ.

I use the following line of code to fetch the lat and long in order to create a GeoPoint.

List<Address> listfromGoogle = gc.getFromLocationName(a, 1);

where a is the address and gc is the GeoCoder object.

According the API , the two addresses mentioned above returns the same coordinates.

So while plotting the pins on the map, they overwrite each other ending up with one pin for multiple addresses.

I tried to implement a list that displays all the repeating addresses on the balloon. The attempt was in vain and I realised that

OverlayItem(GeoPoint point, java.lang.String title, java.lang.String snippet) 

allows me only to supply two strings to be shown on the balloon.

Any clue as to how I could squeeze in a List that displays the multiple addresses?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Neo
  • 1,181
  • 11
  • 22

1 Answers1

0

You should implement a custom OverlayItem

public class ListOverlayItem extends OverlayItem {
    private List<Address> list;

    public ListOverlayItem(GeoPoint point, List<Address> list) {
        super(point, "", "");
    }

    public List<Address> getList() {
        return list;
    }
}

then in your custom ItemizedOverlay you can use this list to create a custom dialog with a list in the onTap method

public class ListItemizedOverlay extends ItemizedOverlay<ListOverlayItem> {

    @Override
    protected boolean onTap(int index) {
        // get item they tapped from index
        // use getList() to populate the listview in the custom dialog
    }
}
skynet
  • 9,898
  • 5
  • 43
  • 52
  • Thanks Craigy! Probably just the start I needed ! Shall let you know how it went :) – Neo Nov 16 '11 at 03:37
  • hi i doing same , i am populate a list when click any overlayitem , give the code inside the onTab method.everything is working fine.but when i select list ,my list Listner not working everytime. – Rajesh Sharma Nov 23 '11 at 18:12
  • @RajeshSharma you should post a new question about that. Make sure you post any exceptions you see and the relevant code. – skynet Nov 23 '11 at 18:19