When starting a new map activity the map loads really slow and doesn't start the loading until clicking the screen.
The Layout is the following:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.android.momintuition.DirectionsActivity">
<com.google.android.gms.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
android:paddingTop="62px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
map:uiCompass="true"
map:zOrderOnTop="true"
map:uiZoomControls="true"
android:background="#00000000" />
</RelativeLayout>
The new activity looks like this:
public class DirectionsActivity extends AppCompatActivity implements OnMapReadyCallback {
GoogleMap mMap; // Might be null if Google Play services APK is not available.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_directions);
MapView mv = (MapView) findViewById(R.id.mapView);
mv.onCreate(savedInstanceState);
mMap = mv.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
this.map = googleMap;
CameraUpdate cameraUpdate =
CameraUpdateFactory.newLatLngZoom(new LatLng(43.1, -87.9), 10);
map.animateCamera(cameraUpdate);
}
}
I am new to Android. Am I missing something? Thank you!
Clear app data Google Maps stores data like shared locations, saved locations, and map tiles on your phone or tablet. Clearing this data will do the following things: Delete cache (including search suggestions, direction searches, map tiles, and activity page content stored on your device) Delete cookies.
Clear the app's cache & data On your Android phone or tablet, open the Settings app . Tap Apps & notifications. Follow the steps on your device to find the Maps app. After you select the app, storage & cache options should be available.
More and more Android users ended up struggling with all kinds of problems in Google Maps, including broken navigation, GPS connection issues, audible guidance not working, and freezes occurring all of a sudden when the app is minimized.
The problem in this case was that I didn't implement the following methods(even if it was specified in the documentation):
@Override
public void onResume() {
mapView.onResume();
super.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
It is counterintuitive to me why this methods might affect showing the map but it does fix the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With