This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Hai,

I am working in a project where I will pick a point on google map by clicking somewhere on the map and draw a circle with a radius, say 1 mile. So a later if a user enters some latitude and longitude, I will have to say whether it falls within the circle or not. I am trying to do this with google maps api. I am not able to focus on any logic in particular. My problem is finding if the given coodinate or latitude or longitude is within the circle or not. I am unable to think of anything that will help. Thank you for your time.

I am working in a project where I will pick a point on google map by clicking somewhere on the map and draw a circle with a radius, say 1 mile. So a later if a user enters some latitude and longitude, I will have to say whether it falls within the circle or not. I am trying to do this with google maps api. I am not able to focus on any logic in particular. My problem is finding if the given coodinate or latitude or longitude is within the circle or not. I am unable to think of anything that will help. Thank you for your time.

http://www.free-zipcodes.com/

More to come.

Thanks for your prompt replies. I have gone through all of those, but could not find what I was looking for. Maybe, I have not been clear enough. Let me explain with an example.

Suppose, I a circle at a zoom level of 6. which is pretty high up in the sky. The area covered would be more than what I would cover with the circle of the same radius drawn at say 14, meaning closer to the ground. I would have to figure out some way to accommodate this variance. Maybe, I would need to get the coordinates on the circumference of circle. I don't know. I am just thinking aloud. Please let me know what you think. Thanks

>>be more than what I would cover with the circle of the same radius drawn at say 14, meaning

>>closer to the ground.

Well it all depends upon the circle you have drawn. If you have drawn a circle of 1 mile it will be the same even if you are watching from 1000meters above or on ground level.

In your case you donot need the circumference of the circle but only the center points of the circle and the radius of the circle. As an example your circle center coordinates are long0,lat0 and your circle has a radius of "t" meters. Now the user enters the latitude & longitude as lat1 and long1 and you need to check if the points are within your circle or not. Simply use a distance formula between the center coordinates and the coordinates entered. Then compare it with the radius. If the distance between the coordinates is less then the radius then the point lie within the circle else they are out of the circle.....

Haversine formula:

R = earths radius (mean radius = 6,371km)

”lat = lat2 lat1

”long = long2 long1

a = sin²(”lat/2) + cos(lat1).cos(lat2).sin²(”

c = 2.atan2(a, (1a))

d = R.c

Spherical law

of cosines: d = acos(sin(lat1).sin(lat2)+c

Visit the following site for full formulas

http://www.movable-type.co.uk/scripts/latlong.html

```
Haversine formula:
R = earths radius (mean radius = 6,371km)
”lat = lat2 lat1
”long = long2 long1
a = sin²(”lat/2) + cos(lat1).cos(lat2).sin²(”long/2)
c = 2.atan2(a, (1a))
d = R.c
(Note that angles need to be in radians to pass to trig functions).
Spherical law
of cosines: d = acos(sin(lat1).sin(lat2)+cos(lat1).cos(lat2).cos(long2long1)).R
```

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.