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

Get PrimeFaces Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.