Ich habe den Standardcode verwendet, um die Karte anzuzeigen, aber ich frage mich, warum es nicht funktioniert. Ich habe die Schritte auf Getting Started | Google Maps-API Ich habe einen API-Schlüssel für die App generiert und ihn ebenfalls eingeschränkt.MapsActivity lädt die Karte überhaupt nicht
Dies ist mein Code für MapsActivity.java
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
double LATITUDE, LONGITUDE;
String MARKER;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
Bundle lalo = getIntent().getExtras();
if (lalo != null){
LATITUDE = Double.valueOf(lalo.getString("LAT"));
LONGITUDE = Double.valueOf(lalo.getString("LON"));
MARKER = lalo.getString("MARKER");
}
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng location = new LatLng(LATITUDE, LONGITUDE);
mMap.addMarker(new MarkerOptions().position(location).title(MARKER));
mMap.moveCamera(CameraUpdateFactory.newLatLng(location));
}
}
Hier ist der Screenshot der MapActivity.
Bitte helfen Sie mir zu diesem Thema.
Was gibt Ihr Logcat zurück? –
Überprüfen Sie die Schritte mit dem API-Schlüssel, Sie erhalten einen leeren Bildschirm wie diesen, wenn es ein Problem damit gibt. Gibt es auch etwas in den Protokollen? –
haben Sie die Metadaten in einem offenkundigen deklarieren –