2013-02-28 44 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>