Google Maps v3 InfoWindow Too Wide

给你一囗甜甜゛ 提交于 2019-12-23 12:12:51

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/2703210/google-maps-v3-infowindow-too-wide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!