Adding a Marker to Google Android Map v2 Running on Android 2.3.3

android-map-v2-mark-old-androidRunning Google Map on older version of Android e.g. 2.3.3 is a bit different than running on a newer ones. Android Google Map v2 on Older Android Version shows how to setup Google Map v2 to run on Android 2.3.3. Here we will show how to add a marker to the on the middle of the map.

 

 

 

 

Objective:

  • How to add a marker to Google Map v2 running on older version of Android (2.3.3.)?

Environment & Tools:

  • Android Developer Tools (ADT) (or Eclipse + ADT plugin)
  • Samsung Galaxy S II with Android 2.3.3
  • Min SDK 8
  • Google Play Services revision 13
  • Android Support Library revision 19

( 1 ) Create Android Application

Android Google Map v2 on Older Android Version

( 2 ) Add the Marker

In the MainActivity class modify the code as following

package com.hmkcode.android;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MainActivity extends FragmentActivity  {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        GoogleMap map;
        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        map.addMarker(new MarkerOptions()
                .position(new LatLng(0, 0))
                .title("Hello world"));
    }

}