Simple way to draw a line on a map in real-time
Project description
Draw a on a map in real-time
Install the library
pip install fmo-livemap
Run the server
livemap server
You can view the map in your browser at localhost:5689
.
Draw a line with a script
This simple script will connect to the map, create a new line and update it every 2 seconds
gps_data = [
[38.91168232416608, -76.47992628575723,],
[38.91167723745552, -76.47998040159345],
[38.911660346950676, -76.48003362018159],
[38.91163193259245, -76.48008505529343],
[38.91159245603817, -76.48013384887776],
[38.91154255338108, -76.4801791845924],
[38.91148818673626, -76.48022588905636],
[38.91142387753969, -76.48026912019613],
[38.91135045470874, -76.48030791267406],
[38.911268963041756, -76.48034139145376],
[38.91118060039576, -76.48036874891672],
[38.9110867003822, -76.48038926174374],
[38.91098871241652, -76.48040230666497],
[38.9108881794186, -76.48040737474784],
[38.91078671350825, -76.48040408391331],
[38.910685970081836, -76.48039218939842],
[38.9105876206919, -76.48037159191706],
[38.91049332518039, -76.48034234331065],
[38.91040470353717, -76.48030464952399],
[38.9103233079686, -76.48025887079041],
[38.91025059566554, -76.48020551896194],
]
import time
from livemap.client import Map
# Setup a connection to the map server
map = Map("http://127.0.0.1:5689")
# Create an empty line
my_line = map.polyline("myline", [])
# Extend the line with new coordinates over time
for p in gps_data:
my_line.extend(p)
time.sleep(2)
You can change the color of the line: map.polyline("myline", [], color='red')
Load a geojson file
When the server is running, use the cli to load a file
livemap load-file mydata.json
This assumes the server is running at http://127.0.0.1:5689
, but you can override it
livemap load-file -h 127.0.0.1 -p 5555 mydata.json
You can change the color of the line
livemap load-file mydata.json --color red
This is a sample geojson file that works with the load-file
command:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-75.7949705,
38.0574904
],
[
-75.7950745,
38.0572349
],
[
-75.7951317,
38.0572322
]
]
}
}
]
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fmo-livemap-0.4.0.tar.gz
.
File metadata
- Download URL: fmo-livemap-0.4.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dbdccbec9fdc86903c8800d27b0f892324f5a6406aead844930a312dc72f5d7 |
|
MD5 | 71b18381717fd839b5a88fa7dc768e79 |
|
BLAKE2b-256 | 0a099559171a6e7a62a8ef6240dfa2195a883b8fe4f3978e2448acfdbe6cff80 |
File details
Details for the file fmo_livemap-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: fmo_livemap-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0764fd7acbef71d2f618dd0c8628d56f997a5db08e11c21afeec98414990ee37 |
|
MD5 | 9abaf34b37465306bd958e3c7e912b57 |
|
BLAKE2b-256 | 225a31ca48127b337ef177eed6ae408de091433cd24a7c659cf575a745a08315 |