我成功用html文件创建了一个Google地图,并使用QWebView和show函数将其称为simpy。 但是现在我有了一个桌面应用程序,我想在其中显示地图标签并根据客户地址添加一些标记。但是,当我尝试创建布局并添加我的qwebview时,我仅得到一个空白窗口,并且地图位于其自己的窗口之外(并且地图停止刷新。)我的目标是将地图添加到应用程序的选项卡中。在这里,用于创建地图的html代码来自一个Google示例:
const receipts = expo.sendPushNotificationsAsync([
{
to: userObj.pushToken,
sound: 'default',
body: notification,
data: { withSome: notification },
priority: 'high',
},
]);
我想这与div和样式有关,但我没有找到。我尝试删除它或只返回地图,但仍然有一个空白的窗口:(。然后在python中创建选项卡和我的地图:
<!DOCTYPE html>
<html>
<head>
<title>Geocoding Service</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#floating-panel {
position: absolute;
top: 10px;
left: 25%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
var geocoder;
function initMap() {
console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: {lat: -34.397, lng: 150.644}
});
geocoder = new google.maps.Geocoder();
}
function addMarker(adressClient) {
console.log( typeof adressClient)
console.log( adressClient)
geocoder.geocode({'address': adressClient}, function(results, status) {
if (status === 'OK') {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
}
else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=keyapi&callback=initMap">
</script>
</body>
</html>
我没有找到一种方法来创建地图并将Web视图嵌入到我的布局中。我读了一些有关kml的文章,但是我没有发现这是否是解决我的问题的好方法。