This was made to use it with Raspberry Pi for a project I am working on. I guess this is the best API Maps you will ever find on the internet. Easy to use, Free, Opensource.
Used Application:
Flask Web Framework ( pip install flask )
Mapbox
SQLite3 Database ( pip install db-sqlite3 )
Termux ( if wanted )
Download the Files from my Github link
To Find a Location for your Phone
Download termux in your phone
Go to https://github.com/v-senthil/Device-Tracker-using-Flask/blob/main/mobile-location.py
Copy the file into your local system.
Run the python code
python3 mobile-location.py
The output will show you the latitude and longitude of your current location.
Further, the same logic which is applied in raspberry can be done to track your phone also.
To Make in Work with Raspberry Pi
A GPS Module is connected to raspberry pi, which constantly updates the database with the current location
wget "https://github.com/v-senthil/Device-Tracker-using-Flask"
unzip the file
Go to templates/tracker.html
Change the Mapbox YOUR_API_KEY ( get it from https://account.mapbox.com/ )
Run:
python3 main.py
Go to http://127.0.0.1:5000/
Enter Latitude and Longitude Value into Database (data.db)
syntax: INSERT INTO map VALUES (datetime('now','localtime'), LATITUDE, LONGITUDE)
INSERT INTO map VALUES (datetime('now','localtime'), 21.56463, 77.464734)
See that the rocket image in the map changes the location according to the location you give
For using it all over the World
Create an account at https://ngrok.com/
Download ngrok according to your system
Unzip the file and place it in your desired location
Change directory to the place where ngrok file is present
Run the below code with YOUR_AUTH_TOKEN which will be available in https://dashboard.ngrok.com/get-started/setup
./ngrok authtoken YOUR_AUTH_TOKEN
Run
./ngrok http 5000
Copy the link and paste it in templates/track.html line 65 with an extension '/locationdata'
eg: var url = 'https://cfa635282g00.ngrok.io/locationdata';
Comments