Clustering in Maps add-on

Hi JMIX team
Do you have any examples or can share code snippets how the weightProperty can be used?

weightProperty — if specified, then each point of the layer will have a weight value (int) defined by the weight property of the geo-object. This value will be used when calculating the summed-up value of the cluster (by default, the number of points is used).

I have a use case.

  1. I want to show the total sales amount from customers in different geolocations instead of just count of customers.
  2. The aggregation will be based on the hierarchy used e.g. Country, Province, District etc.

As per the documentation, it seems #1 above is possible but any sample code will be helpful.

Is this add-on has the option to achieve #2 above too?


  1. weightProperty takes entity’s property to show value of the cluster instead of number of points. It should return the Integer type.

You can define the existing property from entity or create non-persistent property which will be calculated based other ones or later. For instance the weight property in Location entity:

Location class
@Table(name = "SAMPLER_LOCATION")
@Entity(name = "sampler_Location")
public class Location {

    @Column(name = "ID", nullable = false)
    private UUID id;

    @Column(name = "NAME")
    private String name;

    @Column(name = "POINT")
    @Convert(converter = PointWKTConverter.class)
    protected Point point;

    @Column(name = "INTENSITY")
    private Double intensity;

    private Integer weight = RandomUtils.nextInt(1, 100);

    public Double getIntensity() {
        return intensity;

    public void setIntensity(Double intensity) {
        this.intensity = intensity;

    public Point getPoint() {
        return point;

    public void setPoint(Point point) {
        this.point = point;

    public String getName() {
        return name;

    public void setName(String name) { = name;

    public UUID getId() {
        return id;

    public void setId(UUID id) { = id;

    public Integer getWeight() {
        return weight;

    public void setWeight(Integer weight) {
        this.weight = weight;

And set this property in the map:

<maps:geoMap id="map"
        <maps:tile id="tiles" tileProvider="map_OpenStreetMap"/>
        <maps:vector id="locations" dataContainer="locationsDc">
            <maps:cluster disableAtZoom="18" weightProperty="weight"/>
  1. As far as I know map does not provide the ability to cluster by country, city, etc. I think the only way is to group data by containers and create several layers with cluster. However they won’t group together.
    <maps:vector id="locations" dataContainer="locationsDc">
    <maps:vector id="locations2" dataContainer="locationsDc2">

Thank you. #1 point working. How can we use the style in Cluster? for example,

  1. make it red when a certain criterion is not met and blue in other cases.
  2. change the opacity.

I found the styling of polygon but not for Clustering. Thanks for sharing some codes.

For now, cluster-marker can only be styled by its default style names.

I created an issue: jmix-framework/jmix#713

Thanks for creating the issue for enhancement. You may also consider adding the following too:
3. Option to use different shapes (instead of just circle)
4. Option to show more than 1 value like a) target sales b) actual sales. These two fields can be the criteria to change the colour e.g. when actual sales >= target then green, else red.

Do you also have any plan to include Direction, distance, routing etc. features in the map add-on? Currently, the map component add-on looks to have very limited functionalities. Being a commercial component, I would expect more useful features in it.

1 Like

Hi Mortoza,

Thanks for your feedback!
We’ll definitely consider adding these features.


1 Like