Google Maps employs a clever technique to hide marker numbers from being selected with the mouse. The SVG icon (the blue circle without the number) is initially placed in a lower layer, while the number is positioned above it. Then, the icon is rendered again on top but with an opacity="0.01"
. This setup tricks developer tools as selecting the marker leads you to the higher layer without revealing the DOM node for the number.
The selected icon resides in a layer with z-index:3
. Preceding this element are two sibling elements within a div with z-index:1
(both lacking class or id). Inside this div are the components holding the marker and the number 9:
<div style="width: 32px; height: 32px; overflow: hidden; position: absolute; left: -16px; top: -16px; z-index: 0;">
<img alt="" src="data:image/svg+xml;utf8,..." draggable="false" style="position: absolute; left: 0px; top: 0px; width: 32px; height: 32px; user-select: none; border: 0px; padding: 0px; margin: 0px; max-width: none;">
</div>
<div style="position: absolute; left: 0px; top: 0px; z-index: 0;">
<div style="height: 100px; margin-top: -50px; margin-left: -50%; display: table; border-spacing: 0px;">
<div style="display: table-cell; vertical-align: middle; white-space: nowrap; text-align: center;">
<div style="color: white; font-size: 14px; font-weight: bold; font-family: Roboto, Arial, sans-serif;">9</div>
</div>
</div>
</div>
To target the number programmatically, use the following selector (note that CORS restrictions may prevent accessing this in certain environments):
document.querySelector('div[style*="z-index: 103"] div[style*="display: table-cell"] > div')