Reputation: 393
I'm using the p:gmap component in an application, but when I try to use the binding attribute to reference a GMap in a bean, it doesn't work and the map is not showed.
JSF code:
<p:gmap binding="#{mapBean.map}" center=" -26.9995, -49.686" zoom="11" type="ROADMAP" />
Backing bean code:
public GMap getMap() {
map = new GMap();
map.setCenter("-26.9995, -49.686");
map.setZoom(11);
map.setType("ROADMAP");
map.setModel(geoModel);
map.setStyle("width:850px;height:450px");
map.setWidgetVar("vMap");
return map;
}
When I used this component without binding, and it worked normally...
Primefaces version 3.4.1; Glassfish 3.1.2.2
Any idea?
Thanks
Upvotes: 0
Views: 1144
Reputation: 1404
An alternative it's to create a GMap instance on Backed Bean (or whatever component that presents this case), Create the Component xhml view, remove binding xhtml propperty and match every propperty of both, like this example:
Bean:
// #{viewBean}
private GMap googleMap;
@PostConstruct
public void onPostConstruct(){
googleMap.setDisableDoubleClickZoom(Boolean.TRUE);
googleMap.setScrollWheel(Boolean.FALSE);
googleMap.setCenter(getMapCenterString());
googleMap.setZoom(mapZoomLevel);
googleMap.setType("NORMAL");
googleMap.setFitBounds(Boolean.FALSE);
// etc...
}
// getter and setter of googleMap
XHTML View:
<p:gmap id="gmap"
center="#{viewBean.googleMap.center}"
zoom="#{viewBean.googleMap.zoom}"
type="#{viewBean.googleMap.type}"
model="#{viewBean.mapModel}"
scrollWheel="#{viewBean.googleMap.scrollWheel}"
disableDoubleClickZoom="#{viewBean.googleMap.disableDoubleClickZoom}"
etc... />
So we can keep the control of component in backed bean.
While primefaces fixes this bug.
Upvotes: 0
Reputation: 39
I found the same problem related for you... When I use the binding attribute to reference GMap in a Managed Bean, the map isn't rendered.
I noticed that the file gmap.js was not been loading and for this reason GMap was not been rendered too.
I didn't get to find out the cause of this problem, but I found a way to solve it, but is not an elegant way. :D
I added this line in my xhtml file after copy gmap.js to file system of directory structure of the project.
<h:head>
...
<h:outputScript library="primefaces" name="gmap/gmap.js" />
...
</h:head>
I hope this help you! Good luck! :D
Upvotes: 3