In Version 2 Map view does not show map

后端 未结 18 1711
星月不相逢
星月不相逢 2020-12-14 18:07

Map Activity doesn\'t showing map, it\'s appear as just white screen with zoom control buttons. Manifest File like this :



        
相关标签:
18条回答
  • 2020-12-14 18:42

    My suggestion is you can use MapFragment. As far as i know almost all devices are upgraded to 11 and above. MapFragment supports 11 and above. Log into google api console again and check whether your application key is present there or not. I know that you have done it already. But check it again. Because am having an issue where the api key is not getting saved. I have to create a new project everytime. Maybe you are facing the same issue too.

    0 讨论(0)
  • 2020-12-14 18:43

    I had the same problem, so I went ahead and created a new key at the API console. Also, make sure you follow instructions for recording your release key on the API console: Displaying the release certificate fingerprint

    It works for me now...

    0 讨论(0)
  • 2020-12-14 18:44

    I got this problem using MapView

    fragment_map.xml

    <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"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
    

        @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        String message = getArguments().getString(EXTRA_MESSAGE);
        v = inflater.inflate(R.layout.map_f, container, false);
        vh = new ViewHolder();
        assetHandler = new AssetHandler(getActivity());
        vh.mapView=assetHandler.mapViewHandler.set(v,R.id.mapview);
        vh.mapView.onCreate(savedInstanceState);
    
        vh.mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap googleMap) {
                googleMap.getUiSettings().setMyLocationButtonEnabled(true);
                googleMap.setMyLocationEnabled(true);
                // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
                try {
                    MapsInitializer.initialize(getActivity());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        return v;
    }
    
    
    @Override
    public void onResume() {
        super.onResume();
        vh.mapView.onResume();
    
    
    }
    
    @Override
    public void onPause() {
        vh.mapView.onPause();
        super.onPause();
    }
    
    @Override
    public void onDestroy() {
        vh.mapView.onDestroy();
        super.onDestroy();
    }
    
    @Override
    public void onLowMemory() {
        super.onLowMemory();
        vh.mapView.onLowMemory();
    }
    

    I noticed if the LifeCycle methods are not implemented, you will not be able to see the map as well. hope this is hopeful for some.

    0 讨论(0)
  • 2020-12-14 18:44

    I just spent a couple of hours on this same error. I initially did not have the debug keystore API key set up properly and my android device cached the incorrect API key that was hard-coded into my manifest. Eventually I simply deleted the app from the device, cleaned the project, and this cleared whatever residual API key was stored locally on the device. I ran the app again and everything worked like a charm!

    Good Luck.

    0 讨论(0)
  • 2020-12-14 18:48

    As been mentioned here this problem usually derives from the fact that you are not referencing the google-play-service library correctly. Please take a look at the first 3 steps of the following guide I wrote no integrating Google Maps in your application and make sure you are doing all the steps correctly:

    Google Maps API V2

    0 讨论(0)
  • 2020-12-14 18:48

    Did you activate Google Map Service in API console?

    0 讨论(0)
提交回复
热议问题