简体   繁体   English

Primefaces GMap OverlaySelect事件,并在单击时弹出输出面板

[英]Primefaces GMap OverlaySelect event and poping up an output panel while clicking

I've a probleme in primeface 4. I have a map and I want to see an output panel while clicking on a marked position in the map 我在primeface 4中遇到问题。我有一张地图,我想在单击地图上标记的位置时看到输出面板

 <p:gmap model="#{addMarkers.emptyModel}" id="gmap" streetView="false" navigationControl="true" mapTypeControl="true" draggable="true" center="26.959512, -12.821044" zoom="8" type="ROADMAP" style="width:100%;height:500px"> <p:ajax event="overlaySelect" listener="#{addMarkers.onMarkerSelect}" id="open1" update="messages"/> <p:gmapInfoWindow id="infoWindow"> <p:outputPanel style="text-align: center; margin: auto"> <p:commandButton ajax="true" type="button" value="open map" onclick="PF('dlg').show();" /> 

When i do refresh the page, the problem seems to be solved and surprisingly I get my output panel ! 当我刷新页面时,该问题似乎已解决,并且令人惊讶的是,我得到了输出面板! After debuging I found that I have a little problem in my ManagedBeans 调试后,我发现我的ManagedBeans有一个小问题

public void onMarkerSelect(OverlaySelectEvent event)  {
    marker = (Marker) event.getOverlay();
     FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "scanning the materials", "Site :"+ marker.getTitle() ));

}

Before refreshing I'm getting: event overlay type is unknown and the value is NULL After refereshing I'm getting event overlay type is "Marker" and the value is #440 刷新之前,我得到:事件覆盖类型未知,值为NULL刷新后,我得到事件覆盖类型为“ Marker”,值为#440

If you're still struggling with this, I'd suggest to check when the MapModel constructor is used. 如果您仍在为此苦苦挣扎,建议您检查何时使用MapModel构造函数。 It should be done in the definition of the bean's field itself or in the postInit funciton, to assure it will be called just once, and not inside a getter or something like that. 应该在bean的字段本身的定义中或在postInit函数中完成此操作,以确保仅将一次调用它,而不是在getter之类的东西中调用它。 Example: 例:

@ManagedBean(name = EstablecimientoInstalacionesViewDetailBean.ID)
@ViewScoped
public class ViewDetailBean extends AbstractViewDetailBean {

private final static MapModel mapModel = new DefaultMapModel();
[...]
@Override
protected void postInit() {
    refreshMapModel();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM