4

I'm building an app where I need to apply bounds on user's location (Lat,Lng) to be within city perimeters like Uber. How can I achieve this?

This one is when within city perimeters

enter image description here

This one is not in city or Uber's service zone.

enter image description here

I have tried this approach. I'm using geocoder and fetching the address of the location and matching city parameters.

        addresses = geocoder.getFromLocation(lat, lon, 1); 
        if (addresses != null && !addresses.isEmpty()) {
            String address = addresses.get(0).getAddressLine(0);
            String city = addresses.get(0).getLocality();
            String state = addresses.get(0).getAdminArea();
            String country = addresses.get(0).getCountryName();
            String postalCode = addresses.get(0).getPostalCode();
            String knownName = addresses.get(0).getFeatureName();
        }

Can I use Geofencing? If yes then how?

Abhishek Dey
  • 1,601
  • 1
  • 15
  • 38

0 Answers0