我的Primefaces版本为3.0.M3有问题.我使用了gmap和prime p:ajax.我想做点什么就是当Gmap上的用户点击标记时点击Marker.
这是守则
<p:tabView effect="slide" effectDuration="normal" style="width:1050px;height:450px" >
<p:tab title="blabla">
<h:panelGrid colums="1">
</h:panelGrid>
</p:tab>
<p:tab title="blabla" >
<h:panelGrid colums="1">
<h:form id="mapId">
<p:gmap id="asd" center="39.000409,35.201554"
zoom="#{mapBean.modelMap.zoomLevel}"
type="ROADMAP"
style="width:1000px;height:400px"
model="#{mapBean.emptyModel}"
widgetVar="map" >
<p:ajax event="overlaySelect" listener="#{mapBean.onMarkerSelect}"/>
</p:gmap>
</h:form>
</h:panelGrid>
</p:tab></p:tabView>
Run Code Online (Sandbox Code Playgroud)
和我的ManagedBean
public void onMarkerSelect(OverlaySelectEvent event) {
Marker marker = (Marker) event.getOverlay();
if (marker!=null) {
System.out.println(marker.getId());
}
System.out.println("Clicked");
modelMap.setZoomLevel(modelMap.getZoomLevel()+1);
}
Run Code Online (Sandbox Code Playgroud)
托管Bean声明
@ManagedBean(name="mapBean")
@RequestScoped
public class MapBean implements Serializable
Run Code Online (Sandbox Code Playgroud)
我采取NullPointerException的onMarkerSelect方法.( event.getOverlay();)
我试图用新的纬度,经度帮助更新PrimeFaces的谷歌地图p:ajax,但它不起作用......我正在使用JSF 2.0.我p:ajax早先以类似的方式使用它,它工作得很漂亮.知道为什么这不起作用吗?以下是代码,contForm是表单的id.
<h:outputText value="Latitude :"/>
<h:inputText value="#{confirmBrandRegistration.newBrand.mapLatitude}" size="10">
<p:ajax event="blur" update="contForm:gMapID"/>
</h:inputText>
<h:outputText value=" Longitude :"/>
<h:inputText value="#{confirmBrandRegistration.newBrand.mapLongitude}" size="10" >
<p:ajax event="blur" update="contForm:gMapID"/>
</h:inputText>
<h:outputText value=" Marker :"/>
<h:inputText value="#{confirmBrandRegistration.newBrand.mapMarker}" size="20" >
<p:ajax event="blur" update="contForm:gMapID"
listener="#{confirmBrandRegistration.updateMarker}"/>
</h:inputText>
</h:panelGrid>
<p:outputPanel id="gMapID">
<f:view contentType="text/html">
<p:gmap center="#{confirmBrandRegistration.newBrand.mapLatitude}, #{confirmBrandRegistration.newBrand.mapLongitude}"
zoom="16" type="HYBRID" streetView="true"
model="#{confirmBrandRegistration.simpleModel}"
style="width:500px;height:400px" />
</f:view>
</p:outputPanel>
Run Code Online (Sandbox Code Playgroud)