Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get current location with geolocate #202

Closed
masoudr opened this issue Oct 4, 2017 · 12 comments
Closed

get current location with geolocate #202

masoudr opened this issue Oct 4, 2017 · 12 comments

Comments

@masoudr
Copy link

masoudr commented Oct 4, 2017

Hi,
I want to get the current location based on this link but I can't find any python example to do that. I want to create a general code to get the current location.
I used this part of code but it didn't work.

import googlemaps
gmaps = googlemaps.Client(key='my_key')
loc = gmaps.geolocate()
print(loc)

Thanks.

@domesticmouse
Copy link
Contributor

You need to supply Wifi and Cell tower information for the Geolocate API to do it's job. From the documentation: The Google Maps Geolocation API returns a location and accuracy radius based on information about cell towers and WiFi nodes that the mobile client can detect.

@masoudr
Copy link
Author

masoudr commented Oct 11, 2017

I'already test that but I couldn't retrieve the information. is there any example to do this?
Another problem is I want to create a general purpose app that is independent on some information. For example, works on any wifi router or cellular network.

@domesticmouse
Copy link
Contributor

Extracting the WiFi and Cell tower information is platform specific and outside the scope of the API. You may be better off using the geolocation APIs available on specific platforms, e.g. Web, iOS and Android.

@masoudr
Copy link
Author

masoudr commented Oct 11, 2017

Thanks,
But I want to create a python script to retrieve current location of the user and it must be independent of wifi or cellular information, I mean something like web API but in the python script.
There is no example for python API for geolocation.

@domesticmouse
Copy link
Contributor

As explained in the documentation, this Geolocation API requires WiFi and Cellular tower information to be able to calculate the location. Without this required data, there is nothing this API can do.

@forwhomthebelltools
Copy link

forwhomthebelltools commented Mar 13, 2018

Hello @masoudr, maybe you have to disable geocoding API from google console and leave geolocation api enabled. In this way your script will run and you will get location with accuracy in meters. I tried your python script above but the position returned is non accurate, because of geolocation by ip address.

@masoudr
Copy link
Author

masoudr commented Mar 14, 2018

@forwhomthebelltools Thanks for the tip. I tried the manual method and sent POST request directly to Google API and it worked somehow.

@trinanda
Copy link

Hello @masoudr , can i see the scripts have you tried and works?

@masoudr
Copy link
Author

masoudr commented Jul 30, 2018

@trinanda I couldn't get any result from googlemaps API. If you need the location you can use google doc and manually send a request with a proper body to the server and get the location.

@joeljogy
Copy link

Hey, here's a different solution to the same problem and you can obtain more accurate geolocation(lat,lng coordinates) using selenium.

Tutorial for that can be found here: https://link.medium.com/LOSOvlDLiU

Or find the script for it, directly here: https://github.com/joeljogy/Getting-GeoLocation

@jenlincode
Copy link

@joeljogy This is perfect. Thank you for your solution.

@markmelnic
Copy link

Hey, here's a different solution to the same problem and you can obtain more accurate geolocation(lat,lng coordinates) using selenium.

Tutorial for that can be found here: https://link.medium.com/LOSOvlDLiU

Or find the script for it, directly here: https://github.com/joeljogy/Getting-GeoLocation

This is a cool but very unsustainable solution.

@googlemaps googlemaps locked as off-topic and limited conversation to collaborators Aug 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants