我正在使用Google图书馆时间在地图上显示它。
我遇到的问题是显示的第一个窗口非常小,你必须滚动。 如何控制此窗口的大小?
其次,我只想显示我给出的坐标的地图,并告诉我我想要的最少时间。我该怎么做?
这是我在here中的代码:
function generartiempo(36.745,-3.87665,'mapatiempo') {
var mapOptions = {
zoom: 11,
center: new google.maps.LatLng(lat,lng,true),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infowindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById('mapatiempo'),
mapOptions);
var weatherLayer = new google.maps.weather.WeatherLayer({
temperatureUnits: google.maps.weather.TemperatureUnit.CELSIUS,
windSpeedUnit: google.maps.weather.WindSpeedUnit.KILOMETERS_PER_HOUR
});
weatherLayer.setMap(weatherLayer.getMap() ? null : map);
var cloudLayer = new google.maps.weather.CloudLayer();
cloudLayer.setMap(map);
}
<div id="mapatiempo"></div>
#mapatiempo {
width: 268px;
height: 200px;
border: 1px solid #AAAAA8;
margin-bottom: 5px;
margin-top: 15px;
}
有人可以帮忙吗? 编辑示例:http://jsfiddle.net/webyseo/YW2K7/12/ 解? 感谢!!!!!
答案 0 :(得分:0)
没有选项来定义默认infoWindow的大小。此外,infoWindow的大小受地图大小的限制,它不能更大,所以你需要放大地图。
你可以做什么:用自定义的infoWindow覆盖默认的infoWindow并自己定义内容,以便它适合更小的infoWindow
自定义infoWindow的示例代码:(假设包含google.maps.Map
的变量)
//create the weatherLayer
var weatherLayer = new google.maps.weather.WeatherLayer({
temperatureUnits: google.maps.weather.TemperatureUnit.FAHRENHEIT,
clickable:true,
suppressInfoWindows:true
});
//create InfoWondow-instance
var weatherWindow=new google.maps.InfoWindow();
//observe click-event
google.maps.event.addListener(weatherLayer,'click',function(e){
//hide infoindow
weatherWindow.close();
var content = document.createElement('ul'),
weather = e.featureDetails.forecast,
unit = '°'+e.featureDetails.temperatureUnit.toUpperCase();
//merge current weather and forecast
weather.push(e.featureDetails.current);
//create some content(here a short summary)
for(var i = 0; i<weather.length; ++i){
var item = content.appendChild(document.createElement('li'))
.appendChild(document.createTextNode(''))
w = weather[i];
item.data='['+w.shortDay+']'+w.description+
'('+w.low+unit+'/'+w.high+unit+')';
}
//set content and position of the infoWindow
weatherWindow.setOptions({position:e.latLng,content:content});
//...and open the infowindow
weatherWindow.open(map);
});
weatherLayer.setMap(map);