百度地图api,使用QT同时绘制多个标注

2021-02-07 10:14

阅读:493

YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

标签:EAP   utf-8   ring   focus   font   运行   web   map   navig   

myMap.html     文件内容:

城市名定位
经度: 纬度:

qt构造函数内代码:

qApp->setApplicationName("padcollectionclient");

    QString sFilePath = QCoreApplication::applicationDirPath();
    sFilePath += "/my.html";

    ui->lineEdit->setText(sFilePath);
    //connect(ui->lineEdit,SIGNAL(returnPressed()),this,SLOT(loadNavigate()));

    //设置ActiveX控件为IEMicrosoft Web Browser
    //设置ActiveX控件的id,最有效的方式就是使用UUID
    //此处的{8856F961-340A-11D0-A96B-00C04FD705A2}就是Microsoft Web Browser控件的UUID
    ui->axWidget->setControl(QString::fromUtf8("{8856F961-340A-11D0-A96B-00C04FD705A2}"));
    //ui->axWidget->setObjectName(QString::fromUtf8("webWidget"));//设置控件的名称
    //ui->axWidget->setFocusPolicy(Qt::StrongFocus);//设置控件接收键盘焦点的方式:鼠标单击、Tab键
    //ui->axWidget->setProperty("DisplayAlerts",false); //不显示任何警告信息。
    //ui->axWidget->setProperty("DisplayScrollBars",true); // 显示滚动条

    loadNavigate();

loadNavigate() :

QString Utr = ui->lineEdit->text().trimmed();
ui->axWidget->dynamicCall("Navigate(const QString&)",Utr);

on_pushButton_clicked()  :

QString str = "send()";
QAxObject *document = ui->axWidget->querySubObject("Document");
QAxObject *parentWindow = document->querySubObject("parentWindow");
parentWindow->dynamicCall("execScript(QString,QString)",str,"JavaScript");


// 1
QString x = ui->lineEdit_2->text();
double xx = x.toDouble();
QString y = ui->lineEdit_3->text();
double yy = y.toDouble();

// 2
QString x_2 = ui->lineEdit_4->text();
double xx_2 = x_2.toDouble();
QString y_2 = ui->lineEdit_5->text();
double yy_2 = y_2.toDouble();

// 3
QString x_3 = ui->lineEdit_6->text();
double xx_3 = x_3.toDouble();
QString y_3 = ui->lineEdit_7->text();
double yy_3 = y_3.toDouble();

// 3
QString x_4 = ui->lineEdit_8->text();
double xx_4 = x_4.toDouble(); QString y_4 = ui->lineEdit_9->text(); double yy_4 = y_4.toDouble(); double lon[4], lat[4]; lon[0] = xx; lon[1] = xx_2; lon[2] = xx_3; lon[3] = xx_4; lat[0] = yy; lat[1] = yy_2; lat[2] = yy_3; lat[3] = yy_4; qDebug() "x :" " " "y :" endl "x :" " " "y :" endl "x :" " " "y :" endl "x :" " " "y :" endl; for (int i = 0; i 4; i++) { QString command = QString("addpoint(%1,%2)").arg(QString::number(lon[i], f, 6)).arg(QString::number(lat[i], f, 6)); QAxObject *document = ui->axWidget->querySubObject("Document"); QAxObject *parentWindow = document->querySubObject("parentWindow"); parentWindow->dynamicCall("execScript(QString,QString)",command,"JavaScript"); }

运行后:

 

技术图片

百度地图api,使用QT同时绘制多个标注

标签:EAP   utf-8   ring   focus   font   运行   web   map   navig   

原文地址:https://www.cnblogs.com/ruandahua/p/11388163.html


评论


亲,登录后才可以留言!