Namratha Namratha - 1 year ago 71
Android Question

Google Maps API Android show Map of address in MapFragment

I have a SupportMapFragment

private GoogleMap mMap;
// ...
mMap = ((MapFragment) getFragmentManager().findFragmentById(;

I want to load the map for a particular address. The above code, I got at
I also saw this post Google maps API in Android which talks about starting an activity. I don't want to do that but load it in the fragment. How do I do this? The APIs of Google Map ( also don't have any appropriate method for loading map with specific address.

Answer Source

Take a look at this code,

    public class MainActivity extends Activity {
  static final LatLng HAMBURG = new LatLng(53.558, 9.927);
  static final LatLng KIEL = new LatLng(53.551, 9.993);
  private GoogleMap map;

  protected void onCreate(Bundle savedInstanceState) {
    map = ((MapFragment) getFragmentManager().findFragmentById(

    if (map!=null){
      Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
      Marker kiel = map.addMarker(new MarkerOptions()
          .snippet("Kiel is cool")

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download