授权失败。
仅有放大和缩小选项,而没有地图
授权失败。
有关如何正确设置地图的信息,请参见https://developers.google.com/maps/documentation/android-api/start。
06-19 17:05:09.219 13337-13404 /? E / Google Maps Android API:在Google Developer Console(https://console.developers.google.com)中 确保已启用“ Google Maps Android API v2”。 确保存在以下Android密钥:
package com.android.msahakyan.expandablenavigationdrawer.fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.msahakyan.expandablenavigationdrawer.R;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class FragmentThriller extends Fragment implements OnMapReadyCallback {
private MapView mapView;
private GoogleMap mgoogleMap;
private static final String KEY_MOVIE_TITLE = "key_title";
public static FragmentThriller newInstance(String movieTitle) {
FragmentThriller fragmentThriller = new FragmentThriller();
Bundle args = new Bundle();
args.putString(KEY_MOVIE_TITLE, movieTitle);
fragmentThriller.setArguments(args);
return fragmentThriller;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate( R.layout.fragment_thriller, container, false);
// // Gets the MapView from the XML layout and creates it
// mapView = (MapView) v.findViewById(R.id.mapView);
// mapView.onCreate(savedInstanceState);
//
// // Gets to GoogleMap from the MapView and does initialization stuff
// mapView = mapView.getMapAsync();
// map.getUiSettings().setMyLocationButtonEnabled(false);
// map.setMyLocationEnabled(true);
//
// // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
// try {
// MapsInitializer.initialize(this.getActivity());
// } catch (GooglePlayServicesNotAvailableException e) {
// e.printStackTrace();
// }
//
// // Updates the location and zoom of the MapView
// CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(43.1, -87.9), 10);
// map.animateCamera(cameraUpdate);
return v;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated( view, savedInstanceState );
mapView = (MapView) view.findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
mapView.onResume();
mapView.getMapAsync(this);
}
@Override
public void onResume() {
mapView.onResume();
super.onResume();
}
@Override
public void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
@Override
public void onMapReady(GoogleMap googleMap) {
mgoogleMap = googleMap;
mgoogleMap.getUiSettings().setZoomControlsEnabled(true);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom( new LatLng(28.6403159,77.376114) ,17);
mgoogleMap.animateCamera( cameraUpdate );
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.msahakyan.expandablenavigationdrawer"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="in.goodiebag.carouselpicker"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/responsive"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="keyyyyyy"/>
<activity android:name=".MainActivity" >
</activity>
<activity android:name=".Splash"
android:label="WebTechniQ">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".fragment.digital_marketing"
android:label="Digital Marketing">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".fragment.website_designing"
android:label="Website Design and Development">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".fragment.DomainRegistration"
android:label="Domain Registration">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Registration"
android:label="Query Form">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<permission
android:name="com.android.msahakyan.expandablenavigationdrawer.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.android.msahakyan.expandablenavigationdrawer.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.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" />
</manifest>