0

I have a map application in Android.

There is an alert dialogue when I click on marker, but I want to convert the alert dialogue to a simple infowindow like this:

http://3.bp.blogspot.com/-PrYuYQMcGcc/Ta__3fCcw7I/AAAAAAAAAGU/xCxjK3slU4k/s1600/google_map_marker_tooltip_popup_android.JPG

Here is the code I'm using to populate the Infowindow:

public class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem> {

    private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();

    private Context context;

    public CustomItemizedOverlay(Drawable defaultMarker) {
          super(boundCenterBottom(defaultMarker));
    }

    public CustomItemizedOverlay(Drawable defaultMarker, Context context) {
          this(defaultMarker);
          this.context = context;
    }

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

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

    @Override
    protected boolean onTap(int index) {
        OverlayItem item = mapOverlays.get(index);
        AlertDialog.Builder dialog = new AlertDialog.Builder(context);
        dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();
        return true;
    }

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

}
Kevin Bedell
  • 13,254
  • 10
  • 78
  • 114
user1505962
  • 61
  • 1
  • 8
  • Remove dialog.setTitle(item.getTitle()); and than try. – AkashG Jul 07 '12 at 05:15
  • Sir I don't want to use dialogue becuase when dialogue open map disables and i have to press escape to click another one and also dialogue position is not on exactly on marker as i provided picutre example in my question – user1505962 Jul 07 '12 at 05:26
  • Another way is to inflate a layout.When you click the balloon call a layout having only textview and it will be displayed according to the index. – AkashG Jul 07 '12 at 05:30
  • Sir According To My Code Will U Please Give Some Example with Code – user1505962 Jul 07 '12 at 05:34

1 Answers1

1

http://android-codes-examples.blogspot.in/2011/04/google-map-example-in-android-with-info.html where did you get that image from??? its actually from this link and it also contains how to do it....but not onTap.

If you want onTap, just remove that alert dialog box and all from the onTap method and add a toast which tell the location...thats the general practice.

Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
  • Yes Sir I have made a toast like this Toast.makeText(context, item.getSnippet(), Toast.LENGTH_SHORT).show(); but its position is not on current marker on which i have clicked it is in bottom of map not exactly on marker please give some suuggestion – user1505962 Jul 07 '12 at 05:51
  • yeah that was expected....toast comes at the bottom, not where you clicked (i don't know if we can do that)....but have you checked the code in that link i pasted?? i just saw the same image you pasted in the question there, but i didnt check the code. – Archie.bpgc Jul 07 '12 at 06:06
  • Sir Actualy above example dnt match with my project i have to made a lot of chaneges in my code that i dnt want so kindly tell some suggextion according to my above code – user1505962 Jul 07 '12 at 06:08
  • okay...if there is a possible way to change the position of the toast...will you be satisfied...or you want exactly whats there in the picture you pasted in the question – Archie.bpgc Jul 07 '12 at 06:12
  • if you want something like the one in the image you pasted ..check this...https://github.com/jgilfelt/android-mapviewballoons – Archie.bpgc Jul 07 '12 at 06:16
  • or if you want to change the position of the toast check this...http://stackoverflow.com/questions/2506876/how-to-change-position-of-toast-in-android....if you want to know more about toast check this...http://developer.android.com/guide/topics/ui/notifiers/toasts.html – Archie.bpgc Jul 07 '12 at 06:18