title: How to constantly detect nearby marker locations from current location in Google Maps android?
body: <p>I am trying to display a <code>TextView</code> at the top left corner of Google Maps that inform users if they are x distances from particular marker point locations, i.e. "You are close to location A", but only display the <code>TextView</code> if within range. If they move out of range, the <code>TextView</code> will disappear.</p>
  
  <p>I understand that the Google Places API shows you all the nearby locations, but I only want to show nearby locations of the markers I have on the map if users are x distances close to them.</p>
  
  <p>How can I achieve this? Would I still need to use Google Places API?</p>
  
  <p>my class .java:</p>
  
  <pre><code>private GoogleMap mMap;
  
  private LatLng currLocation;
  
  private static final LatLng POINTA = new LatLng(32.820193, -117.232568);
  private static final LatLng POINTB = new LatLng(32.829129, -117.232204);
  private static final LatLng POINTC = new LatLng(32.821114, -117.231534);
  private static final LatLng POINTD = new LatLng(32.825157, -117.232003);
  
  // Array to store hotspot coordinates
  private ArrayList&lt;LatLng&gt; markerCoords = new ArrayList&lt;LatLng&gt;();
  private static final int POINTS = 4;
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_map);
  
      setUpMapIfNeeded();
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
      // Create MenuInflater object to insert ActionBar buttons
      MenuInflater inflater = getMenuInflater();
  
      // Display the ActionBar buttons from .xml
      inflater.inflate(R.menu.menu_map, menu);
  
      return true;
  }
  
  @Override
  protected void onResume()
  {
      super.onResume();
      setUpMapIfNeeded();
  
  }
  
  private void setUpMapIfNeeded()
  {
      if (mMap == null)
      {
          mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                  .getMap();
  
          // Check if we were successful in obtaining the map.
          if (mMap != null)
          {
              markerCoords.add(POINTA);
              markerCoords.add(POINTB);
              markerCoords.add(POINTC);
              markerCoords.add(POINTD);
  
              setUpMap();
          }
      }
  }
  private void setUpMap()
  {
      // Set My Location blue dot
      mMap.setMyLocationEnabled(true);
  
      LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
      Criteria criteria = new Criteria();
      String provider = locationManager.getBestProvider(criteria, true);
      Location myLocation = locationManager.getLastKnownLocation(provider);
  
      if (myLocation != null)
      {
          double latitude = myLocation.getLatitude();
          double longitude = myLocation.getLongitude();
          currLocation = new LatLng(latitude, longitude);
      }
  
      for (int i = 0; i &lt; POINTS; i++)
      {
          mMap.addMarker(new MarkerOptions()
                  .position(markerCoords.get(i))
                  .icon(BitmapDescriptorFactory.fromResource(R.drawable.post_it_marker)));
      }
  }
  </code></pre>
  
  <p>map.xml</p>
  
  <pre><code>&lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;fragment
          xmlns:map="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/map"
          android:name="com.google.android.gms.maps.SupportMapFragment"
          map:cameraTargetLat="32.881416"
          map:cameraTargetLng="-117.237428"
          map:cameraZoom="15"
          map:mapType="normal" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Can someone point me in the right direction? Thanks</p>