MapModel API is used to add markers to the map. Marker class has various configuration options like custom icons, dragging, title text and more.
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<div class="card">
<p:gmap center="36.890257,30.707417" zoom="13" type="HYBRID" style="width:100%;height:400px"
model="#{markersView.simpleModel}"/>
</div>
@Named
@RequestScoped
public class MarkersView implements Serializable {
private MapModel simpleModel;
@PostConstruct
public void init() {
simpleModel = new DefaultMapModel();
//Shared coordinates
LatLng coord1 = new LatLng(36.879466, 30.667648);
LatLng coord2 = new LatLng(36.883707, 30.689216);
LatLng coord3 = new LatLng(36.879703, 30.706707);
LatLng coord4 = new LatLng(36.885233, 30.702323);
//Basic marker
simpleModel.addOverlay(new Marker(coord1, "Konyaalti"));
simpleModel.addOverlay(new Marker(coord2, "Ataturk Parki"));
simpleModel.addOverlay(new Marker(coord3, "Karaalioglu Parki"));
simpleModel.addOverlay(new Marker(coord4, "Kaleici"));
}
public MapModel getSimpleModel() {
return simpleModel;
}
}