Check user within circle of Map and activate a button

0

I'm developing an application and I came across a logic that I can not solve, if anyone can give a force, I'd appreciate it.

IhaveadestinationthathasarangecircleofitImadeitwiththiscode:

privatevoidsetDestino(Doublelatitude,Doublelongitude){latDestino=latitude;longDestino=longitude;LatLngdestino=newLatLng(latDestino,longDestino);map.addMarker(newMarkerOptions().position(destino).title("Destino entrega Depósito."));
    CircleOptions circle = new CircleOptions().center(destino);
    circle.fillColor(Color.LTGRAY);
    circle.radius(30); //Em metros.
    map.addCircle(circle);
}

And I have a bookmark of a user that is going to this destination, it is being updated by picking up the location information of the phone:

@Override
public void onLocationChanged(Location l) {
    if(l != null){
        latitude = l.getLatitude();
        longitude = l.getLongitude();
        LatLng usuario= new LatLng(latitude, longitude);
        LatLng destino = new LatLng(latDestino, longDestino);
        map.clear();
        map.addMarker(new MarkerOptions().position(usuario).title("Usuário"));
        map.moveCamera(CameraUpdateFactory.newLatLng(usuario));
        setDestino(latDestino, longDestino);
        adicionaPolyline(map, mastertrack, destino);
    }
    map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(l.getLatitude(), l.getLongitude()), 20));

}

The logic that I lack is when the user is out of the circle a button will be disabled, when I click on the circle of the destination I check if the user's marker is inside the circle and activate the button.

If anyone knows and can clarify this logic, it will be a great favor. Thank you.

    
asked by anonymous 05.07.2017 / 18:47

0 answers