Android Google Maps Abnormalities

Asked 2 years ago, Updated 2 years ago, 107 views

Hello. I'm asking for your help because I couldn't solve the problem while studying Android.

Currently, I'm going to make Google Maps into fragments and float them. The float is successful, but

Only the Google Maps logo and markers are displayed, but the map does not appear at first.

Then, when you touch it, Google Maps starts to come out late one by one, and even if you zoom, drad, etc., the response is very late.

May I know why?

googlemap android

2022-09-22 19:03

2 Answers

In the case of MapView, it is stated that the life cycle of Activity must be notified and used unless it is in lite mode. I understand that the map rendering thread is executed/disrupted in the onResume(), onPause() phases, which seems to be for rendering processing according to the life cycle, memory management, etc. due to the nature of the map consisting of complex rendering elements.

When using the API in fully interactive mode, users of the MapView class must forward all the activity life cycle methods to the corresponding methods in the MapView class. Examples of the life cycle methods include onCreate(), onDestroy(), onResume(), and onPause().

https://developers.google.com/maps/documentation/android-sdk/lite


2022-09-22 19:03

It's self-answer! Usually, the way to float Google Maps in Fragment is through Google,

public class Google_map_fragment extensions Fragment implementations OnMapReadyCallback {

    private GoogleMap mMap;
    private MapView mapView = null;
    View layout;

    @Override
    public View onCreateView( LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
        Log.d ("Log: "Google_map_fragmentation on CreateView"));

        layout = inflater.inflate(R.layout.google_map_fragment,container,false);
        mapView = (MapView)layout.findViewById(R.id.map);
        mapView.getMapAsync(this);
        mapView.onCreate(savedInstanceState);
        return layout;
    }

You can see the code like this code.

However, if you just do this and run it, Google Maps does not run naturally, but you have to keep touching the screen to get the map, and zooming out and stuff doesn't work well.

 @Override
    public void onResume() {
        mapView.onResume();
        super.onResume();
    }
    @Override
    public void onDestroy() {
        mapView.onDestroy();
        super.onDestroy();
    }

OnResume, onDestroy map view in this case.~~ If you add that, You can use Google Maps that work naturally.

I don't know why. If you know the reason, please leave a comment!


2022-09-22 19:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.