Friday, 3 July 2015

Marker Clusterer in Primefaces Gmap


wiKlimb development is running smoothly and i'm learning a lot meanwhile. The latest feature it's clustering markers on the main google maps window.

Why clustering?

 As Google says too many markers can be a pain to render and gives poor usability to your users. wiKlimb right now does not need clustering as the numer of locations is low, but have to very close locations and the user may have a hard time selecting one of them with out zooming in.


1. Download last version of markerClusterer (I used markerclusterer_compiled.js at http://google-maps-utility-library-v3.g ... terer/src/)

2. Import script int your page:

3. Use PF gmap normally. wiKlimb main map for example:
4.Add the following code to the map page:

All your markers will be clustered, and clicking on a cluster fill zoom in to fit all of them.

If you update the map in any action you need to call clusterMarkers(); again in order to cluster the updated markers. For example, wiKlimb uses different buttons to filter the map by climbing style.

That's it!