user3575965
user3575965

Reputation: 29

How do I show place details?

So I have a class called 'InterestingPoint' with variables 'Name', 'Coordinates'. I've created a list with interesting places and then I've added markers on the map like that:

for (InterestingPoint point:route.points_of_interest){
        mMap.addMarker(new MarkerOptions().position(point.Coordinates).title(point.Name));
    }

So the main question is can I get details of any marker when I click on it? When I click on marker I want to show description and picture of that place.

Upvotes: 0

Views: 53

Answers (1)

Sky
Sky

Reputation: 1433

First, you need to set OnMarkerClickListener in onCreate method.

map.setOnMarkerClickListener(this);

Then you override the onMarkerClick method to get the title and position of the Marker.

@Override
public boolean onMarkerClick(Marker marker) {
    String title = marker.getTitle();
    LatLng position = marker.getPosition();

    return true;
}

Upvotes: 2

Related Questions