3

Google マップに問題があります。初めてアプリケーションを実行すると、マップは正常に表示されますが、閉じて再度実行すると、マップの画面が黒くなります。何が起こるかわかりませんが、アプリケーションのすべてのデータを消去すると、マップが再び表示されます。

初めて:

ここに画像の説明を入力

2回目(アプリケーションを閉じて再度実行したとき)

ここに画像の説明を入力

私はandroidx86プロジェクトで仮想ボックスを使用しています

手伝って頂けますか?

マップを設定した私のコード:

private void setUpMapIfNeeded() {
        if (map == null) {
            map = ((SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        }
            if (map != null) {
                try{
                    map.setMyLocationEnabled(true);
                    map.setOnMyLocationButtonClickListener(this);
                    map.setOnMapLongClickListener(this);
                    map.setOnMarkerClickListener(this);
                    map.setOnMapClickListener(this);
                    map.setOnCameraChangeListener(this);
                    LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
                    Criteria criteria = new Criteria();
                    String provider = locationManager.getBestProvider(criteria, true);
                    Location location = locationManager.getLastKnownLocation(provider);
                    if(location!=null){
                        double latitude = location.getLatitude();
                        double longitude = location.getLongitude();
                        LatLng latLng = new LatLng(latitude, longitude);
                        //ThreadMostraImoveisJson(latLng);
                        onLocationChanged(location);
                    }           
                }
                catch (Exception ex){
                    Log.e("Erro Mapa", "Erro Setar Mapa: "+ex.getMessage());
                }
            }
    }

私のXML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapHost"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
<fragment
      android:id="@+id/map"
       android:name="com.google.android.gms.maps.SupportMapFragment"
       android:layout_width="match_parent"
       android:layout_height="match_parent" >
</fragment>
   <LinearLayout 
    android:id="@+id/layPesquisa"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#f4f4f4"
    android:orientation="horizontal"
    android:layout_gravity="right">

    <Button
        android:id="@+id/btnPesquisa"
       android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OK" />

    <EditText
        android:id="@+id/edtPesquisa"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="invisible"
         android:text="" 
     />

</LinearLayout>
</FrameLayout>
4

3 に答える 3

3

それは新鮮な新しいバグです。

Google の問題トラッカーを参照してください:

https://code.google.com/p/gmaps-api-issues/issues/detail?id=4659

https://code.google.com/p/gmaps-api-issues/issues/detail?id=5767

于 2013-08-30T16:17:05.197 に答える
1

MapFragment が黒く表示されるという問題がありました。私が使用していたAndroidManifestで:

<supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="false" />

ここで anyDensity を false に設定すると、黒く表示されます。私はそれをtrueに戻しましたが、うまくいきました

于 2015-11-02T01:48:28.547 に答える