I am using MapView inside a fragment. Now it does not load. (Or to be precise, it loads but it does not load. Yes, its weird, pics attached.)
Here is the code :
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home, container, false);
mapView = (MapView) view.findViewById(R.id.mapview);
// Gets the MapView from the XML layout and creates it
mapView.onCreate(savedInstanceState);
// Gets to GoogleMap from the MapView and does initialization stuff
mapView.getMapAsync(this);
}
And on MapReady, I do this :
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
map.getUiSettings().setMyLocationButtonEnabled(true);
map.getUiSettings().setAllGesturesEnabled(true);
map.setMyLocationEnabled(true);
// Needs to call MapsInitializer before doing any CameraUpdateFactory calls
try {
MapsInitializer.initialize(this.getActivity());
} catch (Exception 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);
}
The map is not even loaded. When I keep clicking on it. Then after a few seconds it suddenly starts showing zoomed, but does not respond to any user interaction. Nothing happens whether i click it pinch zoom it. Now when I use a SUPPORT MAP FRAGMENT, it loads immediately and perfectly. So, MY API KEY IS CORRECT AND INTERNET IS PERFECTLY FINE. But MAP VIEW IN THE FRAGMENT DOES NOT WORK.
I also checked this link and the logs are same like I am getting :Here
Sometimes when I keep clicking on it , say 10 20 times, then after few seconds only some part of map is visible. But still no user interaction. Nothing happens, no matter what I do.
Now here are the screenshots of the MapView :
Please help me, can anyone tell me if its a bug on my side or a real bug on Android's mapview. Has anyone able to use MapView inside fragment with latest Google Play services ?
Please help me, I am stuck.
Thanks



