Quantcast
Viewing all articles
Browse latest Browse all 42

Detect when user enter circle

I am working on a app based on google maps.

I added a circle to the map ( https://ibb.co/PhZy0t6 ) and I have been tring to detect if the user entered the circle.

The user is a marker I added with the user current location.

I tried to do like the following:

// Circle code:        circle = mMap.addCircle(new CircleOptions()                .center(new LatLng(addressLatLng.latitude, addressLatLng.longitude))                .radius(70)                .strokeColor(Color.RED)        );// The rest        float[] distance = new float[2];        Location.distanceBetween(userLocation.latitude, userLocation.longitude, circle.getCenter().latitude,circle.getCenter().longitude,distance);        if (distance[0] <= circle.getRadius()) {            Toast.makeText(this, "User Enter Circle", Toast.LENGTH_SHORT).show();        }

However it didn't worked..

Thanks for any help


Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>