0

Ich möchte die Map innerhalb des Fragments erhalten, das ich von einem MapFragment in die MapView migriert habe.Google MapView V3 lädt keine Kacheln

Im Mapfragment-Modus funktioniert die Map gut in einer einfachen Aktivität. Aber wenn ich ein Mapview in ein Fragment in einem Viewpager stecke. Die Kartenansicht ist immer noch grau.

Ich weiß nicht warum.

Mein MapViewFragment Code:

public class MapViewFragment extends RecordFragment implements GoogleMap.OnMarkerClickListener,OnMapReadyCallback { 
    private GoogleMap mMap; 
    private MapView mapView; 


    public MapViewFragment() { 
     // Required empty public constructor 
    } 

    public static MapViewFragment newInstance() { 
     MapViewFragment fragment = new MapViewFragment(); 
     // Supply index input as an argument. 
     Bundle args = new Bundle(); 

     fragment.setArguments(args); 
     return fragment; 
    } 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     if (getArguments() != null) { 
     } 


    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     View view = inflater.inflate(R.layout.fragment_map, container, false); 
     // Gets the MapView from the XML layout and creates it 
     mapView = (MapView) view.findViewById(R.id.mapView); 
     mapView.onCreate(savedInstanceState); 

     // Gets to GoogleMap from the MapView and does initialization stuff 
     mapView.getMapAsync(this); 

     return view; 

    } 

    @Override 
    public void onMapReady(GoogleMap googleMap) { 
     mMap = googleMap; 
     mMap.setOnMarkerClickListener(this); 
     UiSettings settings = mMap.getUiSettings(); 
     settings.setCompassEnabled(true); 
     try{ 
      if (PermissionsHelper.checkPermissionLocation(getActivity())) { 
       mMap.setMyLocationEnabled(true); 
      } 
     }catch (SecurityException e){ 
      e.printStackTrace(); 
     } 

     MapsInitializer.initialize(this.getActivity()); 


    } 

    @Override 
    public boolean onMarkerClick(Marker marker) { 
     return false; 
    } 
} 

fragment_map.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <com.google.android.gms.maps.MapView 
     android:id="@+id/mapView" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 

</LinearLayout> 

Mein manifest.xml:

<permission 
     android:name="com.kwik.googlemapsv2.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 

    <uses-permission android:name="com.kwik.googlemapsv2.permission.MAPS_RECEIVE"/> 

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

    <!-- Required OpenGL ES 2.0. for Maps V2 --> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 

    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true" /> 
    <meta-data 
      android:name="com.google.android.geo.API_KEY" 
      android:value="AI..." /> 

Ergebnis: enter image description here

LogCat:

