0

I need to highlight the boundary of a country, for which I am using GMaps4JSF aimed at integrating Google maps with JSF.

To draw polygon and polylines, the library provides polygonComponent polylineComponent components.

I have loaded the data points from the fusion tables into our own DB.

   <m:map width="1000px" height="500px">   

    <m:polygon lineWidth="4">

        <m:point latitude="35.555618" longitude="61.27652" />
        <m:point latitude="35.517635" longitude="61.183601" />
        <m:point latitude="35.348602" longitude="61.105827" />
        <m:point latitude="35.281799" longitude="61.096241" />
        <m:point latitude="35.23624" longitude="61.099781" />
        <m:point latitude="35.17659" longitude="61.116379" />
        <m:point latitude="35.163876" longitude="61.136036" />
        <m:point latitude="35.132072" longitude="61.13166" />
        <m:point latitude="35.085823" longitude="61.115547" />
        <m:point latitude="35.016937" longitude="61.077492" />
        <m:point latitude="34.879433" longitude="61.051102" />
        <m:point latitude="34.789436" longitude="60.976654" />
        <m:point latitude="34.650757" longitude="60.853191" />
        <m:point latitude="34.567631" longitude="60.832909" />
        <m:point latitude="34.561794" longitude="60.77916" />
        <m:point latitude="34.556099" longitude="60.73999" />
        <m:point latitude="34.544716" longitude="60.723877" />


        ....... and so on to a very very large extent
    </m:polygon>
  </m:map>

which renders as enter image description here

It would be stupidity to manually enter values into those latitude and longitude attributes of the polygon inside the map component.

How can I achieve this so that I have to write only this much...

<m:map width="1000px" height="500px">
    <m:polygon lineWidth="4">
       <m:point latitude=" " longitude=" " />
    </m:polygon>
</m:map>

just like we have a dynamic datatable in which rows are generated dynamically (multiple rows). How can these <m:point latitude=" " longitude=" " /> be generated multiple times?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Farhan stands with Palestine
  • 13,890
  • 13
  • 58
  • 105

1 Answers1

2

You can use <c:forEach> for that.

<m:polygon lineWidth="4">
    <c:forEach items="#{bean.points}" var="point">
        <m:point latitude="#{point.latitude}" longitude="#{point.longitude}" />
    </c:forEach>
</m:polygon>

The <ui:repeat> is unsuitable as it doesn't build the component tree. A theoretical alternative would be to use a fictive <m:points> component from the GMaps4JSF, if it has one.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555