In the article:
Getting Google Map MarkerClusterer Plus Icons In One Color
the second solution (using inline SVG for a cluster marker) has a JavaScript function:
getGoogleClusterInlineSvg(color)
that allows for passing of a color parameter, e.g.
url: getGoogleClusterInlineSvg('blue')
in order to dynamically produce the marker with SVG code.
Is there a way to also pass the actual number of clustered items for the particular marker, e.g. “37” so that number variable can also be embedded in the SVG code (to allow for setting font-family and other font attributes)?
E.g.
url: getGoogleClusterInlineSvg('blue', intNumberOfItemsClustered)
In function:
var textlabel = ‘<text x="50%" y="50%" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em">
+ intNumberOfItemsClustered
+ ‘</text>’
var encoded = window.btoa('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-100 -100 200 200"><defs><g id="a" transf...”
+ textlabel
+ “(rest of svg code ...)”
from Can we have a Google maps SVG Marker-Cluster icon with a number inside?
No comments:
Post a Comment