Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Version 2 Map view does not show map

Tags:

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

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.demomap"     android:versionCode="1"     android:versionName="1.0" >     <uses-sdk         android:minSdkVersion="8"         android:targetSdkVersion="17" />    <permission         android:name="com.example.demomap.permission.MAPS_RECEIVE"         android:protectionLevel="signature" />     <uses-permission android:name="com.example.demomap.permission.MAPS_RECEIVE" />     <uses-permission android:name="android.permission.INTERNET" />     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />     <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />         <application         android:allowBackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/AppTheme" >         <activity             android:name="com.example.demomap.MainActivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.MAIN" />                  <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>         </activity>          <meta-data             android:name="com.google.android.maps.v2.API_KEY"             android:value="AIzaSyCTQZOcXFS3RpNSVe79HHN1xojat-2MbT4" />     </application>     <uses-feature         android:glEsVersion="0x00020000"         android:required="true" /> </manifest> 

My XmL File Like these:

<?xml version="1.0" encoding="utf-8"?> <fragment     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/map"     android:layout_width="match_parent"     android:layout_height="match_parent"     class="com.google.android.gms.maps.SupportMapFragment" /> 

Log Cat Error:

05-15 17:15:16.255: E/Google Maps Android API(26201): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors). 

Please Help me.

like image 968
Suraj Avatar asked May 15 '13 12:05

Suraj


People also ask

Why won't My Maps show the map?

You may need to update your Google Maps app, connect to a stronger Wi-Fi signal, recalibrate the app, or check your location services. You can also reinstall the Google Maps app if it isn't working, or simply restart your iPhone or Android phone.

Why is Google Maps only showing directions and not map?

Disconnect the phone from your car If this problem occurs when you're using an app to connect your phone to your car's media screen, Google Maps will only display text directions. For example, if you're plugged into your vehicle with Apple CarPlay, you should be able to see the map directly on your vehicle's screen.


2 Answers

Maybe the key isn't correct. You can try the following thing:

  • Be sure you Enter your right Package name like this
  • Test on a real device which updated latest google play. Or use emulator with this guide
  • Active google map api v2 for android at google console site enter image description here

like image 136
Tai Dao Avatar answered Oct 29 '22 18:10

Tai Dao


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.

like image 37
Ng Zhong Qin Avatar answered Oct 29 '22 18:10

Ng Zhong Qin