I want to add a bookmark at the point I'm showing on the map. It loads the map and everything, but I can not add the bookmark.
<h:body>
<h:form>
<p:poll interval="10"
listener="#{gadoBean.obterPosicaoTag}"
update="panelMap"/>
<p:panel id="panelMap">
<p:gmap id="mapa"
center="#{gadoBean.center}"
zoom="18"
model="#{gadoBean.mapa}"
type="HYBRID"
style="width:600px;height:400px"/>
</p:panel>
</h:form>
</h:body>
</html>
ManagedBean:
@Named
@SessionScoped
public class GadoBean implements Serializable {
private static final long serialVersionUID = 1L;
private MapModel mapa;
private Circle circulo = null;
private Tag tag;
private Gado gadoAtual;
private float lastLat, lastLong;
private Coordenadas coordenadas;
private List<Coordenadas> posicoes;
private Fazenda fazendaAtual;
private String center;
private LatLng coord;
@Inject
private CoordenadasService coordenadasService;
@Inject
private CoordenadasRep coordenadasRep;
public GadoBean() {
mapa = new DefaultMapModel();
}
public void inicializar() {
}
public void obterPosicaoTag() {
posicoes = new ArrayList<Coordenadas>();
posicoes = coordenadasRep.listar();
int totalPosicoes = this.getPosicoes().size();
if (totalPosicoes > 0) {
Coordenadas posicaoAtual = this.getPosicoes().get(totalPosicoes - 1);
coord = new LatLng(posicaoAtual.getPosLongitude(), posicaoAtual.getPosLatitude());
lastLong = (float) posicaoAtual.getPosLongitude();
lastLat = (float) posicaoAtual.getPosLatitude();
center = lastLat + "," + lastLong;
System.out.println(center);
mapa.addOverlay(new Marker(coord));
}
}
//getters and setters