Draw waypoints in a satellite map
-
Hi!
This is a very general question.
I have an existing Qt application that processes GNSS coordinates and some associated data like speed at every point and so on.
Now I would like to add a map to my application to visualize the waypoints along a route in a (for example) open street map or other.
However, I have absolutely no idea how to do this, respectively where to start.A few requirements:
- draw waypoints
- visualize data associated with waypoint, e.g. color shade the waypoint marker according to some data, e.g. velocity
- show additinonal data, e.g. by hovering over the waypoint
- use map tiles or satellite tiles
- if possible use free and/or open providers only
Can someone give me a few hints on where to start?
What I've done so far is get the minimal map example for QtLocation with QML up and running and I can show an OSM map and draw a marker to a specific place.
Sorry if I use incorrect or imprecise terminolgy here, as I said I'm completely new to all of this.Thanks!
-
Hi and welcome to devnet,
From a cursory look, the Putting objects on a map section in the Maps And Navigation chapter should be the starting point you are looking for.
-
Thanks @SGaist !
Do you by chance also have a hint for the general topic? Using tile servers, getting satellite images and what not...
-
@LinkwitzRiley , a long time ago I worked for a company where we did this kind of thing, first off you need to either know the extents of the map you are working with, that is the coordinates that can be shown on the map.
Then you need to decide what type of coordinates you are going to be using geographical great circle or grid. Geographical co-ordinates consist of a latitude and longitude and these can be in several formats, degrees minutes & seconds, degrees minutes and decimal minutes or radial. Grid co-ordinates are easting and northing in metres that then require a spheroid and projection used to transform the easting and nothing to geographical latitude and longitude.
Do you have all the math functions required to perform this translation?
-
Hi @SPlatten and thanks!
I'm not too much concerned about that side of things; as I said the application is already handling position data that comes from GNSS and transforms in several ways, e.g. the changes in representation you mentioned.
What I am new to is the whole map handling part itself, so showing a map to the user, make it interactive in terms of satellite or map only display, make it zoomable, those things.I guess my first problem to solve would be, coming from the minimal map example, how do I display satellite imagery instead of the base map?
-
Can anyone help me with getting from the following code to satellite images?
main.cpp:
#include <QGuiApplication> #include <QQmlApplicationEngine> #include <QSslSocket> int main(int argc, char *argv[]) { qDebug() << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString(); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }
main.qml:
import QtQuick 2.0 import QtQuick.Window 2.0 import QtLocation 5.6 import QtPositioning 5.6 Window { width: 512 height: 512 visible: true Plugin { id: mapPlugin name: "osm" // "mapboxgl", "esri", ... // specify plugin parameters if necessary // PluginParameter { // name: // value: // } } Map { anchors.fill: parent plugin: mapPlugin center: QtPositioning.coordinate(48.208497863359874, 16.373096018872882) zoomLevel: 14 activeMapType:MapType.SatelliteMapDay MapQuickItem { id: marker1 coordinate {latitude: 48.208497863359874, longitude: 16.373096018872882} sourceItem: Image { id: image1 height: 35 width: 35 source: "geotag.png" } function recenter(lat,lng) { map.clearMapItems(); marker.coordinate.latitude = lat; marker.coordinate.longitude = lng; map.addMapItem(marker); map.center.latitude = lat; map.center.longitude = lng; map.update(); } } } }
-
@LinkwitzRiley , sorry this is not something I've done with Qt. What format is the map in? Is it an Admiralty Raster Chart (https://www.google.co.uk/aclk?sa=l&ai=DChcSEwiIxqOFnqL3AhWTt8gKHf0aAl4YABAAGgJxdQ&sig=AOD64_2KFXQt71cpq7dm0vDMjjVrlXWuog&q&adurl&ved=2ahUKEwiLppuFnqL3AhVig4kEHbRtCNgQ0Qx6BAgEEAE) ?
Looking at your QML if the map is just a bitmap, then you need to include information about the extents of the map, that way the additional information can be worked out, e.g. coordinates for top, left and bottom right. Lets say you supply latitude and longitude for the top left and bottom right of the map, you will also need to supply a scale factor so you can then work out the extents of the area shown between the minimum and maximum latitude and longitude.
Once you have the extents and the scale factor then you should be able to calculate a X,Y coordinate on the map.
-
Thanks @SPlatten,
but as a first step, I would like to add a satellite view to the map, as I stated in my question.
Can anyone help me with that? -
@LinkwitzRiley , what do you mean by satellite view, if the map you have is a bitmap and not a vector then you cannot zoom in or out of it and the resolution will not change, if it was a raster chart as I mentioned in my last post then you can zoom in and out and the level of detail improves.
At best all you can do with a bit map is crop sections of it, but zooming in or out will just get blockly.
-
@SPlatten, zooming and the necessary loading of new (higher or lower resolution) tiles is completely handlet by QtLocation.
What I want to do is display a satellite view, similar to when one switches from map view to satellite view in google maps.
From what I know, one has to configure a different tile server for that. However, I don't know a) if that is sufficient and b) how to do that.