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

Creating rectangles, circles, polylines, and polygons in maps

The gmap component supports the drawing of rectangles, circles, polylines, and polygons on the map canvas.

How to do it…

All drawings can be implemented as an instance of DefaultMapModel, as stated here:

private MapModel rectangleModel = new DefaultMapModel();
private MapModel circleModel = new DefaultMapModel();
private MapModel polylineModel = new DefaultMapModel();
private MapModel polygonModel = new DefaultMapModel();

All models contain instances of LatLng, where they define the points for the drawings. The rectangle model can be defined with two points, upper-left and lower-right, which are wrapped in an instance of LatLngBounds. This is shown in the following code:

rectangleModel.addOverlay(new ...

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