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>

我有标记列表和数据表中的坐标,但我在地图中没有标记,你能帮帮我吗

4

1 回答 1

0
public ShowMarker() {
    emptyModel = new DefaultMapModel();
}

您必须在构造函数中定义 emptyModel。

于 2015-06-04T06:36:15.510 回答