Я создал приложение для геозоны.
Я реализую прослушиватель местоположения, который отправляет мне текущую широту и долготу.
У меня есть массив Lat Long, и я создал Geofence из этого массива.
Я хочу проверить, что текущая широта и долгота находятся в пределах моей геозоны или нет?
Код для геозоны: -
private void createGeofence(double latitude, double longitude, int radius,
String geofenceType, String title) {
Marker stopMarker = googleMap.addMarker(new MarkerOptions()
.draggable(true)
.position(new LatLng(latitude, longitude))
.title(title)
);
googleMap.addCircle(new CircleOptions()
.center(new LatLng(latitude, longitude)).radius(radius)
.fillColor(Color.parseColor("#B2A9F6")));
}
Lat Long от слушателя: -
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Lat=location.getLatitude();
Lng=location.getLongitude();
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(this, Locale.getDefault());
try {
addresses = geocoder.getFromLocation(Lat, Lng, 1);
address = addresses.get(0).getAddressLine(0);
city = addresses.get(0).getAddressLine(1);
country = addresses.get(0).getAddressLine(2);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Lat Long is "+ Lat + " " + Lng);
}
Пожалуйста, помогите в этом.