简体   繁体   English

单击Google Maps API v3中的信息窗口后,奇怪的缩放控件

[英]Weird zoom controls after clicking infowindow in google maps api v3

I'm getting weird Zoom controls after clicking an infowindow on Google Maps API v3. 单击Google Maps API v3上的信息窗口后,我得到了奇怪的Zoom控件。 See image via link below. 通过下面的链接查看图片。

Can anybody help me with why this is happening? 有人可以帮我解决为什么会这样吗? It seems to happen when I display the map in a webview in an Android app, but not when using Firefox. 当我在Android应用程序的Web视图中显示地图时似乎发生了这种情况,但在使用Firefox时却没有发生。

An example of this can be found here: http://www.last-orders.net/shot_2014-03-25_19-23-44.png 可以在这里找到一个示例: http : //www.last-orders.net/shot_2014-03-25_19-23-44.png

My code is as follows: 我的代码如下:

function initialize() {
 var myLatlng = new google.maps.LatLng(mylat[0],mylng[0]);

   var mapOptions = {
   zoom: 14,
   center: myLatlng,
   disableDefaultUI: true,
   zoomControl: true

   }


  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

  var infoWindows = [];
  var myicon = [];
  var marker = [];


  for(var i = 0; i < mytitle.length; i++)
  {


      var myiconX = {
    url: "https://chart.googleapis.com/chart?chst=d_map_pin_icon&chld=beer" + "|" + mycol[i] + "|000000"
      };


      var myplaceX = new google.maps.LatLng(mylat[i],mylng[i]);
      var markerX = new google.maps.Marker({
          position: myplaceX,
          map: map,
          icon: myiconX,
          title: mytitle[i],
          infoWindowIndex : i  
      });

        var contentString = '<div id="content">' + mytitle[i] + '</div>';

        var infoWindow = new google.maps.InfoWindow({
            content : contentString

        });

        google.maps.event.addListener(markerX, 'click', 
            function(event)
            {
                infoWindows[this.infoWindowIndex].open(map, this);
            }
        );

        infoWindows.push(infoWindow);

        marker.push(markerX); 





   }


   myicon[0] = "http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=glyphish_walk|33CCFF|000000";



   marker[0] = new google.maps.Marker({
   position: myLatlng,
   map: map,
   icon: myicon[0],
   title: mytitle[0]
   });





   var bounds = new google.maps.LatLngBounds();

   for (var i=0; i < marker.length; i++) {

     if (marker[i] == null) {

      }
     else
      {
         bounds.extend(marker[i].getPosition());
      }

    }

    map.fitBounds(bounds);


}





google.maps.event.addDomListener(window, 'load', initialize);

Are you by any chance using Bootstrap? 您是否有机会使用Bootstrap? Or viewing on a retina display? 还是在视网膜显示器上观看? Recently bootstrap interfered with Google Maps on a site I was building, removing the bootstrap css fixed the issue. 最近,引导程序干扰了我正在构建的网站上的Google Maps,删除了引导程序CSS即可解决此问题。 It only happened on retina screens. 它仅在视网膜屏幕上发生。 I think the fix I made into bootstrap's CSS file was really simple. 我认为我对bootstrap的CSS文件所做的修复非常简单。

Found a solution to this. 找到了解决方案。 For the the InfoWindow.content use the string: 对于InfoWindow.content,请使用以下字符串:

'<div><h3>'+ text + '</h3></div>'

Where text is the content to show in the InfoWindow. 文本是要在InfoWindow中显示的内容。 Somehow this resolved the problem of the weird Zoom Controls which I was seeing only on Kindle Fire devices. 某种程度上,这解决了我仅在Kindle Fire设备上看到的奇怪的Zoom Controls问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM