我在使用JSF2.0和Jboss 1.7的Primefaces 3.5的Gmap组件的一个项目上有问题。所以问题是在页x.xhtml我有组件gmap,但gmap不显示模型映射从bean。bean中的数据是正确的。我包括谷歌API的gmaps,但标记不工作,它的唯一的地图。
我使用这个例子->PrimeFaces Gmap
从这个例子中,我从页面查看源并找到标记,但在我的页面上没有找到。管理bean是一个会话作用域。
Thanks for help
x.xhtml:
<p:ajax event="overlaySelect" listener="#{mapIskanjeBean.onMarkerSelect}" />
<p:gmapInfoWindow>
<p:outputPanel style="text-align:center;display:block;margin:auto:">
<p:graphicImage value="/img/#{mapBean.marker.data}" height="150"/>
<br />
<h:outputText value="#{mapIskanjeBean.marker.title}" />
</p:outputPanel>
</p:gmapInfoWindow>
</p:gmap>
mapIskanjeBean管理bean:
public class MapIskanjeBean implements Serializable {
private static final long serialVersionUID = 1L;
private MapModel advancedModel;
private Marker marker;
public MapIskanjeBean() {
advancedModel = new DefaultMapModel();
//Shared coordinates
LatLng coord1 = new LatLng(46.377291, 15.885323);
LatLng coord2 = new LatLng(36.883707, 30.689216);
LatLng coord3 = new LatLng(36.879703, 30.706707);
LatLng coord4 = new LatLng(36.885233, 30.702323);
LatLng coord5 = new LatLng(36.883333, 30.799323);
//Icons and Data
advancedModel.addOverlay(new Marker(coord1, "Konyaalti", "zelenjava.png", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
advancedModel.addOverlay(new Marker(coord2, "Ataturk Parki", "http://maps.google.com/mapfiles/ms/micons/pink-dot.png"));
advancedModel.addOverlay(new Marker(coord4, "Kaleici", "kaleici.png", "http://maps.google.com/mapfiles/ms/micons/pink-dot.png"));
advancedModel.addOverlay(new Marker(coord3, "Karaalioglu Parki", "karaalioglu.png", "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png"));
advancedModel.addOverlay(new Marker(coord5,"hepan","http://maps.google.com/mapfiles/ms/micons/pink-dot.png","http://maps.google.com/mapfiles/ms/micons/pink-dot.png"));
}
public MapModel getAdvancedModel() {
return advancedModel;
}
public void onMarkerSelect(OverlaySelectEvent event) {
marker = (Marker) event.getOverlay();
}
public Marker getMarker() {
System.out.println("vzame marker");
return marker;
}
public void setAdvancedModel(MapModel advancedModel) {
System.out.println("nastavi model");
this.advancedModel = advancedModel;
}
public void setMarker(Marker marker) {
this.marker = marker;
}
}
嗯,你的代码看起来不错。但如果这些图像的路径是错误的,标记就不会显示出来。所以你可以检查图标路径是否正确!
好幸运!