当前位置: 动力学知识库 > 问答 > 编程问答 >

java - PrimeFaces GMap ignores model tag, not displaying markers

问题描述:

I have a problem using the GMap in PrimeFaces 5.2

I am trying to show a map window with a single marker, but the marker does not show up, I keep getting the blank map without the marker. After investigating I found that apparently the model tag in the XHTML file is being ignored. Even if I fill in complete nonsense (like model="#{asdfasdf}) it doesn't even throw an error.

Snippets of my code:

XHTML

 <p:outputPanel id="mapPanel" style="text-align:center;width:400px">

<p:gmap id="map" rendered="#{testRecordsView.showMap}"

model="#{GMapView.simpleModel}" zoom="10" type="ROADMAP"

center="#{testRecordsView.selectedTest.lat}, #{testRecordsView.selectedTest.lng}"

style="width:400px;height:400px" />

</p:outputPanel>

GMapView.java

@ManagedBean

public class GMapView implements Serializable {

private static final long serialVersionUID = -2238997881933594120L;

private MapModel simpleModel;

@ManagedProperty("#{testRecordsView}")

private TestRecordsView dtView;

@PostConstruct

public void init() {

System.out.println("MAPMAPMAP");

simpleModel = new DefaultMapModel();

LatLng coord1 = new LatLng(dtView.getSelectedTest().getLat(), dtView.getSelectedTest().getLng());

// Basic marker

simpleModel.addOverlay(new Marker(coord1, "test"));

}

public MapModel getSimpleModel() {

System.out.println("Map: " + simpleModel + " !");

return simpleModel;

}

public void setDtView(TestRecordsView dtView) {

this.dtView = dtView;

}

}

The prints in the GMapView never occur and if I put breakpoints somewhere in the class, they are not activated either. Apparently the whole class is never called. Has anybody had this problem before?

网友答案:

this line:

model="#{GMapView.simpleModel}" zoom="10" type="ROADMAP"

put the g in lowercase at start ;-)

model="#{gMapView.simpleModel}" zoom="10" type="ROADMAP"

There you go.

分享给朋友:
您可能感兴趣的文章:
随机阅读: