当前位置:网站首页>QT writing map comprehensive application 58 compatible with multi browser kernel
QT writing map comprehensive application 58 compatible with multi browser kernel
2022-06-29 05:57:00 【feiyangqingyun】
One 、 Preface
miniblink Is a pursuit of the ultimate compact browser kernel project , The third most popular browser kernel control in the world . It is based on chromium The latest version of the kernel , In addition to the chromium All the spare parts , Keep only the most basic typesetting engine blink.miniblink Keep it up 10M The minimalist size of the left and right , It's the smallest volume of any product of its kind , Support at the same time windows xp、npapi.miniblink The author of is very powerful ,QQ The nickname is sweeping monk , It's like the sweeping monk in Tianlong eight , Extremely secret and highly skilled , Master all kinds of unique skills , It's quite a loser .
use Qt In the process of doing the project , Encountered the need to use the browser control project , There may be a problem , That's from Qt5.6 Version start mingw Compiler Qt Build Suite , Browser controls are no longer available , It can be used before webkit Control , Now, many projects have to choose 5.6 The following versions , Or choose msvc Build suite for , And most of it msvc The build suite doesn't come with browser controls , You need to compile it yourself , Only original build kits, such as Qt5.9+VS2015、Qt5.12+VS2017 This kind of collocation can have browser control , Otherwise, even if you check the browser control, it will not be installed , This makes many projects that rely on browser controls more passive , So we must find a lightweight browser control to replace , such as cef、miniblink, Individuals are more inclined to miniblink, The usage is extremely simple , It's a very simple one dll, stay linux and mac On the system qt There will always be browser controls , So it doesn't involve cross platform issues , therefore miniblink Temporary support windows The shortcomings of our country are not shortcomings .
qt+miniblink Usage steps :
- First step : call wkeSetWkeDllPath Function load dll File path , A project only needs to be executed once .
- The second step : call wkeInitialize Initialize the dynamic library , A project only needs to be executed once .
- The third step : call wkeCreateWebWindow Create a browser control , Incoming handle .
- Step four : call wkeOnLoadingFinish Register callback load completion signal , You need to register .
- Step five : call wkeJsBindFunction Register the callback method to receive data , Be sure to put it here before loading the page .
- Step six : call wkeLoadURL Load web address 、wkeLoadFile Load web file 、wkeLoadHtmlWithBaseUrl Load web content .
- Step seven : call wkeRunJS perform js function , Super easy .
- Step eight : call wkeFinalize Release resources , Just do it once , At the end of the whole project .
Two 、 Functional characteristics
1 The functional characteristics of provincial and regional map encapsulation
- At the same time, it supports flicker point graph 、 Migration map 、 Regional map 、 Map of the world 、 Dashboard, etc .
- You can set the title 、 Prompt information 、 The background color 、 Text color 、 line color 、 Area color, etc .
- You can set the name of the city 、 value 、 Longitude and latitude aggregate .
- You can set the magnification of the map 、 Allow mouse wheel to zoom .
- Built in world map 、 National map 、 Province Map 、 Area map , It can be accurate to the county , All maps are offline .
- Built in provinces and cities json Data file transfer js File function , If there is any data update, it can be converted by itself , Support single file conversion and one click conversion of all files .
- Built in from json Documents or js File access to all the names of the area and latitude and longitude information set function , Information can be obtained through this method to display .
- Rely on browser components to display maps , Provided demo Support webkit/webengine/miniblink/ie Load web pages in many ways .
- use miniblink The browser kernel got through Qt5.6 And later +mingw The compiler lacks browser module , Make the whole project support all Qt edition , Personal test 4.7 To 6.2 And so on .
- Flicker point, migration map and other settings of the point support setting color alone .
- Provide an interface to directly obtain the relevant information of the click point , It is convenient for program linkage processing .
- It's very expansive , You can add all kinds of exquisite ones by yourself echarts Components , Make the effect of cow force .
- The built-in dashboard components provide interactive functions ,demo The demo contains the corresponding code .
- Friendly and unified function interface , Easy to use , Just one class .
- Support any Qt edition 、 Any system 、 Any compiler .
2 Baidu map encapsulation features
- At the same time, it supports online map and offline map .
- Support at the same time webkit kernel 、webengine kernel 、miniblink kernel 、IE kernel .
- Support setting multiple annotation points , The information includes the name 、 Address 、 Longitude and latitude .
- You can set whether the map can be clicked 、 Drag the 、 Mouse Wheel Zoom .
- Protocol version can be set 、 Secret key 、 The theme style 、 Central coordinates 、 The central city 、 Geocoding location, etc .
- You can set the scale and level of the map , thumbnail 、 scale 、 Traffic information and other controls are visible .
- Support map interaction , For example, press the mouse to get the latitude and longitude of the corresponding position .
- Support query route , You can set the starting position 、 Final position 、 Route mode 、 Route way 、 Route plan ( At least time 、 Minimum transfer 、 At least walk 、 No subway 、 Shortest distance 、 Avoid high speed ).
- It can display point, line and surface tools , You can draw lines directly on the map 、 spot 、 rectangular 、 Round, etc .
- Administrative divisions can be set up , Specify a city area drawing layer , The online map automatically outputs the boundary points of administrative divisions to js Files for offline map use .
- Multiple coverings can be added statically or dynamically . Support points 、 Broken line 、 polygon 、 rectangular 、 circular 、 Arc 、 A little polymerization, etc .
- Function interface is provided to process longitude and latitude resolution into address and address resolution into longitude and latitude coordinates .
- Provided demo You can directly select points to perform corresponding processing, such as route query .
- You can get the point coordinate information set from the route query , For example, for robot coordinate navigation and so on .
- Encapsulates rich functions, such as deleting specified points and all points , Delete the specified cover and all covers, etc .
- You can customize the content by marking the information of the bullet box , standard html Format .
- Annotation point click event is optional 0- Don't deal with 1- Play the box yourself 2- Sending signal .
- Mark points to animate 0- Don't deal with 1- beating 2- falling
- Mark point can set local image file and so on .
- Friendly and unified function interface , Easy to use , Just one class .
- Support js Add a little bit of dynamic interaction 、 Delete point 、 Empty point 、 Reset point , No page refresh required .
- Support any Qt edition 、 Any system 、 Any compiler .
3 Offline map download features
- Multi thread synchronous download multi-level Tile Map , No card interface .
- Built in multiple offline map download request addresses , Automatically randomly select a send request .
- Download map type, support street map and satellite map at the same time .
- Automatically calculate the number of tiles downloaded in the visual area or administrative area .
- Download level can be customized range and selection .
- After each tile is downloaded, Chengdu sends a signal to inform , Parameters include download time .
- The maximum download timeout can be set , If it exceeds, discard it and jump to the next download task .
- Real time display of download progress , And the number of tiles that have been downloaded at the current level and the total number of tiles .
- You can stop downloading during the download process , Download complete automatic statistics total time .
- Built in conversion function between latitude and longitude and screen coordinates .
- At present, baidu map is supported , Other maps like Google Maps 、 Tencent map 、 Gaode map can be customized .
- Friendly and unified function interface , Easy to use , Just one class .
- Support any Qt edition 、 Any system 、 Any compiler .
4 The features of the download function
- The timer queues up to download the point coordinate set of the provincial and municipal contour map and stores it in JS file .
- Support multiple irregular download in one administrative region .
- Automatically calculate the number of download profiles for administrative areas .
- Provinces can be selected precisely 、 The city 、 The county , You can also enter the name of the administrative region directly .
- You can set the download interval 、 Start and stop downloading at any time .
- Provide edit boundary function , You can edit the point set of irregular area directly on the map , And then get the boundary point set data , This can be used to draw your own area and get the data , For example, the administrative region data of a town or even a community , It's awesome .
3、 ... and 、 Experience address
- Experience address :https://pan.baidu.com/s/1ZxG-oyUKe286LPMPxOrO2A Extraction code :o05q file name :bin_map.zip
- Domestic site :https://gitee.com/feiyangqingyun
- International sites :https://github.com/feiyangqingyun
- Personal home page :https://blog.csdn.net/feiyangqingyun
- Zhihu Homepage :https://www.zhihu.com/people/feiyangqingyun/
Four 、 design sketch

