I have some d3 animation i want to append to a custom map marker created with an overlay. Since I customized the markers they have a class which I can target, but they are attached to the map/overlay not the svg so i am not sure how to select them.
Here is the map and custom marker creation:
var map = new google.maps.Map(mapCanvas, mapOptions)
overlay = new CustomMarker(
myLatlng,
map,
{
marker_id: '1'
}
);
Which results in a class of marker. Here is the failing attempt to append my svg elements to that marker:
svg.selectAll(".marker")
.data(locationsArray)
.enter()
.append("circle")
.attr("stroke-width", 20)
.attr("r", 20)
// .attr("cx", function(d) { return d[1] })//position of pulse on canvas
// .attr("cy", function(d) { return d[0] })
.attr("class", function(d) {
if (d[3] >= 30 && d[3] < 60) {
d[2] == 1 ? result = "smallBadVibe" :
d[2] == 2 ? result = "smallNeutralVibe" : result = "smallGoodVibe";
return result;
}
else if (d[3] >=60 && d[3] < 90) {
d[2] == 1 ? result = "mediumBadVibe" :
d[2] == 2 ? result = "mediumNeutralVibe" : result = "mediumGoodVibe";
return result;
}
else if (d[3] >= 90) {
d[2] == 1 ? result = "largeBadVibe" :
d[2] == 2 ? result = "largeNeutralVibe" : result = "largeGoodVibe";
return result;
}
})
I think maybe I have to type in something other than svg.select since the marker is not on my svg but don't know what to type. In case it matters here is the animation I am applying:
function cyanBigPulse() {
var circle = svg.selectAll(".largeNeutralVibe");
(function repeat() {
circle = circle.transition()
.attr("fill", "rgba(0,255,255, .35)")
.attr("stroke", "rgba(0,255,255,1)")
.duration(20)//circle close
.attr("stroke-width", 0.5) //how thick is the stroke at min size
.attr("r", 5) //inner circle radius
.transition()
.duration(2000)//circle open
.attr('stroke-width', 0.5) //how thick is the stroke at full size
.attr("r", 150) //circle outer radius
.ease('sine')
.each("end", repeat)
})();
}
A note: I will be attaching multiple circles to different spots on the map, and will be iterating through some data to create many more markers, but for now i must know how to append to that one marker, before applying that on a bigger scale. Thanks in advance for help.