-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
97 lines (75 loc) · 2.55 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
.selected{
fill: #333333;
}
.unselected{
fill: pink;
}
svg{
background: powderblue;
}
.country {
fill: pink;
stroke: #333333;
stroke-width: 1;
}
</style>
<body>
<!-- <div id="map"></div> -->
<!-- Bringing in d3 library -->
<script src="https://d3js.org/d3.v4.min.js"></script>
<!-- bringing in topojson file for creating lightweight maps -->
<script src="https://unpkg.com/topojson-client@3"></script>
<!-- Bringing in the location data -->
<script src="https://raw.githubusercontent.com/kgarrity22/location/master/location2.csv"></script>
<script>
var width = window.innerWidth,
height = window.innerHeight,
centered,
clicked_point;
var projection = d3.geoMercator()
.translate([width/2, height/2]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var g = svg.append("g");
var path = d3.geoPath()
.projection(projection);
d3.json("https://unpkg.com/world-atlas@1/world/110m.json", function (error, topology) {
var countries = topojson.feature(topology, topology.objects.countries).features
g.selectAll(".country")
.data(countries)
.enter()
.append("path")
.attr("class", "country")
.attr("d", path)
.on('mouseover', function(d){
d3.selectAll(".country")
d3.select(this).attr("style", "fill: yellow");
})
.on('mouseout', function(d){
d3.selectAll(".country")
d3.select(this).attr("style", "fill: pink")
});
d3.csv("https://raw.githubusercontent.com/kgarrity22/location/master/location2.csv", function (data){
svg.selectAll("circles")
.data(data)
.enter()
.append("cricle")
.attr("cx", function(d) {
return projection([d.long, d.lat])[0];
})
.attr("cy", function(d) {
return projection([d.long, d.lat])[1];
})
.attr("r", 15)
.attr("d", circle)
.style("fill", "red");
});
});
</script>
</body>
</html>