[英]MapView shows blank map inside a fragment (Android MAP API V2)
I'm currently developing an application that integrate with google map. 我目前正在开发与Google Map集成的应用程序。 However it didn't run as I expect to be. 但是它没有按我预期的那样运行。 It shows nothing, just a blank gray screen. 它什么也没显示,只有空白的灰色屏幕。
I've checked my adb and grep Auth
there doesn't seems any mistake in authorization. 我已经检查了我的adb和grep Auth
,授权似乎没有任何错误。 Which means it's eliminate the possibility of mistake API_KEY.
这意味着它消除了错误API_KEY.
的可能性API_KEY.
I wonder what's the possibilities that I didn't see. 我想知道我没有发现什么可能性。 I hope to find some insights here.. 我希望在这里能找到一些见识。
My Manifest 我的清单
<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_WIFI_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="[Removed]"/>
My Gradle 我的摇篮
compile 'com.google.android.gms:play-services:7.8.0'
My fragment XML 我的片段XML
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
My Fragment 我的片段
public class CurrentLocationFragment extends Fragment implements OnMapReadyCallback {
private MapView mapView;
private GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_current_location, null);
FragmentManager fm = getChildFragmentManager();
mapView = (MapView) view.findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
map = mapView.getMap();
map.getUiSettings().setMyLocationButtonEnabled(false);
map.setMyLocationEnabled(true);
//initialize the map
try {
MapsInitializer.initialize(this.getActivity());
} catch (Throwable e) {
e.printStackTrace();
}
//animate the camera
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(43.1, -87.9), 10);
map.animateCamera(cameraUpdate);
return view;
}
Any Insights will be much appriciated! 任何见解都将被广泛应用! Thanks.. 谢谢..
Are you using Android Studio? 您正在使用Android Studio吗? You can create a Map App by default and is too easy, later you can change the MainActivity and put like Second or Third Activity, 您可以在默认情况下创建Map App,这太简单了,之后您可以更改MainActivity并放置为Second Activity或Third Activity,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.