2013-02-28 47 views
0

我正面临使用gmap组件的一个小问题:当我尝试制作组件大小调整(即,在CSS的帮助下将地图的高度和宽度都设置为100%)时,组件将缩小并映射本身变得不可见。但是如果设置了固定的高度/宽度,那么组件工作正常。有没有办法为gmap自动调整大小?Primefaces'gmaps autoresize

+0

请分享您的代码。 – Ankit 2013-02-28 17:58:04

回答

0

只是一个快速的想法。您正在将大小应用于实际的#map或#map_content(或其他),而不是地图本身?

如果只是大小的地图,并没有包含分区,那么0 100%还是0

0

这个问题可能是与CSS样式。如果有人仍有意解决这个问题下面的代码工作对我来说:

CSS:

html, body, form { 
    height: 100%; 
    margin: 0; 
} 

.mapClass { 
    width: 100%; 
    height: 100%; 

}

XHTML:

<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:h="http://java.sun.com/jsf/html" 
xmlns:f="http://java.sun.com/jsf/core" 
xmlns:ui="http://java.sun.com/jsf/facelets" 
xmlns:p="http://primefaces.org/ui"> 

<h:head> 
    <link href="./resources/css/style.css" rel="stylesheet" type="text/css" /> 
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> 
</h:head> 
<h:body> 
    <h:form> 
     <p:gmap widgetVar="gmtls" center="41.381542, 2.122893" zoom="15" type="hybrid" styleClass="mapClass"/> 
    </h:form> 
</h:body> 
</html>