5、 ... and 、 Related codes
#include "miniblink.h"
#include "qapplication.h"
#include "qmessagebox.h"
#include "qdatetime.h"
#include "qfile.h"
#include "qvariant.h"
#include "qdebug.h"
#pragma execution_character_set("utf-8")
#define TIMEMS qPrintable(QTime::currentTime().toString("hh:mm:ss zzz"))
static void onLoadingFinish(wkeWebView, void *param, const wkeString, wkeLoadingResult result, const wkeString)
{
//qDebug() << TIMEMS << "onLoadingFinish" << result;
// The class pointer is already passed in where the function is registered
miniblink *widget = (miniblink *)param;
//0 = WKE_LOADING_SUCCEEDED, 1 = WKE_LOADING_FAILED, 2 = WKE_LOADING_CANCELED
widget->loadFinish(result == 0);
}
static jsValue objName_receiveData(jsExecState es, void *param)
{
if (0 == jsArgCount(es)) {
return jsUndefined();
}
// Take out the parameters one by one , The general method of setting , There are only two parameters
jsValue arg0 = jsArg(es, 0);
jsValue arg1 = jsArg(es, 1);
if (!jsIsString(arg0)) {
return jsUndefined();
}
// You can get specific webview Object is used for differential analysis
//jsGetWebView(es);
// Convert the corresponding data , There are many other parameter judgments. For details, see wke.h
QString type = QString::fromStdString(jsToTempString(es, arg0));
QVariant data;
if (jsIsNumber(arg1)) {
data = jsToInt(es, arg1);
} else if (jsIsBoolean(arg1)) {
data = jsToBoolean(es, arg1);
} else if (jsIsString(arg1)) {
data = QString::fromStdString(jsToTempString(es, arg1));
} else if (jsIsArray(arg1)) {
// The following transformation needs to be processed according to the actual project application
data = QString::fromStdString(jsToTempString(es, arg1));
if (type == "boundary") {
} else if (type == "routepoints") {
}
}
// The class pointer is already passed in where the function is registered
miniblink *widget = (miniblink *)param;
widget->receiveData(type, data);
return jsUndefined();
}
miniblink::miniblink(QWidget *parent) : QWidget(parent)
{
// The first step is to initialize the dynamic library
init();
// The second step is to initialize the browser control
// Create a browser control , Put in the handle
webView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, this->width(), this->height());
// Correlation completion signal
wkeOnLoadingFinish(webView, onLoadingFinish, this);
// Set browser controls to be visible
wkeShowWindow(webView, true);
// Set whether the right-click menu is visible
wkeSetContextMenuEnabled(webView, false);
// Set whether the touch screen is allowed
wkeSetTouchEnabled(webView, false);
// For more parameter descriptions, see https://miniblink.net/views/doc/APIDocument/API/index.html
//wkeJsBindFunction("objName_receiveData", objName_receiveData, this, 2);
}
void miniblink::init()
{
// Global needs to be initialized only once
static bool isInit = false;
if (!isInit) {
isInit = true;
// Different build kits load different dynamic libraries
#ifdef Q_OS_WIN64
QString flag = "64";
QString file = qApp->applicationDirPath() + "/miniblink_64.dll";
#else
QString flag = "32";
QString file = qApp->applicationDirPath() + "/miniblink.dll";
#endif
// If the file does not exist, you will be prompted
if (!QFile(file).exists()) {
QMessageBox::critical(0, " error ", file + "\n The file does not exist. Please copy it first !");
return;
}
const wchar_t *path = reinterpret_cast<const wchar_t *>(file.utf16());
wkeSetWkeDllPath(path);
bool ok = wkeInitialize();
qDebug() << TIMEMS << QString("init miniblink_%1 %2").arg(flag).arg(ok ? "ok" : "error");
}
}
void miniblink::release()
{
wkeFinalize();
}
void miniblink::showEvent(QShowEvent *)
{
// This setting is initially placed in the constructor , It will be overwritten later , So I thought of a way to bind the display to the display
// Because lazy web pages are written in general methods, they will conflict , There is no problem if you use different methods
//miniblink The kernel uses reference counting , In order to save resources , Therefore, the last one will be used for the same binding
// This method can only be used temporarily to meet all the current project needs
// Register general methods of receiving data , Be sure to put it here before loading the page
// binding js function , Give Way js Active call C++ function , The two names can be different, but the parameters must be consistent
wkeJsBindFunction("objName_receiveData", objName_receiveData, this, 2);
}
void miniblink::resizeEvent(QResizeEvent *)
{
wkeResize(webView, this->width(), this->height());
}
void miniblink::setBgColor(const QColor &color)
{
wkeViewSettings setting;
setting.bgColor = color.rgb();
wkeSetViewSettings(webView, &setting);
}
void miniblink::loadFinish(bool ok)
{
emit loadFinished(ok);
}
void miniblink::receiveData(const QString &type, const QVariant &data)
{
emit receiveDataFromJs(type, data);
}
void miniblink::load(const QString &url, bool file)
{
QByteArray data = url.toUtf8();
const char *temp = data.data();
if (file) {
wkeLoadFile(webView, temp);
} else {
wkeLoadURL(webView, temp);
}
}
void miniblink::setHtml(const QString &html, const QString &baseUrl)
{
QByteArray dataHtml = html.toUtf8();
QByteArray dataUrl = baseUrl.toUtf8();
wkeLoadHtmlWithBaseUrl(webView, dataHtml.data(), dataUrl.data());
}
void miniblink::runJs(const QString &js)
{
QByteArray data = js.toUtf8();
wkeRunJS(webView, data.data());
}
边栏推荐
- Spark saving to external data source
- 51 lines of code, self-made TX to MySQL software!
- Analysis report on the investment market of the development planning prospect of the recommended rare earth industry research industry in 2022 (the attachment is a link to the online disk, and the rep
- 2022 recommended property management industry research report industry development prospect market investment analysis (the attachment is the link to the online disk, and the report is continuously up
- [C language series] - branch and loop statements
- How to choose congestion model and anemia model
- DataX connection MySQL cannot find driver
- [CV] wuenda machine learning course notes Chapter 13
- Top ten Devops best practices worthy of attention in 2022
- Service grid ASM year end summary: how do end users use the service grid?
猜你喜欢

Hyperledger Fabric 2. X custom smart contract

Use of sed in shell script

Research on heuristic intelligent task scheduling

CCTV revealed that xumengtao won the black Technology: there was a virtual coach???

The fresh student who was born in Ali after 2000: it's really fragrant to mend this

How to choose congestion model and anemia model

Open source demo| you draw and I guess -- make your life more interesting

5,10,15,20-tetra (3,5-dimethoxyphenyl) porphyrin ((tdmpp) H2) /2-nitro-5,10,15,20-tetra (3,5-dimethoxyphenyl) porphyrin copper (no2tdmpp) Cu) supplied by Qiyue

Parsing rshub document auto generation API

2,5-di (3,4-dicarboxyphenoxy) - 4 '- phenylethynylbiphenyldianhydride (pephqda) / Qiyue custom supply porphyrin modified amphiphilic block copolymer peg113-pcl46-porphyrin
随机推荐
Skills of writing test cases efficiently
CodeIgniter active record not equal - CodeIgniter active record not equal
嵌入式RTOS
Top ten Devops best practices worthy of attention in 2022
Use some examples of qte5
[C language series] - branch and loop statements
D Author: import C programming in D
ES6 Modularization: export /import
Multiline regular expression search in Visual Studio code - multiline regular expression search in Visual Studio code
Jenkins operation Chapter 6 mail server sending build results
51 single chip microcomputer learning notes 7 -- Ultrasonic Ranging
HTTP Caching Protocol practice
Test content
RTOS embarqués
How to hand over complex legacy systems?
CCTV revealed that xumengtao won the black Technology: there was a virtual coach???
The easiest GUI to compile: dgui
Slot
5000+ word interpretation | Product Manager: how to do a good job in component selection?
Research Report on the new energy industry of recommended power equipment in 2022 industry development prospect market investment analysis (the attachment is a link to the network disk, and the report