1

There is a google MapView and projection circle zone. if user keep move inside projection circle there should be pop up messagebox so that i need listener and projection implementanion.

I dont know which listener i have to use. ıf you help me i appreciate that. thanks

KSBeyaz
  • 11
  • 2

1 Answers1

0

try with the distance it works for you I think: distanceBetween

Yo can implement your listener with a Runnable:

  private Handler handler = new Handler();
  public static final int circleCheckingDelay = 1000; // in ms


  private Runnable circleChecker = new Runnable()
  {
      public void run()
      {
          float distance= getDistance(GeoPoint p1, GeoPoint p2);
          if(distance < ...)
          {
            //do something
          }
          handler.removeCallbacks(circleChecker);
          handler.postDelayed(circleChecker, circleCheckingDelay);
      }
  };

Add the following functions in your mapActivity:

OnResume:

  handler.postDelayed(circleChecker, circleCheckingDelay);

OnPause:

  handler.removeCallbacks(circleChecker);

Check this link too: how to find the distance between two geopoints?

for example the function to get the distance:

public float getDistance(GeoPoint p1, GeoPoint p2) {
    double lat1 = ((double)p1.getLatitudeE6()) / 1e6;
    double lng1 = ((double)p1.getLongitudeE6()) / 1e6;
    double lat2 = ((double)p2.getLatitudeE6()) / 1e6;
    double lng2 = ((double)p2.getLongitudeE6()) / 1e6;
    float [] dist = new float[1];
    Location.distanceBetween(lat1, lng1, lat2, lng2, dist);
    return dist[0];
}
Community
  • 1
  • 1
ƒernando Valle
  • 3,634
  • 6
  • 36
  • 58