Class: IWClusteredOverlayLayer

IWClusteredOverlayLayer

An layer to show overlays like POIs or search hits on a map. These overlays are clearly arranged in clusters depending on the zoom level.

new IWClusteredOverlayLayer(map, parent, layer)

Constructor.
Parameters:
Name Type Description
map IWMap
parent HTMLDivElement the divOverlay element
layer number the zIndex of this layer

Methods


addAllOverlays(hits)

Adds an array of hits to the clustered layer.
Parameters:
Name Type Description
hits array an array of hits as defined in addOverlay (or a JSON string which can be parsed to an array of objects)
Returns:
true if the hit has a coordinate and was added, false otherwise
Type
boolean

addOverlay(hit, redraw)

Adds a single hit to the clustered layer. This triggers a re-clustering, so if you have an array of hits, use addAllOverlays instead! The hit has to have a coordinate in any of those three forms:
  1. An IWCoordinate called coordinate
  2. Numeric properties x and y with the coordinate in Mercator (EPSG:3857)
  3. Numeric properties lat and lon with the coordinate in WGS84 (EPSG:4326)
Parameters:
Name Type Description
hit object a map of the hit properties, which has to have a coordinate (or a JSON string which can be parsed to an object)
redraw boolean
Returns:
true if the hit has a coordinate and was added, false otherwise
Type
boolean

getClusters()

Returns all clusters in this clustered layer. These change every time the map is zoomed or hits are added to or removed from the layer.
Returns:
an array containing all clusters
Type
array

getOverlayById(id)

Returns the hit with the given id property. If no hit with this ID exists null is returned.
Parameters:
Name Type Description
id String an id
Returns:
Type
object

getOverlays()

Returns all hits in this clustered layer.
Returns:
an array containing all hits
Type
array

getVisibilityRange()

Returns the visibility range of this layer.
Returns:
Type
IWRange

isVisible()

Returns true if this layer is visible.
Returns:
Type
boolean

redraw()

Redraws the overlay layer.
Returns:
Type
void

removeAllOverlays()

Removes all hits from the clustered layer.
Returns:
Type
void

removeOverlay(hit)

Removes the specified hit from the layer.
Parameters:
Name Type Description
hit object
Returns:
Type
void

setClusteringAlgorithm(algorithm)

Sets an instance of the class used to cluster the hits. This has to be a class extending IWClusteringAlgorithm.
Parameters:
Name Type Description
algorithm IWClusteringAlgorithm the instance used for clustering

setMarkerFunction(markerFunction)

Sets a function used to create a marker for every cluster. This has to be a function which gets an instance of the map and the cluster (i.e. an array of the clustered items) and returns the marker (an instance of IWOverlay) to be displayed in the map.
Parameters:
Name Type Description
markerFunction function the marker function to use

setOptions(options)

Sets the options for this layer. Available options are:
  • joinOnOverlap: Join close-by cluster markers to prevent overlapping (default false)
  • markerOffset: Offset of the markers as IWPoint, required for joinOnOverlap
  • markerSize: Size of the markers as IWSize, required for joinOnOverlap
  • zoomOnClick: Zoom into clusters on clicks to resolve the hits (default true)
  • spiderfyOnClick: Spiderfy cluster content on clicks when no further zoom is possible (default true)
  • spiderfyBaseRadius: Base radius in pixels for the circle the spiderfied markers are placed on (used for 8 markers and scaled for less or more markers)
  • offset: An object with properties top, right, bottom and left to specify individual offsets for all map borders, or an integer which is used for every border, or null (no borders).
Example:
layer.setOptions({
  joinOnOverlap: true,
  markerOffset: new IWPoint(15, 40),
  markerSize: new IWSize(30, 40),
  zoomOnClick: true,
  spiderfyOnClick: true,
  spiderfyBaseRadius: 80,
  offset: {
    top: 40,
    right: 100,
    bottom: 0,
    left: 15 
  }
});
Parameters:
Name Type Description
options object the options to use
Returns:
Type
void

setVisibilityRange(range)

Sets the visibility range of this layer.
Parameters:
Name Type Description
range IWRange
Returns:
Type
void

setVisible(isVisible)

Sets the visibility of this layer.
Parameters:
Name Type Description
isVisible boolean
Returns:
Type
void