chart = {
const width = 1660,
height = 1660;
const svg = d3.create("svg")
.attr("viewBox", [400, 415, width-900, 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("path2")
.data(streets.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path2)
.style("fill", "none")
.style('stroke-opacity','1')
.style("stroke-width", '.25')
.style("stroke", "red")
g.selectAll("path3")
.data(bldgs.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path3) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "rgb(240,240,240)")
.style("fill-opacity", "1")
.style('stroke-opacity','.1')
.style("stroke-width", '.5')
.style("stroke", "black")
var c = svg.selectAll("circle")
.data(mypoints.features)
.enter()
.append("circle")
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',3)
.style('fill','black')
.style('fill-opacity','1')
.on('mouseover',buildingtext)
.on('mouseout',removebuildingText)
c.enter().append("circle")
.data(mypoints.features)
.enter()
.append("circle")
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',3)
.style('stroke','black')
.style('stroke-width','1')
.style('fill','cyan')
.style('fill-opacity','1')
function buildingtext(event,d){
//console.log(d)
svg
.append("text")
.attr('x','500')
.attr('y','520')
.attr('class','mypoints_position')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','light')//use 'fill' to change color
.text(d.properties.Position)
var wrap = svg.selectAll("text.mypoints")
.each(function(d, i) { wrap_text(d3.select(this), 75) });
svg
.append("line")
.attr('x1','540')
.attr('y1','595')
.attr('x2', path2.centroid(d)[0])
.attr('y2', path2.centroid(d)[1])
.attr('class','fLine')
.style('stroke-width', '1')
.style("stroke", "rgb(0,0,0)")
.style('stroke-dasharray', '6 4')
//p.enter().append("polyline") //use this line the first time we create a polyline
//.data(f1)
//.enter() //there are more data than elements, this selects them
//.append("polyline") //appends path to data
//.attr("points", function(d) {return d})//we use a function in order to draw ALL of the fountains - loop through the fountains
//.attr("class", 'fountain')
//.style('fill','black')
//.style('stroke','none')
//.style('stroke-width','.5')
//p.enter().append("polyline") //use this line the first time we create a polyline
//.data(f2)
//.enter() //there are more data than elements, this selects them
//.append("polyline") //appends path to data
//.attr("points", function(d) {return d})//we use a function in order to draw ALL of the fountains - loop through the fountains
//.attr("class", 'fountain')
//.style('fill','none')
//.style('stroke','blue')
//.style('stroke-width','2')
}//this is where fountainText function ends
function removebuildingText(){
d3.selectAll('text.rink_position').remove()//geometry type, then class name
d3.selectAll('line.fLine').remove()
d3.selectAll('polyline.rink').remove()
}
c.enter().append("circle") // use this line everytime after the first time we create a 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.long,d.lat])[0]})//projection([d.long,d.lat])[0]
.attr("cy", function(d) {return projection([d.long,d.lat])[1]})
.attr('r',3)
.style('stroke','black')
.style('stroke-width','1')
.style('fill','cyan')
.style('fill-opacity','1')
var t = svg.selectAll("text") //use this line the first time we create a circle
.data(mypoints.features)
.enter() //there are more data than elements, this selects them
.append("text") //appends path to data
.attr("x", function(d) {return path2.centroid(d)[0]})
.attr("y", function(d) {return path2.centroid(d)[1]-7})
.style('font-family','helvetica')
.style('font-size','8px')
.style('text-anchor','middle')
.style('font-weight','bold')//use 'fill' to change color
.text(function(d) {return d.properties.name})
svg
.append("text")
.attr('x','500')
.attr('y','500')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Places to Know at RPI')
svg
.append("text")
.attr('x','500')
.attr('y','560')
.style('font-family','helvetica')
.style('font-size','12px')
.style('font-weight','bold')//use 'fill' to change color
.text('Building Location')
svg
.append("line")
.attr('x1','500')
.attr('y1','600')
.attr('x2','550')
.attr('y2','600')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
//var p = svg.selectAll("polyline") //use this line the first time we create a polyline
//.data(test1)
//.enter() //there are more data than elements, this selects them
//.append("polyline") //appends path to data
//.attr("points", function(d) {return d})//we use a function in order to draw ALL of the fountains - loop through the fountains
//.style('fill','none')
//.style('stroke','black')
//.style('stroke-width','2')
//p.enter().append("polyline") //use this line the first time we create a polyline
//.data(test2)
//.enter() //there are more data than elements, this selects them
//.append("polyline") //appends path to data
//.attr("points", function(d) {return d})//we use a function in order to draw ALL of the fountains - loop through the fountains
//.style('fill','cyan')
//.style('stroke','black')
//.style('stroke-width','2')
return svg.node();
}