Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write Map and realize dynamic trajectory in Qt

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "Qt how to write maps to realize dynamic trajectories". In daily operation, I believe many people have doubts about how to write maps to realize dynamic trajectories in Qt. Xiaobian consulted all kinds of materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "Qt how to write maps to realize dynamic trajectories"! Next, please follow the small series to learn together!

I. Foreword

Recently, in the robot monitoring platform, it is necessary to dynamically display the trajectory of the robot, and at the same time, it is necessary to select points on the map to plan the path, and then send the coordinate information of the obtained path to the robot, so that the robot can move by itself according to the received latitude and longitude coordinates. Sometimes, the number of track point coordinate sets queried is very large, which is limited by the memory space of the robot itself. It is required to set a filtering mechanism to filter track points. Then the filtered track point information is sent, for example, only 50 points are required, and 300 points are received, then the average value is automatically filtered, for example, one point coordinate is taken every 6 points, and then the first and last coordinates must be in, so as to ensure the integrity of the whole path.

There are two ways to set the label points to generate dynamic track effect. One is to clear all the label points directly, reload the new label points with latitude and longitude coordinates, that is to say, call deleteMarker function to clear all label points, and then call addMarker function to set new label points one by one. Another method is to pass in the identification information of the moved label points, and let js function automatically find them. Then execute setPosition method. In the case of a small number of label points, such as one, the efficiency of the two methods is almost the same. If there is more clearance, the second method is the best choice. There is no need to delete and add repeatedly. Let the existing label point object setPosition be good.

Step 1: Dynamically select the latitude and longitude coordinates of the starting point and the ending point.

Step 2: Choose the route planning method (walking, bus, driving, cycling).

Step 3: Choose the strategy for path planning (minimum time, shortest distance, etc.).

Step 4: Click Query to receive and save the coordinate set of path points.

Step 5: Start the timer, take out the next latitude and longitude coordinates one by one, and set the coordinates of the marked points.

Step 6: Stop the timer until the latitude and longitude coordinates are taken out.

II. Functional characteristics

It supports both online map and offline map modes.

Support webkit kernel, webengine kernel, minilink kernel, IE kernel.

Support setting multiple marking points, including name, address, latitude and longitude.

You can set whether the map can be clicked, dragged, or zoomed with the mouse wheel.

Protocol version, key, theme style, central coordinates, central city, geocode location, etc. can be set.

Map zoom and level can be set, thumbnail, scale, traffic information and other controls visible.

Support map interaction, such as mouse press to get the latitude and longitude of the corresponding position.

Support query route, you can set starting position, ending position, route mode, route mode, route scheme (minimum time, minimum transfer, minimum walking, no subway, shortest distance, avoid highway).

Dot-line-surface tool can be displayed, and lines, dots, rectangles, circles, etc. can be directly drawn on the map.

Administrative divisions can be set, designated a certain city area drawing layer, online map automatically output administrative division boundary point set to js file for offline map use.

Multiple overlays can be added statically or dynamically. Support points, polylines, polygons, rectangles, circles, arcs, point aggregations, etc.

Provide function interface to handle latitude and longitude resolution into address and address resolution into latitude and longitude coordinates.

The demo provided can directly select points to perform corresponding processing, such as route query.

You can get the coordinate information set of the points queried by the route, such as for robot coordinate navigation.

Encapsulates rich functions such as deleting specified points and all points, deleting specified overlays and all overlays, etc.

The label point pop-up box information can be customized in standard html format.

Callout point click event optional 0-Do not process 1-Pop-up box yourself 2-Send signal.

Annotations can be animated 0-Do not handle 1-Jump 2-Fall

Mark points can be set to local picture files, etc.

Function interface friendly and unified, easy to use, on a class.

Support js dynamic interaction to add points, delete points, clear points, reset points, do not need to refresh the page.

Support any Qt version, any system, any compiler.

III. Effect Drawing

void MapBaiDu::moveMarker(QStringList &list){ //Move points dynamically list data(Qt::UserRole).toString(); points listWidgetSrc->item(countSrc - 1)->data(Qt::UserRole).toString(); if (points.last() != point) { points listWidgetTarget->clear(); for (int i = 0; i

< points.count(); ++i) { QString point = points.at(i); addItem(ui->

listWidgetTarget, i, point); } ui->tabWidgetRoute->setCurrentIndex(1); qDebug() isVisible()) { listWidget = ui->listWidgetTarget; } int row = listWidget->currentRow(); if (row >= 0 && row

< listWidget->

count()) { QString point = listWidget->currentItem()->data(Qt::UserRole).toString(); listWidget->setCurrentRow(row + 1); QString js = QString("moveMarker('%1', '%2')").arg(name).arg(point); map->runJs(js); } else { on_btnTestData_clicked(); }}void frmMapRoute::on_btnTestData_clicked(){ QString name = "Track Point"; QListWidget *listWidget = ui->listWidgetSrc; if (! ui->listWidgetSrc->isVisible()) { listWidget = ui->listWidgetTarget; } if (ui->btnTestData->text() == "Simulation Trajectory") { //Custom icons QString iconfile = "./ ipc_robot2.png"; int iconsize = 50; QString js = QString("addMarker('%1', '', '', '', 60, '%1', 0, 0, '%2', %3)") .arg(name).arg(iconfile).arg(iconsize); map->runJs(js); listWidget->setCurrentRow(0); ui->tabWidgetRoute->setEnabled(false); ui->btnTestData->setText("Stop Simulation"); timer->start(100); moveMarker(); } else { QString js = QString("deleteMarker('%1')").arg(name); map->runJs(js); timer->stop(); ui->tabWidgetRoute->setEnabled(true); ui->btnTestData->setText("Simulation track"); }} At this point, the study of "Qt how to write maps to achieve dynamic trajectories" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report