user2427497
user2427497

Reputation:

How to display text when tap on marker in google maps android

I want to display like this.

https://lh6.ggpht.com/DOvS0NiHGyGC9Vn7JvkwznRBZ7I65j3zwpNAqLkP5y083ju7JQbwWi4NAXQLp5Wsavmn=h900 When google map marker gets tap, text will display below. It can be drag up and down. I don't get how it has been done.

public class MapsActivity extends FragmentActivity
{
Googlemap gm;

gm = ((SupportMapFragment) (getSupportFragmentManager()
            .findFragmentById(R.id.map))).getMap();
gm.setMapType(GoogleMap.MAP_TYPE_NORMAL);
gm.setOnInfoWindowClickListener(this);
@Override
public void onInfoWindowClick(Marker marker) {
    String a=marker.getTitle();
   // how to display this title in same screen below with dragging up and down when map marker been tap

}
    }

Please help me to solve this issue.Thanks in advance.

Upvotes: 1

Views: 2209

Answers (3)

Muhammad Ali Hassan
Muhammad Ali Hassan

Reputation: 192

implement this method instead of infoWindowClick

gm.setOnMarkerClickListener(new OnMarkerClickListener() {

    @Override
    public boolean onMarkerClick(Marker arg0) {
    // TODO Auto-generated method stub
            String title = "Any Thing You want";
                marker.setTitle(title);
                textView.setText("title");
        return true;
    }
});

Upvotes: 1

Randula
Randula

Reputation: 1597

or.. If your marker is draggable, use the following snippet

        map.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {

        @Override
        public void onMarkerDragEnd(Marker marker) {
            marker.setSnippet("Your Text");
            map.animateCamera(CameraUpdateFactory.newLatLng(marker.getPosition()));

        }

    });

Upvotes: 0

Pratik Dasa
Pratik Dasa

Reputation: 7439

You have to create hidden layout for it. Create one layout as per your need and do it GONE by default. But when you click like below and inflate that layout in you onClick method:

    gm.setOnInfoWindowClickListener(this);
    @Override
    public void onInfoWindowClick(Marker marker) {
        String a=marker.getTitle();
        LayoutInflater inflater;
        inflater = LayoutInflater.from(context);
        View view;
        view = adapterInflater.inflate(R.layout.adapter_add_event, null);
       // how to display this title in same screen below with dragging up and down when map marker been tap

}

And visible this layout, do findViewById and make it visible.

Upvotes: 0

Related Questions