public class YOURACTIVITY extends AppCompatActivity implements OnMapReadyCallback
private GoogleMap mMap;
<--
OnCreate
SupportMapFragment map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map));
map.getMapAsync(this);
-->
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
double mLat = LATITUDE;
double mLon = LONTITUDE;
LatLng mylocation = new LatLng(mLat, mLon);
mMap.addMarker(new MarkerOptions().position(mylocation).snippet("TEXT BELLOW TITLE").title("TITLE")).showInfoWindow();
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mylocation,15));
}
UPDATE versuchen zu tun, so etwas wie dieses hinzuzufügen. Erstellen von benutzerdefinierten Layout und fügen Sie Informationen
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View view = MainActivity.getLayoutInflater().inflate(R.layout.map_custom, null);
TextView titleTextView = (TextView) view.findViewById(R.id.map_title);
TextView snippetTextView = (TextView) view.findViewById(R.id.map_snippet);
titleTextView.setText(marker.getTitle());
snippetTextView.setText(marker.getSnippet());
return view;
}
});
Ich habe die Antwort aktualisiert, versuche ein benutzerdefiniertes Layout zu erstellen, wenn es für dich funktioniert – MKovac
Entschuldigung, was ist getLayoutInflater? –
Es ist eine Methode von Android-Aktivität. Sie können jedoch mit LayoutInflater.from (Kontext) von außerhalb einer Aktivität einen Inflator haben, wenn Sie dies benötigen. – jeprubio