title: How to drop a marker on the users location in Google Maps v2
body: <p>Hi I want the user to be able to find their location on Google Maps v2. Something is happening when I click the location button on the map because a little satellite thing with beams coming off of it appears at the top of my phone. Can anyone help with this problem?</p>
  
  <p>Also as a side question is there any way of adding directions or distance to a defined location too? </p>
  
  <p>MapsActivity.java:</p>
  
  <pre><code>package com.example.softwaresearchapp;
  import android.app.Activity;
  import android.content.Context;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  import android.os.Bundle;
  import android.widget.Toast;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.MapFragment;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  
  public class MapsActivity extends Activity {
  
      // Google Map
      private GoogleMap googleMap;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.maps);
  
          try {
              // Loading map
              initilizeMap();
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }  
      /**
       * function to load map. If map is not created it will create it for you
       * */
      private void initilizeMap() {
          if (googleMap == null) {
              googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                      R.id.map)).getMap();
  
              // check if map is created successfully or not
              if (googleMap == null) {
                  Toast.makeText(getApplicationContext(),
                          "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                          .show();
              }
          }
  
          googleMap.setMyLocationEnabled(true); // false to disable
          googleMap.getUiSettings().setMyLocationButtonEnabled(true);
          googleMap.getUiSettings().setCompassEnabled(true);
          googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
          googleMap.addMarker(new MarkerOptions()
                  .position(new LatLng(52.911927, -1.187923))
                  .title("Nottingham Trent University - Clifton Campus"));
          googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
          //googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
          //googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
          //googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
          //googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          initilizeMap();
      }
  }
  </code></pre>
  
  <p>AndroidManifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.softwaresearchapp"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
      &lt;uses-sdk android:minSdkVersion="11" android:targetSdkVersion="17" /&gt;
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" 
          android:theme="@style/Theme.AppCompat.Light"&gt;
          &lt;activity
              android:name="com.example.softwaresearchapp.MainActivity"
              android:label="@string/app_name"&gt;
              &lt;meta-data
                  android:name="android.app.default_searchable"
                  android:value=".SearchResultsActivity" /&gt;
          &lt;/activity&gt;
          &lt;!-- Search results activity --&gt;
          &lt;activity android:name="com.example.softwaresearchapp.SearchResultsActivity"
              android:parentActivityName="com.example.softwaresearchapp.MainActivity" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.SEARCH" /&gt;
              &lt;/intent-filter&gt;
  
              &lt;meta-data
                  android:name="android.app.searchable"
                  android:resource="@xml/searchable" /&gt;
          &lt;/activity&gt;
           &lt;activity android:name ="com.example.softwaresearchapp.MapsActivity"/&gt;
               &lt;activity android:name ="com.example.softwaresearchapp.ABActivity"/&gt;
               &lt;activity android:name="com.example.softwaresearchapp.SoftwareSearchActivity"/&gt;
               &lt;activity android:name="com.example.softwaresearchapp.SplashActivity"&gt;
                   &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
              &lt;/activity&gt;        
           &lt;meta-data
      android:name="com.google.android.maps.v2.API_KEY"
      android:value="AIzaSyAyPwV_djsaafTUYCjEc_QyUgjnSdnriwg"/&gt;
           &lt;meta-data
      android:name="com.google.android.gms.version"
      android:value="@integer/google_play_services_version" /&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>