So I am using this
Zoom To Bounding Box framework on D3.js and I just figured out how to append circles to the map. However when you click on a state the circle moves out of place and I can't figure out how to move them with the zoom or stay in that specified spot. I also want to incorporate a tooltip and change the circles to markers(image below).
Here is my code for appending circles:
d3.json("city_locations.json", function(new_us_places){
var my_cords = projection(new_us_places["CA"]["SAN DIEGO"]);
var my_cords1 = projection(new_us_places["CA"]["SAN FRANCISCO"]);
var my_cords2 = projection(new_us_places["CA"]["SAN FERNANDO"]);
var my_cords3 = projection(new_us_places["CA"]["LOS ANGELES"]);
var r = 5;
svg.append("circle")
.attr("cx", my_cords[0])
.attr("cy", my_cords[1])
.attr("r", 5)
.attr("class", "HighlightCircle")
.on("click", function(d){alert("text")})
svg.append("circle")
.attr("cx", my_cords1[0])
.attr("cy", my_cords1[1])
.attr("r", 5)
.attr("class", "HighlightCircle")
.style('fill','red')
.on("click", function(d){alert("text")})
Here is what it looks like:
This is what happens when you click a state to zoom:
I want to make the circle a pin drop marker and show a tool-tip similar to this (and hopefully able to keep that marker in place when click state to zoom):
