Live Location using Python

74 views Asked by At

I had to get live location using for an emergency service idea me and a group of friends had. I tried using geopy and geocoder but the location was far off from my actual one.

The code i tried is attached below:

import geocoder
from geopy.geocoders import Nominatim

g = geocoder.ip('me')
coors = g.latlng

geolocator = Nominatim(user_agent="my_app_name")
location = geolocator.reverse(f"{coors[0]}, {coors[1]}")

print(location.address)

The location it provided me with a location about 200kms(124.274 miles) away from my actual location. Is it possible to get the intended output from the modules I used or are there any better ones out there?

0

There are 0 answers