2013-10-25 90 views
0

我有下面的代碼來顯示googlemap使用primefaces。這不是渲染地圖。但是,如果我設置style =「width:600px; height:400px」,它工作正常。如何在瀏覽器中獲得地圖的完整頁面視圖?Primefaces googlemap不渲染

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html> 
<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:p="http://primefaces.org/ui"> 
<h:head> 
    <script src="http://maps.google.com/maps/api/js?sensor=false&amp;v=3.4" type="text/javascript"></script>   
</h:head> 
    <h:body> 
     <f:view contentType="text/html"> 
      <h:form> 
       <p:gmap center="#{loadBean.centerLatitude},#{loadBean.centerLongitude}" style="width:100%;height:100%" zoom="3" type="HYBRID"/> 
      </h:form> 
     </f:view> 
    </h:body> 
</html> 
+0

查找範圍爲線索瀏覽器的JavaScript控制檯 – kolossus

回答

0

有2種方式:

只需設置絕對位置映射:

<p:gmap tyle="width:100%;height:100%;position:absolute" center="#{loadBean.centerLatitude},#{loadBean.centerLongitude}" zoom="3" type="HYBRID"/> 

您還可以設置寬度和高度的所有的家長地圖。

地址:

<style type="text/css"> 
html, body { 
width:100%; 
height:100%; 
} 
</style> 

修改您的<h:form>

<h:form style="width:100%;height:100%"> 
. . . 
</h:form> 
0

這似乎是真實的風格= 「寬度:100%;高度:100%」 不渲染地圖。我試了一下,空白頁來了。 但是,您需要平衡頁面高度。下面呈現的頁面的全寬和高爲980像素的地圖,幾乎覆蓋整個網頁。

<p:gmap id="gmap" center="36.885233, 30.702323" zoom="13" type="MAP" style="width:100%;height:980px" model="#{addMarkersView.polyLineModel}" 
       onPointClick="handlePointClick(event);" widgetVar="map" > 
      <p:ajax event="overlaySelect" listener="#{addMarkersView.onPolylineSelect}" update="growl"/> 
     </p:gmap> 

enter image description here