Adding, selecting, and dragging markers in maps
It is possible to add markers onto the map via a data model and then select or drag it by interacting with the map.
How to do it…
The marker should be an instance of org.primefaces.model.map.Marker
. Markers can be easily constructed by providing an instance of org.primefaces.model.map.LatLng
to define their position. The latitude
and longitude
values could be provided to the LatLng
class as constructor parameters. Markers will be added to the data model via the addOverlay
method. This is shown in the following code:
MapModel markerModel = new DefaultMapModel(); markerModel.addOverlay(new Marker(new LatLng(41.073399, 29.051971), "Bosphorus")); markerModel.addOverlay(new Marker(new LatLng(41.118418, 29.134026), "Bosphorus"));
The attributes of org.primefaces.model.map.Marker
are listed in the following table:
Property |
Default |
Type |
Description |
---|---|---|---|
|
|
|
This is the text to display on rollover |
|