chart = {
const width = 960,
height = 700;
const svg = d3.create("svg")
.attr("viewBox", [300, 315, width-800, height-445]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], bbox);
var path1 = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
var path3 = d3.geoPath().projection(projection);
var path4 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");
g.selectAll("path3")
.data(troy.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3)
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", ".5")
.style('stroke-opacity','0')
.style("stroke-width", '.5')
.style("stroke", "rgb(0,0,0)")
var p = svg.selectAll("polyline")
.data(test1)
.enter()
.append("polyline")
.attr("points", function(d) {return d})
.attr('fill','white')
.style('fill-opacity','.5')
.style("stroke-width", '.15')
.style("stroke", "gray")
var p = svg.selectAll("polyline") //d3 geopath
.data(route1)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})
.attr('fill','white')
.style('fill-opacity','0')
.style("stroke-width", '.25')
.style("stroke", "black")
.style('stroke-dasharray', '1')
g.selectAll("path2") //d3 geopath
.data(bus.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path2) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','.15')
.style("stroke-width", '.25')
.style("stroke", "gold")
g.selectAll("path2") //d3 geopath
.data(streets) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path2) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "red")
.style('stroke-opacity','1')
.style("stroke-width", '5')
.style("stroke", "rgb(0,0,100)")
g.selectAll("path2") //d3 geopath
.data(buildings3.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path2) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "none")
.style('stroke-opacity','.25')
.style("stroke-width", '.5')
.style("stroke", "gray")
var c = svg.selectAll("circle") //d3 geopath
.data(busstops.features)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',.5)
.attr('fill','white')
.style('fill-opacity','1')
.style("stroke-width", '.15')
.style("stroke", "gray")
.on('mouseover', busstopText)
.on('mouseout', removeBST)
function busstopText(event,d){
//console.log(d)
svg
.append("text")
.attr('x','300')
.attr('y','350')
.attr('class','busstop_name')
.text(d.properties.DESCRIP)
.style('font-family','garamond')
.style('font-size','4px')
.style('font-weight','light')
svg
.append("line")
.attr('x1','300')
.attr('y1','351')
.attr('x2',path1.centroid(d)[0])
.attr('y2',path1.centroid(d)[1])
.attr('class','pline')
.style("stroke-width", '.15')
.style("stroke", "black")
.style('stroke-dasharray', '4')
}
function removeBST (){
d3.selectAll('text.busstop_name').remove()
d3.selectAll('line.pline').remove()
}
c.enter().append("circle")
.data(Personal_spots)
.enter() //there are more data than elements, this selects them
.append("circle") //appends path to data
.attr("cx", function(d) {return projection([d.longitude,d.latitute])[0]})
.attr("cy", function(d) {return projection([d.longitude,d.latitute])[1]})
.attr('r',1)
.attr('fill','black')
.style('fill-opacity','1')
.style("stroke-width", '.25')
.style("stroke", "white")
var t = svg.selectAll("text") //d3 geopath
.data(Personal_spots)
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr("x", function(d) {return projection([d.longitude,d.latitute])[0]+2})
.attr("y", function(d) {return projection([d.longitude,d.latitute])[1]+1})
.style('font-family','garamond')
.style('font-size','3px')
.style('fill','black')
.style('stroke','black')
.style("stroke-width", '.05')
.style('font-weight','bold')
.text(function(d) {return d.name})
svg
.append("text")
.attr('x','300')
.attr('y','333')
.text('Troy')
.style('font-family','garamond')
.style('font-size','14px')
.style('font-weight','bold')
svg
.append("text")
.attr('x','300')
.attr('y','343')
.text('Bus Stops & Bars')
.style('font-family','garamond')
.style('font-size','8px')
.style('font-weight','light')
return svg.node();
}