Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use google map V2 inside fragment?
    text
    copied!<p>I have a fragment which is a part of Viewpager, and I want to use Google Map V2 inside that fragment. This is what I have tried so far,</p> <p>In my fragment,</p> <pre><code> private SupportMapFragment map; private GoogleMap mMapView; @Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); FragmentManager fm = getChildFragmentManager(); map = (SupportMapFragment) fm.findFragmentById(R.id.map); if (map == null) { map = SupportMapFragment.newInstance(); fm.beginTransaction().replace(R.id.map, map).commit(); } } @Override public void onResume() { super.onResume(); if (mMapView == null) { mMapView = map.getMap(); Marker hamburg = mMapView.addMarker(new MarkerOptions().position(HAMBURG) .title("Hamburg")); Marker kiel = mMapView.addMarker(new MarkerOptions() .position(KIEL) .title("Kiel") .snippet("Kiel is cool") .icon(BitmapDescriptorFactory .fromResource(R.drawable.ic_launcher))); mMapView.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15)); // Zoom in, animating the camera. mMapView.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); } } </code></pre> <p>and in my layout subfragment_info.xml , I have,</p> <pre><code>&lt;fragment android:id="@+id/map" class="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="300dp" android:layout_alignParentLeft="true" android:layout_below="@+id/tableLayout1" /&gt; </code></pre> <p>I can see the map now. But the markers are not showing. I think my Google map mMapView is null. Please help me to get this problem solved. Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload