Google Maps v3 InfoWindow太宽 [英] Google Maps v3 InfoWindow Too Wide

查看:113
本文介绍了Google Maps v3 InfoWindow太宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google Maps v3中,我似乎无法让infoWindow的宽度小于200像素。这里是我使用的代码:

  var latlng = new google.maps.LatLng(-34.397,150.644); 
var myOptions = {
zoom:15,
center:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var myMap = new google.maps.Map(document.getElementById(map_canvas),myOptions);
var gmarker = new google.maps.Marker({position:latLng,title:'Example'});
var infoWindow = new google.maps.InfoWindow();
infoWindow.setOptions({maxWidth:110});
window_content ='< div style =width:110px; height:110px;> Test< / div>';
infoWindow.setContent(window_content);
infoWindow.open(myMap,gmarker);

有没有办法让infoWindow更窄?或者我坚持最小宽度?

解决方案

如果您使用的是默认值,那么是的,您会被卡住。

您可能会考虑使用名为infoBox的自定义infoWindow。您可以在这里查看我的其中一个沙箱: http://www.dougglover.com/samples /UOITMap/index.html



在maps.js中,您应该可以阅读并理解infoBox的所需内容并实现它为您自己的工作。



这使您可以完全控制窗口的外观。

更新:对不起,我最初提供的链接确实已经死了。在这里查看信息框的信息: http ://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html


In Google Maps v3, I can't seem to get my infoWindow to a width smaller than 200px. Here is the code I'm using:

var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
    zoom: 15,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
var myMap = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var gmarker = new google.maps.Marker({position: latLng,title:'Example'} );
var infoWindow = new google.maps.InfoWindow();
infoWindow.setOptions({maxWidth: 110});
window_content = '<div style="width:110px;height:110px;">Test</div>';
infoWindow.setContent(window_content);
infoWindow.open(myMap, gmarker);

Is there a way to get the infoWindow more narrow? Or am I stuck with a minimum width?

解决方案

If you're using the default, then yes, you're fairly stuck.

You might consider using a custom infoWindow, called an infoBox. You can view one of my sandboxes here: http://www.dougglover.com/samples/UOITMap/index.html

In the maps.js, you should be able to read through and take what you need of the infoBox stuff and implement it for your own work.

This gives you FULL control over the way that your windows look.

UPDATE: Sorry, link I originally supplied is indeed dead. View here for information on infobox: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html

这篇关于Google Maps v3 InfoWindow太宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