How to programmatically update the center of the gMap card in primefaces ? Is it possible to do this from within a bin?
|
1 answer
index.xhtml:
<h:form prependId="false"> <p:commandButton value="Обновить" actionListener="#{geocodeView.updateMapCenter}" update="geoGmap" /> <p:gmap id="geoGmap" widgetVar="geoMap" center="#{geocodeView.centerGeoMap}" zoom="2" type="ROADMAP" model="#{geocodeView.geoModel}"> </p:gmap> </h:form> GeocodeView.java:
public class GeocodeView { private MapModel geoModel; private String centerGeoMap = "41.850033, -87.6500523"; @PostConstruct public void init() { geoModel = new DefaultMapModel(); } public void updateMapCenter(ActionEvent ae) { centerGeoMap = "..."; // Меняете центр карты. } ... } A more complete example and documentation is available on the official website of Primefaces .
- thank. everything is easier than I thought it turned out - evp
|