Hello!
-
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
@JmixEntity
@Table(name = "SAMPLER_LOCATION")
@Entity(name = "sampler_Location")
public class Location {
@JmixGeneratedValue
@Column(name = "ID", nullable = false)
@Id
private UUID id;
@Column(name = "NAME")
private String name;
@Column(name = "POINT")
@Geometry
@Convert(converter = PointWKTConverter.class)
protected Point point;
@Column(name = "INTENSITY")
private Double intensity;
@JmixProperty
@Transient
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) {
this.name = name;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.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"
zoom="14"
centerX="-1.98"
centerY="53.464"
height="100%"
width="100%">
<maps:layers>
<maps:tile id="tiles" tileProvider="map_OpenStreetMap"/>
<maps:vector id="locations" dataContainer="locationsDc">
<maps:cluster disableAtZoom="18" weightProperty="weight"/>
</maps:vector>
</maps:layers>
</maps:geoMap>
- 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:layers>
...
<maps:vector id="locations" dataContainer="locationsDc">
<maps:cluster/>
</maps:vector>
<maps:vector id="locations2" dataContainer="locationsDc2">
<maps:cluster/>
</maps:vector>
</maps:layers>