Jsf 2 尝试在JSF中显示带有gmap对象的地图
我正在使用JSF2,我想用对象gmap显示一个地图。正如我看到的,gmap对象在richfaces 4.x中不再存在,所以我尝试导入gmap4jsf.jar来渲染我的地图 为了获得一个示例,我从Richfaces演示中获取了部分代码: 地图显示得很好,但是如果我想用rich:面板中的jsf元素控制它(更改类型、缩放等等),我会在Firebug中得到一个错误:“地图未定义”。。。 有人能帮我找出这个问题吗,因为我没有在其他线程中找到答案。。。 这是我的密码:Jsf 2 尝试在JSF中显示带有gmap对象的地图,jsf-2,Jsf 2,我正在使用JSF2,我想用对象gmap显示一个地图。正如我看到的,gmap对象在richfaces 4.x中不再存在,所以我尝试导入gmap4jsf.jar来渲染我的地图 为了获得一个示例,我从Richfaces演示中获取了部分代码: 地图显示得很好,但是如果我想用rich:面板中的jsf元素控制它(更改类型、缩放等等),我会在Firebug中得到一个错误:“地图未定义”。。。 有人能帮我找出这个问题吗,因为我没有在其他线程中找到答案。。。 这是我的密码: <!DOCTYPE html P
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:m="http://code.google.com/p/gmaps4jsf/"><h:head><title>JSF 2.0: Ajax Support</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=myPersonnalKeyIsWrittenHere"></script>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.7.1.js"></script>
<style>.optionList {height: 30px;}</style></h:head><h:body>
<div id="container">
<ui:include src="tpl/menu.xhtml" />
<h1>Gmap4Jsf</h1>
<div align="center">
<f:view contentType="text/html">
<h:panelGrid columns="2">
<h:form id="mapform" prependId="false">
<m:map var="map" mapVar="map" gmapKey="#{gmapBean.gmapkey}" id="map" />
</h:form>
<h:panelGroup>
<h:form>
<rich:tabPanel switchType="ajax" width="350" height="400">
<rich:tab label="Using Google Map API">
<h:panelGrid columns="2" columnClasses="optionList">
<h:outputText value="Controls:" />
<h:panelGroup>
<a href="javascript: void 0" onclick="map.hideControls()">Hide</a>
<a href="javascript: void 0" onclick="map.showControls()">Show</a>
<br />
</h:panelGroup>
<h:outputText value="Zoom:" />
<rich:inputNumberSlider id="zoom" showInput="false"
minValue="1" maxValue="18" value="#{gmapBean.zoom}"
onchange="map.setZoom(this.value)" />
<h:outputText value="Map Type:" />
<h:panelGroup>
<a href="javascript: void 0"
onclick="map.setMapType(G_NORMAL_MAP)">Normal</a>
<a href="javascript: void 0"
onclick="map.setMapType(G_SATELLITE_MAP)">Satellite</a>
<a href="javascript: void 0"
onclick="map.setMapType(G_HYBRID_MAP)">Hybrid</a>
<br />
</h:panelGroup>
</h:panelGrid>
</rich:tab>
<rich:tab label="Using Ajax with JSON">
<rich:dataGrid var="place" value="#{gmapBean.point}"
columns="2">
<h:graphicImage onclick="showPlace('#{place.id}')"
style="cursor:pointer" value="resource://#{place.pic}" />
</rich:dataGrid>
</rich:tab>
</rich:tabPanel>
</h:form>
</h:panelGroup>
</h:panelGrid>
</f:view>
</div>
</div>
jsf2.0:Ajax支持
.optionList{高度:30px;}
Gmap4Jsf
好的,我找到了 我必须定义JSF生成的Javascript变量的名称。 所以,我只是将attribute“jsVariable”添加到我的gmap元素中
<m:map jsVariable="map" var="map" mapVar="map" gmapKey="#{gmapBean.gmapkey}" id="map" />
再见好的,我找到了
我必须定义JSF生成的Javascript变量的名称。
所以,我只是将attribute“jsVariable”添加到我的gmap元素中
<m:map jsVariable="map" var="map" mapVar="map" gmapKey="#{gmapBean.gmapkey}" id="map" />
再见