[英]PrimeFaces gmap not rendering
Using PrimeFaces 2.2.RC2 in a JSF 2.0 project. 在JSF 2.0项目中使用PrimeFaces 2.2.RC2。
I'm trying to get a basic Google Map to render with the gmap component. 我正在尝试使用gmap组件来渲染基本的Google Map。 No errors show up just blank page where the map should be.
没有错误只显示地图所在的空白页面。
My .xhtml file 我的.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>
Not had any issues getting other PrimeFaces components to render in this project and the example on the PrimeFaces website renders in my browser just fine. 没有任何问题让其他PrimeFaces组件在这个项目中呈现,PrimeFaces网站上的示例在我的浏览器中渲染就好了。
Any ideas ? 有任何想法吗 ?
Update: 更新:
I changed the view tag to <f:view contentType="text/html">
, now I get a grey box where the map should be and when I hover over the box the curser turns to white hand to grab and move the map around, but still no map shows. 我将视图标记更改为
<f:view contentType="text/html">
,现在我得到一个灰色框,地图应该是,当我将鼠标悬停在框上时,光标变为白色手以抓住并移动地图,但仍然没有地图显示。
您需要将此脚本添加到您的页面:
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript" ></script>
<f:view contentType="text/html">
is needed for it to work in Safari/Chrome <f:view contentType="text/html">
才能在Safari / Chrome中使用
My other problem was HYBRID was spelled wrong, the following works: 我的另一个问题是HYBRID拼写错误,以下工作原理:
<h1>Google Map 1</h1>
<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID"
style="width:600px;height:400px" />
Spelling was never my strong suit. 拼写从来都不是我的强项。
This works for me 这适合我
<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>
In recent times, you are supposed to provide a KEY https://stackoverflow.com/a/38248059/651288 最近,你应该提供一个KEY https://stackoverflow.com/a/38248059/651288
otherwise you get a Google Maps API error: MissingKeyMapError 否则您会收到Google Maps API错误:MissingKeyMapError
You can get a key here https://developers.google.com/maps/documentation/javascript/get-api-key 您可以在此处获取密钥https://developers.google.com/maps/documentation/javascript/get-api-key
Try this: 尝试这个:
<h:form>
<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID"
style="width:600px;height:400px" streetView="true"/>
</h:form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.