Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions packages/front/src/core/Marker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ export class Marker extends OBC.Component implements OBC.Disposable {
*/
autoCluster = true;

private static readonly DEFAULT_CLUSTER_STYLES = {
backgroundColor: "#FFFFFF",
textColor: "#000000",
fontSize: "1.2rem",
fontWeight: "500",
borderRadius: "50%",
padding: "5px 11px",
textAlign: "center",
cursor: "pointer",
hoverBackgroundColor: "#BCF124",
transition: undefined,
};

// Customizable cluster element styles
clusterElementStyles: Partial<typeof Marker.DEFAULT_CLUSTER_STYLES> = {
...Marker.DEFAULT_CLUSTER_STYLES,
};

/**
* A Map containing the markers grouped by world UUID.
* Each world can have its own set of markers.
Expand Down Expand Up @@ -418,24 +436,40 @@ export class Marker extends OBC.Component implements OBC.Disposable {
private createClusterElement(key: string) {
const div = document.createElement("div");
div.textContent = key;
div.style.color = "#000000";
div.style.background = "#FFFFFF";
div.style.fontSize = "1.2rem";
div.style.fontWeight = "500";
div.style.pointerEvents = "auto";
div.style.borderRadius = "50%";
div.style.padding = "5px 11px";
div.style.textAlign = "center";
div.style.cursor = "pointer";
// div.style.transition = "all 0.05s";

const {
backgroundColor,
textColor,
fontSize,
fontWeight,
borderRadius,
padding,
textAlign,
cursor,
hoverBackgroundColor,
transition,
} = { ...Marker.DEFAULT_CLUSTER_STYLES, ...this.clusterElementStyles };

Object.assign(div.style, {
background: backgroundColor,
color: textColor,
fontSize,
fontWeight,
borderRadius,
padding,
textAlign,
cursor,
...(transition && { transition }),
});

div.addEventListener("pointerdown", () => {
this.navigateToCluster(key);
});
div.addEventListener("pointerover", () => {
div.style.background = "#BCF124";
div.style.background = hoverBackgroundColor;
});
div.addEventListener("pointerout", () => {
div.style.background = "#FFFFFF";
div.style.background = backgroundColor;
});
return div;
}
Expand Down