Skip to content

Question: How do I style my cluster markers? #222

Closed Answered by julianhirt
tbmluijten asked this question in Q&A
Discussion options

You must be logged in to vote

For anybody who needs it. This is how I implemented it...

Define your custom renderer:

const svg = window.btoa(`
  <svg fill="#ff00ff" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240">
    <circle cx="120" cy="120" opacity=".8" r="70" />
  </svg>`);

const renderer = {
  render: ({ count, position }) =>
    new google.maps.Marker({
      label: {
        text: String(count),
        color: "white",
      },
      position,
      icon: {
        url: `data:image/svg+xml;base64,${svg}`,
        scaledSize: new google.maps.Size(75, 75),
      },
      // adjust zIndex to be above other markers
      zIndex: Number(google.maps.Marker.MAX_ZINDEX) + count,
      gridSize: 10,
    }),
};

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by HusamElbashir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #127 on March 28, 2024 23:25.