O'Reilly logo

PrimeFaces Cookbook - Second Edition by Oleg Varaksin, Mert Çalışkan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required