0

I'd like to create textbubbles that show the distance from that marker to the devices location, plus the name given to the marker. These are markers I set in advance:

mMap.addMarker(new MarkerOptions().position(new LatLng(51.1691158, 4.4662486)).icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_marker)));

This is an image of the design I had in mind: On the bottom of the activity, you should see textbubbles that you can scroll and click on

Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
Simon Kuhn
  • 13
  • 5

1 Answers1

1

To display textbubbles, you can use InfoWindow from the same Google Maps API.

static final LatLng MELBOURNE = new LatLng(-37.81319, 144.96298);
Marker melbourne = mMap.addMarker(new MarkerOptions()
                      .position(MELBOURNE)
                      .title("Melbourne"));
melbourne.showInfoWindow();

and to get the difference between two locations, you can use:

Location loc1 = new Location("");
loc1.setLatitude(lat1);
loc1.setLongitude(lon1);

Location loc2 = new Location("");
loc2.setLatitude(lat2);
loc2.setLongitude(lon2);

float distanceInMeters = loc1.distanceTo(loc2);

The code example reference is here.

Reference: . https://developer.android.com/reference/android/location/Location#distanceTo(android.location.Location) . https://developers.google.com/maps/documentation/android-sdk/infowindows