Bläddra i källkod

change ui_ads_hmi. change for use google map.

yuchuli 3 veckor sedan
förälder
incheckning
3332db78ec
2 ändrade filer med 21 tillägg och 1 borttagningar
  1. 19 1
      src/ui/ui_ads_hmi/ADCIntelligentVehicle.cpp
  2. 2 0
      src/ui/ui_ads_hmi/ui_ads_hmi.pro

+ 19 - 1
src/ui/ui_ads_hmi/ADCIntelligentVehicle.cpp

@@ -289,7 +289,12 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
 
         mMapview = new QWebEngineView(ui->stackedWidget->widget(1));
         //    qDebug((QDir::currentPath()).toLatin1().data());
+#ifndef USEGOOGLEMAP
         mMapview->load(QUrl(QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("BaiDuMap.html")));
+#else
+        mMapview->setUrl(QUrl("https://www.google.com/maps"));
+//        mMapview->load(QUrl(QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("googlemap.html")));
+#endif
         mMapview->setGeometry(1000,100,500,500);
     }
     /********************************************************************************/
@@ -966,9 +971,22 @@ void ADCIntelligentVehicle::onStateTimerMap()
         double flon = ServiceCarStatus.location->gps_lng;
         double fang = ServiceCarStatus.location->ins_heading_angle;
 
-        char strscript[256];
+        char strscript[1000];
         snprintf(strscript,255,"theLocation(%11.7f,%11.7f,%11.7f);",flon,flat,fang);
+#ifndef USEGOOGLEMAP
+        mMapview->page()->runJavaScript(strscript);
+#else
+
+        snprintf(strscript,1000,"var latLng = new google.maps.LatLng(%11.7f,%11.7f);"
+                               "var mapOptions = { center: latLng, zoom: 13 };"
+                               "new google.maps.Map(document.getElementById('map'), mapOptions);",flon,flat);
         mMapview->page()->runJavaScript(strscript);
+//        QString js = QString("var latLng = new google.maps.LatLng(40.758896, -73.985130);"
+//                                      "var mapOptions = { center: latLng, zoom: 13 };"
+//                                      "new google.maps.Map(document.getElementById('map'), mapOptions);");
+ //       mMapview->page()->runJavaScript(js);
+
+#endif
     }
     /************************************************************************/
 }

+ 2 - 0
src/ui/ui_ads_hmi/ui_ads_hmi.pro

@@ -118,3 +118,5 @@ LIBS += -livprotoif
 
 
 TRANSLATIONS = ui_ads_hmi_language.ts
+
+#DEFINES += USEGOOGLEMAP