Flet with Python geolocate

Question:
Hello, I’m making my first app with Flet and I have it ready to release the first alpha version. It is a time control and every time the user starts activity and ends it takes the geolocation with the IP through geopy with nominatim, but it always detects the same coordinates a few kilometers away, no matter where it is. Can you recommend a more precise alternative method that does not have costs?

Repl link:

    geolocator = Nominatim(user_agent="controlhorario")
    g = geocoder.ip("me")
    mi_lat = g.latlng[0]
    mi_lon = g.latlng[1]
    dir_gps = (mi_lat, mi_lon)

thank’s

Hey, @nelsongil!
If you are running this directly on Replit, it will not return the location of your device, but rather the location of the Linux server that your repl is running on. Your code seems pretty solid, though I haven’t tested it, but I would recommend trying to run it on Visual Studio Code, or if you want to do it on a mobile device, try making your program into a webserver with Flask, so that people can view the data as a website.

2 Likes

Thanks for your response, maybe it is possible to use browser location? There must be a way to do it and not have to do the project again with another technology and be able to take advantage of repl.it like I have it.
All the best