Android Google Map how to check if the gps location is inside the circle

后端 未结 4 1020
小蘑菇
小蘑菇 2020-12-12 17:49

I\'m trying to detect if a user is in the radius of a Marker , using the users gps location. I have the marker\'s coordinates, but I don\'t know how to calculate whether the

4条回答
  •  我在风中等你
    2020-12-12 18:26

    @Daniel Nugent: imho getRadius() will return the radius and not the diameter so the "/2" is wrong

    @WARpoluido: I cant see that the mMarker variable is updated when the location changes. Why dont you use the value given to onMyLocationChange()?

    Location.distanceBetween( mCircle.getCenter().latitude, mCircle.getCenter().longitude, location.getLatitude(), location.getLongitude(), distance);
    if( distance[0] > mCircle.getRadius() ){
    ...
    

提交回复
热议问题