2011-01-21 109 views
10

在JSF 2.0项目中使用PrimeFaces 2.2.RC2。PrimeFaces gmap not rendering

我想要获得一个基本的Google Map来使用gmap组件进行渲染。没有错误只显示地图应该在的空白页面。

我.xhtml文件

<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<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.prime.com.tr/ui"> 

    <h:head> 
     <script src="http://maps.google.com/maps/api/js?sensor=false" 
       type="text/javascript"></script> 
    </h:head> 
    <h:body> 
     <f:view contentType="text/html"> 
      <h1>Google Map</h1> 
      <p:gmap center="41.381542, 2.122893" zoom="15" type="HYBIRD" 
        style="width:600px;height:400px" /> 
     </f:view> 
    </h:body> 
</html> 

没有让其他PrimeFaces组件在这个项目呈现任何问题上PrimeFaces网站呈现在我的浏览器就好了example

任何想法?

更新:

我改变了看法标签<f:view contentType="text/html">,现在我得到一个灰色的框,地图应该是,当我将鼠标悬停在框中光标变成白色手抓住并移动地图周围,​​但仍然没有地图显示。

alt text

回答

5

<f:view contentType="text/html">需要为它在Safari /铬工作

我的另一个问题是HYBRID被拼写错了,下面的工作:

<h1>Google Map 1</h1> 
<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID" 
    style="width:600px;height:400px" /> 

拼写从来不是我的强项。

0

试试这个:

<h:form> 
<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID"  
style="width:600px;height:400px" streetView="true"/> 
</h:form> 
26

您需要将这个脚本添加到您网页:

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript" ></script> 
+0

你救了我的一天! – Sarz 2014-12-12 12:09:30

+0

就像一个笔记。传感器参数不再需要。 请参阅:http://stackoverflow.com/questions/8616764/what-is-the-sensor-parameter-in-google-places-api-good-for – Koekiebox 2016-01-15 19:42:44

2

这对我的作品

<h:head> 
    <script src="http://maps.google.com/maps/api/js?sensor=false" 
      type="text/javascript"></script> 
</h:head> 
<h:body> 
    <f:view contentType="text/html"> 
     <h1>Google Map</h1> 
     <p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID" style="width:600px;height:400px" /> 
    </f:view> 
</h:body>