0

我在使用gmap组件时遇到了一个小问题:当我尝试使组件可调整大小(即借助 CSS 将地图的高度和宽度都设置为 100%)时,组件会缩小并且地图本身变得不可见。但是,如果设置了固定高度/宽度,则组件可以正常工作。有没有办法为gmap自动调整大小?

4

2 回答 2

0

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

如果您只是调整地图的大小而不是包含的 div,那么 0 的 100% 仍然是 0

于 2013-02-28T23:46:30.013 回答
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>
于 2013-05-13T11:24:58.363 回答