Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When you define the <code>MapFragment</code> like this in your XML, there is no need to perform any <code>FragmentTransaction</code>. The fragment with the map will just be there.</p> <p>So in your <code>onCreate()</code> method try to change the lines</p> <pre><code>mMapFragment = MapFragment.newInstance(); setContentView(R.layout.activity_draw_path); options.mapType(GoogleMap.MAP_TYPE_NORMAL) .compassEnabled(true) .scrollGesturesEnabled(true) .zoomGesturesEnabled(true); MapFragment.newInstance(options); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map1)).getMap(); android.app.FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.map1, mMapFragment); fragmentTransaction.commit(); </code></pre> <p>to</p> <pre><code>setContentView(R.layout.activity_draw_path); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map1)).getMap(); // This is how you set up the map options in this case. // Btw, you could maybe check if you don't set something that // the map has set by default. I'd be surprised if scrollGestures // or zoomGestures were disabled by default. Also the setting // MAP_TYPE_NORMAL is I think useless as it should be the default. mMap.getUiSettings().setCompassEnabled(true).setScrollGesturesEnabled(true).setZoomGesturesEnabled(true); </code></pre> <p>And then in the <code>addMarkers()</code> method, you can delete the <code>mMap = (mMapFragment).getMap();</code> line. You have already obtained reference to the map in the <code>onCreate()</code> method.</p> <p>Should work, let me know.</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