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 realize the regional map of provinces and cities with Qt

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "how to use Qt to realize the provincial and municipal regional map". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Preface

The provincial and municipal regional map can also be called the provincial and municipal outline map, which is to turn the boundary area of each province and urban area into an outline display, which is only a rough outline, which is basically consistent with the real map, after all, it is piled up one by one, and there may be a very small error. before making the map of China in the middle of the big screen system, the customer did everything possible to explain clearly, be sure to pay attention to the nine-dash line. Otherwise, others will be scolded to death if they don't even have a nine-dash line at the exhibition. Some of the early data may not be available because they are not perfect, but there are the latest map data in the later stage, including outline data.

Echart itself does not provide provincial and municipal regional contours, so it needs to introduce external js files to draw. In order to get the corresponding outline js files of provinces and cities across the country, I searched a lot of related articles on the Internet and understood them. I downloaded the json data of the corresponding provinces, cities and regions, and then specially wrote a class according to the rules of js to convert the json data to js files, and then generated the js files of all provinces, cities and regions. Used in echart which only need that js file, these js files are available in that download address, as for the outline of these areas is actually some messy symbols specific meaning I do not understand, you say it is base64 coding it is not like, no matter what, it is correct to use as long as the specific principle is estimated to study the source code of echart.

The previous flicker point map or migration map are all based on the outline of the Chinese map, which can be scaled by the mouse. In fact, svg can also achieve a similar effect, similar to a vector map. In addition to the map of China, there can also be a map of the world. As for the maps of other countries in the world, it is estimated that they have to convert them in other ways and get them slowly. According to reason, there should be a lot of applications for foreign customers.

II. Functional features

At the same time, support flicker point map, migration map, area map, dashboard and so on.

You can set various colors such as title, prompt, background color, text color, line color, area color, and so on.

You can set the name, value, longitude and latitude collection of the city.

You can set the magnification of the map and whether the mouse wheel is allowed to zoom.

Built-in world map, national map, provincial map, regional map, can be accurate to the county, all maps are used offline.

Built-in provincial and municipal json data file to js file function, if there is a data update self-conversion, support a single file conversion and one-click conversion of all files.

Built-in function to obtain all the names and longitude and latitude information sets of the region from json files or js files, which can be used to display the information obtained by this method.

Depending on the browser component to display the map, the provided demo supports webkit, webengine and ie to load web pages.

Strong expansibility, you can add a variety of exquisite echarts components according to the gourd painting ladle to make a great effect.

The built-in dashboard components provide interactive functionality, and the corresponding code is included in the demo demo.

The function interface is friendly and unified, and it is easy to use, just one class.

Support any Qt version, any system, any compiler.

Third, effect picture

4. The related code QStringList EchartJs::getInfoFromData (const QByteArray & data) {/ / takes out the corresponding city name and latitude and longitude / / the following two methods have tested the parsing time, json is about 1s, string segmentation is probably 5s JSON method is faster QStringList result;#if (QT_VERSION > QT_VERSION_CHECK (5json 0) / / parsing QJsonParseError error; QJsonDocument jsonDoc = QJsonDocument::fromJson (data, & error) using qt's built-in json method If (error.error = = QJsonParseError::NoError) {QJsonObject rootObj = jsonDoc.object (); / / qDebug ()

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