1
我在我的數據庫中有座標的標記,我試圖在我的地圖上繪製標記,但我無法做到, 這是我的ShowMarker ::在谷歌地圖上從數據庫中繪製標記,
@Component
@Scope
@ManagedBean
public class ShowMarker {
// =========================================================================
// ATTRIBUTES
// =========================================================================
private Point point ;
private PointService pointService;
private MapModel emptyModel;
public ShowMarker() {
super();
// TODO Auto-generated constructor stub
}
// =========================================================================
// METHODS
// =========================================================================
@SuppressWarnings("unchecked")
public List<Point>getAllPoint(){
List<Point>points=pointService.getAllPoint();
for(Point point : points){
System.out.println("=======>"+point.getTitre());
System.out.println("==========>"+point.getLatitude());
System.out.println("==========>"+point.getLongitude());
Marker marker = new Marker(new LatLng(point.getLatitude(), point.getLongitude()));
emptyModel.addOverlay(marker);
}
return points ;
}
@PostConstruct
public void reint(){
point = new Point();
}
@PostConstruct
public void init() {
emptyModel = new DefaultMapModel();
}
// =========================================================================
// GETTERS & SETTERS
// =========================================================================
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
this.point = point;
}
public MapModel getEmptyModel() {
return emptyModel;
}
public void setEmptyModel(MapModel emptyModel) {
this.emptyModel = emptyModel;
}
@Autowired
public void setPointService(PointService pointService) {
this.pointService = pointService;
}
}
,這是XHTML頁面::
<h:head>
<title>show marker</title>
</h:head>
<h:body>
<ui:composition template="../../template/template_.xhtml">
<ui:define name="content">
<h:form id="form">
<p:growl id="msgs" />
<p:dataTable id="usersTable" value="#{showMarker.allPoint}" var="point">
<p:column>
<f:facet name="header">
<h:outputText value="titre" />
</f:facet>
<h:outputText value="#{point.titre}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="long" />
</f:facet>
<h:outputText value="#{point.longitude}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="latitude" />
</f:facet>
<h:outputText value="#{point.latitude}" />
</p:column>
</p:dataTable>
</h:form>
<h:form>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<p:gmap id="gmap" center="36.8463044,10.1992342" zoom="16" type="HYBRID" style="width:1200px;height:700px" widgetVar="map"
model="#{showMarker.emptyModel}"
/>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
我有標記的列表,並在數據表中的座標,但是我卻沒有在德地圖標記,你可以請幫忙我
你找到答案了嗎? – Yusuf1494