繁体   English   中英

gmap PrimeFaces p:ajax

[英]gmap PrimeFaces p:ajax

我试图在p:ajax的帮助下用新的纬度,经度更新PrimeFaces的谷歌地图,但它不起作用......我正在使用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>

我现在解决了:)

索引页面:

<h:panelGroup id="pmap">
    <p:inputText value="#{mapManager.address}" label="Adresa" />
    <h:outputText value="#{mapManager.geo}" id="m" />
    <p:commandButton value="OK" actionListener="#{mapManager.updateMapCenter(ae)}" update="pmap" />
    <p:gmap  center="#{mapManager.geo}" 
             zoom="7" 
             type="HYBRID"    
             style="width:800px;height:400px" 
             streetView="true"
             model="#{mapManager.map}"
             overlaySelectListener="#{mapBean.onMarkerSelect}"
             >
        <p:gmapInfoWindow>  
            <p:outputPanel style="text-align:center; display:block; margin:auto:">
                <h:outputText value="#{mapManager.marker.title}" />  
                wserw
            </p:outputPanel>  
        </p:gmapInfoWindow>  
    </p:gmap>
</h:panelGroup>

托管bean的一部分:

private MapModel map;
private Marker marker;
private String address;
private String geo="49.817491999999992, 15.4729620";

public MapManager() {
}

@PostConstruct
public void init() {
    events = edao.findAll();
    map = new DefaultMapModel();
    for (Event event : events) {  
        Marker m=new Marker(new LatLng(event.getLat(), event.getLng()), event.getName());
        map.addOverlay(m);
    }
}

public void updateMapCenter(ActionEvent ae) {
    GMapService gs=new GMapService();
    LatLng geo=gs.getGeocode(address);
    this.geo=geo.getLat()+","+geo.getLng();
}

希望它能解决你的问题。

暂无
暂无

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

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