Finding a coordinate in a circle

后端 未结 7 1175
梦谈多话
梦谈多话 2021-01-06 20:51

I am doing a mashup using Google Maps under Grails where users can create geofences by selecting a point on the map and a radius. This get stored on my database and the appl

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-06 21:01

    Sadly, most of the responses here won't work for you conveniently, because GPS coordinates are in units of degrees. You will need something to convert from two points in Degrees of latitude and longitude to a great circle distance, which simple Pythagorean theorem falls short of.

    If you're using Google maps API, you can probably do everything you need using GLatLng. As other posters have noted, You can determine the distance between two points is less than the radius of the specified circle. Specifically GLatLng.distance(other:GLatLng) returns the meters distance between too GPS locations.

    To actually display the circles requires a bit more finesse. You will need to create a GPolygon to draw the circumference of the circle. You can find a number of free JavaScript functions that can do this for you.

提交回复
热议问题