QWebEngineView load baidu map failed
Unsolved
QtWebEngine
-
I use the demo of baiduMap's JS API(V2),and the html work in Edge;
But it do not work in QWebEngineView,and log these"file:///D:/LocalProject/Qt/baiduMap/map/baiduMap_demo.html" [22876:24104:0525/184414.800:WARNING:render_frame_host_impl.cc(901)] InterfaceRequest was dropped, the document is no longer active: blink.mojom.PermissionService [22876:24104:0525/184414.800:WARNING:render_frame_host_impl.cc(901)] InterfaceRequest was dropped, the document is no longer active: blink.mojom.PermissionService js: Uncaught ReferenceError: BMap is not defined
I don' know why
BMap is not defined
see the body of html<body> <div id='allmap'></div> <div id='result'> 经度: <input id="lng" type="text" /> 纬度: <input id="lat" type="text" /> <button onclick="theLocation()">查询</button> </div> <script> // 百度地图API功能-BMap-V2.0 var map = new BMap.Map("allmap"); map.centerAndZoom(new BMap.Point(116.331398, 39.897445), 11); map.enableScrollWheelZoom(true); // 用经纬度设置地图中心点 function theLocation() { if (document.getElementById("lng").value != "" && document.getElementById("lat").value != "") { map.clearOverlays(); var new_point = new BMap.Point(document.getElementById("lng").value, document.getElementById("lat").value); var marker = new BMap.Marker(new_point); // 创建标注 map.addOverlay(marker); // 将标注添加到地图中 map.panTo(new_point); } } </script> </body>
and my QT codes
void MainWindow::on_pushButton_2_clicked() { QString mappath; mappath = exepath + "map/baiduMap_demo.html"; qDebug()<<mappath; m_view->load(QUrl(mappath)); m_view->show(); }
otherwise, 'm_view'can load and show ‘https://www.bilibili.com/’.
-
@k423 said in QWebEngineView load baidu map failed:
js: Uncaught ReferenceError: BMap is not defined
BMap is from Baidu map SDK, you should import Baidu SDK first.
from here: https://github.com/huiyan-fe/react-bmap/issues/4