Skip to content Skip to sidebar Skip to footer

Check If Marker Is Inside Circle Radius

I'm trying to know if a given marker is inside a circle radius. In javascript, i can do something like: google.maps.geometry.spherical.computeDistanceBetween(latLngCircleCenter, la

Solution 1:

After a lot of research, i found a very simple solution:

float[] distance = newfloat[2];

Location.distanceBetween( marker.getPosition().latitude, marker.getPosition().longitude,
    circle.getCenter().latitude, circle.getCenter().longitude, distance);

if( distance[0] > circle.getRadius()  ){
    Toast.makeText(getBaseContext(), "Outside", Toast.LENGTH_LONG).show();
} else {
    Toast.makeText(getBaseContext(), "Inside", Toast.LENGTH_LONG).show();
}

I'm testing this and it's working. Can someone test too and give the feedback here?

Solution 2:

Solution 3:

I think its possible to find the Centre of the circle, you are defining the circle in your code with repect to a given geopoint. You can save it and use later. Then try Location.distanceBetween(..)

Post a Comment for "Check If Marker Is Inside Circle Radius"