ClusterPlacemark
Extends IGeoObject, collection.Item.
Cluster of geo objects. Used by default in Clusterer.
Constructor | Fields | Events | Methods
Constructor
ClusterPlacemark(geometry, properties[, options])
Parameters:
Parameter |
Default value |
Description |
||
— |
Type: Number[] |
Object |
Coordinates of the placemark, or a hash describing the geometry, or a reference to the point geometry object. |
|
— |
Type: IDataManager Cluster data. |
|||
— |
Type: IGeoObject[] Array of geo objects that are located in the given cluster. |
|||
— |
Type: Object Cluster options. In addition to special options, the cluster balloon supports the same options as Balloon. The cluster balloon options are indicated with the "balloon" prefix. |
|||
'cluster#balloonTwoColumns' |
Type: Function|String Layout of the cluster balloon in normal mode. You can pass the object's constructor with the ILayout interface or the key for one of the standard layouts. Each standard layout has several customized options. In standard layouts, geo object data fields are used by default: clustercaption, balloonContentHeader, balloonContent, and balloonContentFooter (see Placemark).
|
|||
— |
Type: Number The height of the layout of the content of the balloon cluster. The balloon cluster option balloonMaxHeight is not set by default, because all standard layouts have fixed dimensions. The standard value depends on the layout.
|
|||
— |
Type: Number The width of the layout of the content of the balloon cluster. The balloon cluster option balloonMaxWidth is not set by default, because all standard layouts have fixed dimensions. The standard value depends on the layout.
|
|||
— |
Type: ILayout|String The layout containing the information about geo object. The standard value depends on the layout.
|
|||
null |
Type: Function|String Layout of the cluster balloon in the "panel" mode. You can pass the object's constructor with the ILayout interface. The available values are the same as in the 'balloonContentLayout' options. If null, then the value of the 'balloonContentLayout' option is used. |
|||
'pointer' |
Type: String Cursor over the cluster marker. |
|||
false |
Type: Boolean Flag that prohibits zooming in on the map when the cluster is clicked. |
|||
true |
Type: Boolean Hide the icon when opening the balloon. |
|||
— |
Type: String The color of the cluster icon. This option is used for standard icons in browsers that support SVG. |
|||
'cluster#iconContent' |
Type: Function|String Layout for cluster marker contents. (Type: constructor for an object with the ILayout interface or the layout key). If you do not want to display the content of the placemark, set the option value to null. |
|||
'cluster#icon' |
Type: Function|String Layout of the cluster placemark (Type: constructor for an object with the ILayout interface or the layout key). |
|||
— |
Type: Object[] Array describing the icon for standard implementation of the cluster. An icon description is made up of an object with the following fields:
|
|||
— |
Type: IGeometryJson|null The hotspot shape of the cluster. Specified as a JSON description of the pixel geometry of the icon. Use this option when creating your HTML layouts. The coordinates of the figure geometry are counted from the anchor point. |
|||
'default#geoObject' |
Type: String Cluster interactivity model. Available keys and their values are listed in the description of interactivityModel.storage. |
|||
[10, 100] |
Type: Number[] Array describing the boundary values for cluster dimensions. The number of icons described in the "icons" options must be 1 more than the number in this array. |
|||
true |
Type: Boolean Option that prevents opening the balloon when clicking on a cluster. By default, opening the balloon is allowed. |
|||
false |
Type: Boolean Enables displaying empty popup hints. Empty cluster hints are not shown by default. |
|||
true |
Type: Boolean Option that allows you to forbid displaying the popup hint when the cluster is pointed at. By default, showing hints is allowed. |
|||
— |
Type: Number The zIndex value, which is set to the cluster placemark on mouse hovering. |
* Mandatory parameter/option.
Examples:
1.
// Variable with a description of two types of cluster icons.
var clusterIcons = [
{
href: 'small.png',
size: [40, 40],
// Offset so the image center matches the cluster center.
offset: [-20, -20]
},
{
href: 'big.png',
size: [60, 60],
offset: [-30, -30],
// You can define the shape of the hotspot area
// of the placemark.
// The rectangular area is used by default.
shape: {
type: 'Circle',
coordinates: [0, 0],
radius: 30
}
}
],
// For a cluster size up to 100, the image small.jpg will be used.
// For a cluster size over 100, big.png will be used.
clusterNumbers = [100],
// Making a layout for cluster icon contents,
// in which numbers will be white.
MyIconContentLayout = ymaps.templateLayoutFactory.createClass(
'<div style="color: #FFFFFF; font-weight: bold;">{{ properties.geoObjects.length }}</div>'
),
var clusterer = new ymaps.Clusterer({
// If options for the cluster are set via the clusterer,
// they must be specified with the "cluster" prefix.
clusterIcons: clusterIcons,
clusterNumbers: clusterNumbers,
clusterIconContentLayout: MyIconContentLayout
});
2.
// Creating a clusterer with a carousel layout.
var clusterer = new ymaps.Clusterer({
clusterDisableClickZoom: true,
// Using the carousel layout.
clusterBalloonContentLayout: "cluster#balloonCarousel",
// Prohibiting cycling the list for paginated navigation.
clusterBalloonCycling: false,
// Configuring the appearance of the navigation panel.
// Markers will be the items in the navigation panel.
clusterBalloonPagerType: "marker",
// Number of items in the navigation panel.
clusterBalloonPagerSize: 6
});
3.
// Creating a clusterer with an accordian layout.
var clusterer = new ymaps.Clusterer({
clusterDisableClickZoom: true,
// Using the accordian layout.
clusterBalloonContentLayout: "cluster#balloonAccordion"
});
4.
// Creating a clusterer with a custom HTML layout of the cluster icon.
var clusterer = new ymaps.Clusterer({
// Defining the cluster placemark layout.
clusterIconLayout: ymaps.templateLayoutFactory.createClass('<div class="clusterIcon">{{ properties.geoObjects.length }}</div>'),
// Redefining the active area of the placemark to make it clickable.
clusterIconShape: {
type: 'Rectangle',
coordinates: [[0, 0], [20, 20]]
}
});
Fields
Name |
Type |
Description |
Event manager. Inherited from IDomEventEmitter. |
||
IGeometry|null |
Geo object geometry. Inherited from IGeoObject. |
|
Options manager. Inherited from ICustomizable. |
||
Geo object data. Inherited from IGeoObject. |
||
Cluster state. Defined by the following fields:
|
Events
Name |
Description |
Single left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Calls the element's context menu. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Double left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Change to the geo object geometry. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeoObject. |
|
Map reference changed. Data fields:
Inherited from IParentOnMap. |
|
Pressing the mouse button over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Pointing the cursor at the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Moving the cursor off of the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Moving the cursor over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
Letting go of the mouse button over an object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
|
End of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface. Inherited from IDomEventEmitter. |
|
Repeating event during multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:
Inherited from IDomEventEmitter. |
|
Start of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:
Inherited from IDomEventEmitter. |
|
Change to the object options. Inherited from ICustomizable. |
|
Change to the geo object overlay. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeoObject. |
|
The parent object reference changed. Data fields:
Inherited from IChild. |
|
Change to the geo object data. Instance of the Event class. Names of fields that are available via the Event.get method:
Inherited from IGeoObject. |
|
Mouse wheel scrolling. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager. Inherited from IDomEventEmitter. |
Methods
Name |
Returns |
Description |
Number[][]|null |
Returns the geographical coordinates of the rectangular area that includes all the cluster elements. |
|
The method is a simplified call of cluster.properties.get('geoObjects'); |
||
getMap() |
Returns reference to the map. Inherited from IParentOnMap. |
|
Returns the promise object, which is confirmed by the overlay object at the time it is actually created, or is rejected with an appropriate error message. Inherited from IGeoObject. |
||
IOverlay|null |
The method provides synchronous access to the overlay. Inherited from IGeoObject. |
|
IParentOnMap|null |
Returns link to the parent object, or null if the parent element was not set. Inherited from IChildOnMap. |
|
Function that is called when adding an element to the map. To perform additional actions when adding the object to the map, redefine this function. Inherited from collection.Item. |
||
Function that is called when deleting an element from the map. To perform additional actions when deleting the object from the map, redefine this function. Inherited from collection.Item. |
||
Sets the parent object. If the null value is passed, the manager element will only be deleted from the current parent object. Inherited from IChildOnMap. |
Fields details
state
{data.Manager} state
Cluster state. Defined by the following fields:
- activeObject - Reference to the cluster's active object. The active object is the one that is currently selected in the cluster balloon.
Example:
var geoObjects = cluster.properties.get('geoObjects');
// When opening the cluster's balloon, the third object in the list will be selected.
cluster.state.set('activeObject', geoObjects[2]);
Methods details
getBounds
{Number[][]|null} getBounds()
Returns the geographical coordinates of the rectangular area that includes all the cluster elements.
getGeoObjects
{IGeoObject[]} getGeoObjects()
The method is a simplified call of cluster.properties.get('geoObjects');
Returns an array of geo objects that make up the cluster.
Mandatory parameter/option.