Load coordinates from cli args

master
Kuba Orlik 4 years ago
parent 173c01bd86
commit c2ddba29b9

@ -6,3 +6,18 @@ clicking on the map causes the window to close and the coordinates to be printed
on stdout; on stdout;
![](./screenshot.png) ![](./screenshot.png)
## Usage
Build the app:
```sh
make build
```
Run it:
```sh
./dist/qt-map-py/qt-map-py # start centered in Poznań
./dist/qt-map-py/qt-map-py 33.66195 -95.55362 # start centered at given lat / lon
```

@ -4,8 +4,6 @@ import QtLocation 5.15
import QtPositioning 5.5 import QtPositioning 5.5
ApplicationWindow { ApplicationWindow {
width: 640 width: 640
height: 480 height: 480
@ -22,6 +20,11 @@ ApplicationWindow {
return marker.coordinate.latitude + "|" + marker.coordinate.longitude return marker.coordinate.latitude + "|" + marker.coordinate.longitude
} }
function setMapPosition(lat, lon){
marker.coordinate = QtPositioning.coordinate(parseFloat(lat), parseFloat(lon));
map.center = QtPositioning.coordinate(parseFloat(lat), parseFloat(lon));
}
Plugin { Plugin {
id: mapPlugin id: mapPlugin

@ -30,6 +30,10 @@ if __name__ == "__main__":
if not engine.rootObjects(): if not engine.rootObjects():
sys.exit(-1) sys.exit(-1)
root = engine.rootObjects()[0] root = engine.rootObjects()[0]
if len(sys.argv) == 3:
lat = sys.argv[1]
lon = sys.argv[2]
root.setMapPosition(lat, lon)
def cb(): def cb():
print(root.getSelectedLocation()) print(root.getSelectedLocation())

@ -1,3 +1,3 @@
{ {
"files": ["pin64.png","main.py","main.qml"] "files": ["pin64.png","main.py","assets/main.qml","main.qml","assets/pin64.png"]
} }

Loading…
Cancel
Save