forked from odileeds/hexmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hexify.html
137 lines (123 loc) · 4.47 KB
/
hexify.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hexify</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8" />
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@ODILeeds">
<meta name="twitter:url" property="og:url" content="https://odileeds.org/projects/hexmaps/builder">
<meta name="twitter:title" property="og:title" content="Hex map builder">
<meta name="twitter:description" property="og:description" content="Create your own point-topped hex map from a data file.">
<meta name="twitter:image" property="og:image" content="https://odileeds.org/projects/hexmaps/hexmap.png">
<link rel="StyleSheet" href="resources/style.css" type="text/css" />
<script src="https://slowe.github.io/stuquery/js/stuquery.js"></script>
<script src="https://slowe.github.io/stuquery/js/stuquery.svg.js"></script>
<script src="resources/d3.v5.min.js"></script>
<script src="resources/stuquery.hexmap.js"></script>
<!--<script type="text/javascript" src="resources/builder.js"></script>-->
<script src="resources/hexify.js"></script>
<script>
var hexify;
S(document).ready(function(){
//builder = new Builder('hexmap',1080,1220,2);
hexify = new Hexify('hexify');
S('#restart').on('click',function(e){
hexify.start();
});
S('#jiggle').on('click',function(e){
hexify.start(true);
});
S('#gridify').on('click',function(e){
hexify.stop();
hexify.gridify();
hexify.draw();
S('#hexjson').html(hexify.makeHexJSON())
});
S('#save').on('click',function(e){
json = hexify.makeHexJSON();
hexify.save(json);
});
S('.example').on('click',function(e){
console.log('click')
S().ajax("imd-leeds.geojson",{
'type':'json',
'this': hexify,
'success':function(d){
this.data = JSON.parse(d);
this.loaded();
}
})
});
});
</script>
<style>
.dropzone {
border: 2px dashed #999999;
border-radius: 5px;
color: #333333;
padding: 25px;
text-align: center;
position: relative;
}
.dropzone.loaded {
border: 2px solid #333333;
color: #333333;
}
.dropzone.loaded .helpertext {
display: none;
}
.dropzone.drop {
background-color: #ddd;
}
.dropzone input {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
opacity: 0;
}
#hexify, #hexmap { width: 100%; height: 200px; }
#d3 { width: 100%; height: 800px; }
</style>
</head>
<body>
<div id="main">
<div class="b1-bg">
<div class="holder">
<div id="infobutton" style="float:right;">ℹ</div>
<h1>Hexify</h1>
</div>
</div>
<div class="holder">
<p>We like <a href="https://odileeds.org/blog/2017-05-08-mapping-election-with-hexes">creating hex maps</a> and sharing them as <a href="https://odileeds.org/projects/hexmaps/hexjson.html">HexJSON</a>. This tool aims to help you make a HexJSON file from a GeoJSON file containing polygons. It parses the polygons, finds neighbours and centres, then uses D3 to bring them together. Use the collapse/jiggle buttons below to adjust the objects. Use the gridify button to force the objects to sit on a hexagonal grid. Then save the output. If you don't have a handy GeoJSON file you can try the <a href="#hexify" class="example">example for Leeds LSOAs</a>. Once you have saved your HexJSON you might want to tidy it up in our <a href="builder.html">HexBuilder</a>.</p>
<div id="drop_zone" class="dropzone block">
<div class="helpertext">
Drop a GeoJSON file here (or click to browse files)<br />
<input id="standard_files" class="fileselect" type="file" title="browse" name="files[]" multiple="multiple" accept=".csv, .hexjson">
</div>
</div>
</div>
<div class="holder">
<div id="hexify"></div>
<div id="d3"><canvas style="width:100%;height:100%"></canvas></div>
<div style="text-align:center;">
<button id="restart" class="c1-bg">Collapse</button>
<button id="jiggle" class="c1-bg">Jiggle</button>
<button id="gridify" class="c1-bg">Gridify</button>
<button id="save" class="c10-bg">Save hexes as <span class="line">H</span>exJSON</button>
</div>
</div>
</div>
<footer class="b1-bg">
<div class="holder">
© 2017 <a href="https://odileeds.org/">ODI Leeds</a>. Released under an MIT license. <a href="https://github.com/odileeds/hexmaps">Source on Github</a>.
</div>
</footer>
<script src="https://odileeds.org/resources/odi.log.js"></script>
<script>
ODI.log.setup({'id':'odileeds','target':['odileeds.org','odileeds.github.io']}).add('action=view');
</script>
</body>
</html>