in this my gps application i want to draw circle around my current location i did it ...but now i find out other users which are come in ci开发者_C百科rle range so i want popoup in my application screen so can anyboby help me...
you have just to compute the distance between each point and the center of the circle.
This can be done with something like this:
double d2r = (180 / Math.PI);
double distance = 0;
try{
double dlong = (endpoint.getLon() - startpoint.getLon()) * d2r;
double dlat = (endpoint.getLat() - startpoint.getLat()) * d2r;
double a =
Math.pow(Math.sin(dlat / 2.0), 2)
+ Math.cos(startpoint.getLat() * d2r)
* Math.cos(endpoint.getLat() * d2r)
* Math.pow(Math.sin(dlong / 2.0), 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
double d = 6367 * c;
return d;
} catch(Exception e){
e.printStackTrace();
}
and then
if (distance < CIRCLE_RADIUS) //The point is inside circle.
If you know the coordinates of the center of the circle and a friend you can call the static method Location.distanceBetween() to find the distance. As you must know the size of your circles radius its just a compare of the result of distanceBetween() and your radius.
精彩评论