Skip to content

A cluster layer for OpenLayers 3 (OL3) that animates clusters on zoom change and a select interaction that spread out cluster to allow feature selection in it.

Notifications You must be signed in to change notification settings

guadaltel/OL3-AnimatedCluster

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OL3-AnimatedCluster

A cluster layer for OpenLayers 3 (OL3) that animates clusters on zoom change and a select interaction that spread out cluster to allow feature selection in it.

Inspired by acanimal/AnimatedCluster.

View the live example...

If you like this, you may like ol3-ext.

How it runs?

ol.layer.AnimatedCluster is a layer that animates clusters on zoom change. The layer is created with an ol.source.Cluster as standard cluster vector layers.

ol.interaction.SelectCluster is a select interaction that handles clusters. On select cluster springs apart to reveal the features. The revealed features are themselves selectable. Revealed features are a cluster with an attribute features that contain the original feature so they can be use as a cluster.

##Usage

Include the following files in your page:

<script type="text/javascript" src="https://cdn.rawgit.com/Viglino/OL3-AnimatedCluster/gh-pages/interaction/selectclusterinteraction.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/Viglino/OL3-AnimatedCluster/gh-pages/layer/animatedclusterlayer.js"></script>

Create a cluster layer to add to the map object:

// Cluster Source
var clusterSource = new ol.source.Cluster({
     distance: 40,
     source: new ol.source.Vector()
	});
// Animated cluster layer
var clusterLayer = new ol.layer.AnimatedCluster(
	{	name: 'Cluster',
		source: clusterSource,
		// Use a style function for cluster symbolisation
		style: getStyle
	});
// Add the layer to the map
map.addLayer(clusterLayer);

The getStyle function will customize the clusters symbolisation.

Look at the standard OL3 cluster example or the repo example to know how to define such a function.

Licence

OL3-ext is licenced under the French Opensource BSD compatible CeCILL-B FREE SOFTWARE LICENSE.
(c) 2016 - Jean-Marc Viglino

Full text license in English: (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
Full text license in French: (http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt)

About

A cluster layer for OpenLayers 3 (OL3) that animates clusters on zoom change and a select interaction that spread out cluster to allow feature selection in it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 59.4%
  • HTML 31.6%
  • CSS 9.0%