12-01 20:33:26.981 11205-11205/com.kwik D/RelationGraph: garbageCollect() 
12-01 20:33:27.091 11205-11205/com.kwik D/RelationGraph: garbageCollect() 
12-01 20:33:27.171 11205-11205/com.kwik W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000008/n/armeabi-v7a 
12-01 20:33:27.171 11205-11205/com.kwik W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000008/n/armeabi 
12-01 20:33:27.181 11205-11205/com.kwik D/ResourcesManager: For user 0 new overlays fetched Null 
12-01 20:33:27.221 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.241 11205-11205/com.kwik I/Google Maps Android API: Google Play services client version: 9452000 
12-01 20:33:27.261 11205-11205/com.kwik I/Google Maps Android API: Google Play services package version: 10084438 
12-01 20:33:27.271 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.291 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.301 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.321 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.341 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.351 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.361 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.381 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.381 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation 
12-01 20:33:27.401 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.451 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.451 11205-11205/com.kwik I/c: Token loaded from file. Expires in: 428631454 ms. 
12-01 20:33:27.451 11205-11205/com.kwik I/c: Scheduling next attempt in 428331 seconds. 
12-01 20:33:27.491 11205-11205/com.kwik D/AbsListView: Get MotionRecognitionManager 
12-01 20:33:27.501 11205-11205/com.kwik E/MotionRecognitionManager: mSContextService = [email protected] 
12-01 20:33:27.501 11205-11205/com.kwik E/MotionRecognitionManager: motionService = [email protected]2bb13fe 
12-01 20:33:27.501 11205-11205/com.kwik E/MotionRecognitionManager: motionService = [email protected]2bb13fe 
12-01 20:33:27.541 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation 
12-01 20:33:27.541 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation 
12-01 20:33:27.551 11205-11205/com.kwik W/System.err: mkdir failed: EEXIST (File exists) : /storage/emulated/0/Android/data/com.kwik/cache/debug 
12-01 20:33:27.551 11205-11205/com.kwik W/System.err: mkdir failed: EEXIST (File exists) : /storage/emulated/0/Android/data/com.kwik/cache 
12-01 20:33:27.571 11205-11277/com.kwik I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 
12-01 20:33:27.571 11205-11277/com.kwik I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 
12-01 20:33:27.641 11205-11315/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.641 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:27.641 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation 
12-01 20:33:27.711 11205-11268/com.kwik D/libEGL: loaded /vendor/lib/egl/libGLES_mali.so 
12-01 20:33:27.731 11205-11268/com.kwik D/libEGL: eglInitialize EGLDisplay = 0xdfb5a7c4 
12-01 20:33:27.731 11205-11268/com.kwik I/OpenGLRenderer: Initialized EGL, version 1.4 
12-01 20:33:27.741 11205-11268/com.kwik D/mali_winsys: new_window_surface returns 0x3000, [1080x1920]-format:1 
12-01 20:33:27.771 11205-11277/com.kwik I/qtaguid: Tagging socket 57 with tag 3000110100000000{805310721,0} uid -1, pid: 11205, getuid(): 10237 
12-01 20:33:27.831 11205-11205/com.kwik I/Choreographer: Skipped 57 frames! The application may be doing too much work on its main thread. 
12-01 20:33:27.841 11205-11314/com.kwik D/libEGL: eglInitialize EGLDisplay = 0xd637f514 
12-01 20:33:27.841 11205-11314/com.kwik D/mali_winsys: new_window_surface returns 0x3000, [1080x1185]-format:2 
12-01 20:33:27.851 11205-11268/com.kwik D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.kwik 
12-01 20:33:28.021 11205-11277/com.kwik I/qtaguid: Tagging socket 74 with tag 3000110100000000{805310721,0} uid -1, pid: 11205, getuid(): 10237 
12-01 20:33:28.061 11205-11205/com.kwik D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1 
12-01 20:33:28.141 11205-11268/com.kwik D/libEGL: eglInitialize EGLDisplay = 0xdfb5a614 
12-01 20:33:28.141 11205-11205/com.kwik I/Timeline: Timeline: Activity_idle id: [email protected] time:664641245 
12-01 20:33:28.171 11205-11277/com.kwik I/qtaguid: Untagging socket 57 
12-01 20:33:28.181 11205-11345/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:28.181 11205-11278/com.kwik I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 
12-01 20:33:28.181 11205-11278/com.kwik I/System.out: (HTTPLog)-Static: isSBSettingEnabled false 
12-01 20:33:28.181 11205-11278/com.kwik I/qtaguid: Tagging socket 57 with tag 3000110100000000{805310721,0} uid -1, pid: 11205, getuid(): 10237 
12-01 20:33:28.261 11205-11278/com.kwik I/qtaguid: Untagging socket 57 
12-01 20:33:28.261 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 
12-01 20:33:28.261 11205-11205/com.kwik W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation 
12-01 20:33:29.651 11205-11316/com.kwik W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found. 
12-01 20:33:29.671 11205-11316/com.kwik I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:2 
12-01 20:33:29.671 11205-11316/com.kwik I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2 
12-01 20:33:29.671 11205-11316/com.kwik E/DynamiteModule: Failed to load DynamiteLoader: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader" on path: DexPathList[[zip file "/data/app/com.kwik-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kwik-1/lib/arm, /vendor/lib, /system/lib]] 
12-01 20:33:29.671 11205-11316/com.kwik W/DynamiteModule: Failed to load remote module: Failed to get module context 
12-01 20:33:29.671 11205-11316/com.kwik W/DynamiteModule: Failed to load module via fast routetn: Remote load failed. No local fallback found. 
12-01 20:33:29.681 11205-11316/com.kwik W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found. 
12-01 20:33:29.681 11205-11316/com.kwik D/RelationGraph: garbageCollect() 
12-01 20:33:29.681 11205-11316/com.kwik D/RelationGraph: garbageCollect() 
12-01 20:33:29.681 11205-11316/com.kwik I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:2 
12-01 20:33:29.681 11205-11316/com.kwik I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2 
12-01 20:33:29.691 11205-11316/com.kwik D/RelationGraph: garbageCollect() 
12-01 20:33:29.701 11205-11316/com.kwik W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000007/n/armeabi 
12-01 20:33:29.721 11205-11316/com.kwik D/ResourcesManager: For user 0 new overlays fetched Null 
+0

Könnten Sie Ihre logcat Ausgang setzen? –

+0

Ja, aber ich habe nichts über ein Problem mit gmap gesehen ... – WhatsUp

Antwort

1

ich von mir selbst gefunden, war die Karte sehr, sehr langsam, ich brauche dieses Problem zu beheben alle Methoden für den Kartenansicht Lebenszyklus zu erklären!

Google doc hier: Google Maps V3

Wenn in vollständig interaktive Modus mithilfe der API, den Benutzern der MapView Klasse muss die folgenden Aktivitätszyklus Methoden, um die entsprechenden Methoden in der MapView-Klasse weiter: onCreate() , onStart(), onResume(), onPause(), OnStop(), onDestroy(), onSaveInstanceState(), und onLowMemory(). Das ApiDemos-Repository auf GitHub enthält ein Beispiel , das zeigt, wie die Aktivitätslebenszyklusmethoden weitergeleitet werden. Wenn die API im Lite-Modus verwendet wird, ist das Weiterleiten von Lebenszyklusereignissen optional. Weitere Informationen finden Sie in der Dokumentation zum Lite-Modus.

Ich habe juste fügen Sie diese auf dem MapViewFragment: hier

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

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

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

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