-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.html
50 lines (41 loc) · 1.26 KB
/
map.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
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
stroke: white;
stroke-width: 0.25px;
fill: grey;
}
</style>
<body>
<script src="js/d3.v3.min.js"></script>
<script src="js/topojson.js"></script>
<script>
var width = 760,
height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var g = svg.append("g");
// load and display the World
// cc= dc.geoChoroplethChart("#map");
d3.json("india-states.json", function(error,topology) {
var featureCollection = topojson.feature(topology, topology.objects.india);
var bounds = d3.geo.bounds(featureCollection);
var centerX = d3.sum(bounds, function(d) {return d[0];}) / 2,
centerY = d3.sum(bounds, function(d) {return d[1];}) / 2;
var projection = d3.geo.mercator()
.scale(600)
.center([centerX, centerY]);
path.projection(projection);
g.selectAll("path")
.data(featureCollection.features)
.enter()
.append("path")
.attr("d", path)
.overlayGeoJson(topology.features, "india", function(d){return d.properties.NAME_1;})
});
</script>
</body>
</html>