Only white color with zoom control shown in google

2019-07-07 19:02发布

I try to embed a map in my desktop application by using CHtmlView::Navigate2 method to browse local webpage which is a simple google-maps sample html. The html file source as the following.

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <meta name="viewport" content="initial-scale=1.0">
  <meta charset="utf-8">
  <style>
    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
    }
    #map {
      height: 100%;
    }
  </style>
</head>
<body>
<div id="map"></div>
<script>

var map;
function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
  center: {lat: -34.397, lng: 150.644},
  zoom: 8
  });
}

</script>
<script src="https://maps.googleapis.com/maps/api/js?callback=initMap"
  async defer></script>
</body>
</html>

The html file with google-maps JavaScript API simple map sample was displayed properly with Internet Explorer but only white color map with vaild zoom control in my CHtmlView window. And I observe that if quickly zoom in/out the map in my test application sometimes the map show up then disappear immediately.

2条回答
爷、活的狠高调
2楼-- · 2019-07-07 19:33

After all-day digging to the issue...
Finally I figure out the root cause might be the IE version applied to the embed MS Web Browser Control. First of all, I have caught related information from Google Map API official community support channel.

Discontinue support of Internet Explorer 8
We would like to inform you that we are planning to discontinue support of Internet Explorer 8 (IE8) for the Google Maps JavaScript API v3 around August 31st 2015.

And then I googled to a related page which mentions how to specify IE version of MS Web Browser Control.(Rick Strahl's Web Blog)

Eventually, I solved my problem by applying Registry Hacks from above link^^
Wish this digging journey is helpful for someone encountered the same problem, Good luck.

查看更多
狗以群分
3楼-- · 2019-07-07 19:34

As the answer of @Akabrando, adding a registry key of FEATURE_BROWSER_EMULATION can solve the script error of google map. There is another way to solve IE compatible issue, add a meta tag in your webpage:

<meta http-equiv="x-ua-compatible" content="IE=11">
查看更多
登录 后发表回答