PrimeFaces gmap无法渲染

Mar*_*ark 10 jsf google-maps primefaces

在JSF 2.0项目中使用PrimeFaces 2.2.RC2.

我正在尝试使用gmap组件来渲染基本的Google Map.没有错误只显示地图所在的空白页面.

我的.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>
Run Code Online (Sandbox Code Playgroud)

没有任何问题让其他PrimeFaces组件在这个项目中呈现,PrimeFaces网站上的示例在我的浏览器中渲染就好了.

有任何想法吗 ?

更新:

我将视图标记更改为<f:view contentType="text/html">,现在我得到一个灰色框,地图应该是,当我将鼠标悬停在框上时,光标变为白色手以抓住并移动地图,但仍然没有地图显示.

替代文字

小智 28

您需要将此脚本添加到您的页面:

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript" ></script>
Run Code Online (Sandbox Code Playgroud)


Mar*_*ark 5

<f:view contentType="text/html"> 它需要在Safari/Chrome中运行

我的另一个问题是HYBRID拼写错误,以下工作原理:

<h1>Google Map 1</h1>
<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID"
  style="width:600px;height:400px" />
Run Code Online (Sandbox Code Playgroud)

拼写从来都不是我的强项.