Skip to content

Commit 560097c

Browse files
committed
first commit
0 parents  commit 560097c

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
1. dojo一覧を取得する
2+
3+
```
4+
% sh curl.sh
5+
```
6+
7+
2. geojsonファイルに変換する
8+
9+
```
10+
% ruby convert.rb
11+
```
12+
13+
3. http serverを起動し、ブラウザで閲覧する
14+
15+
```
16+
% npm install -g http-server
17+
% http-server
18+
% open http://localhost:8080
19+
```

convert.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'json'
2+
3+
dojos = []
4+
5+
File.open("dojos.json") do |file|
6+
dojos = JSON.load(file)
7+
end
8+
9+
features = []
10+
dojos.each do |dojo|
11+
if dojo["geoPoint"]
12+
features << {
13+
"type" => "Feature",
14+
"geometry" => {
15+
"type" => "Point",
16+
"coordinates" => [dojo["geoPoint"]["lon"], dojo["geoPoint"]["lat"]]
17+
},
18+
"properties" => {
19+
"description" => "#{dojo['name']}<br /><a target='_blank' href='http://zen.coderdojo.com/dojos/#{dojo['urlSlug']}'>zen</a>"
20+
}
21+
}
22+
end
23+
end
24+
25+
geojson = {
26+
"type": "FeatureCollection",
27+
"features": features
28+
}
29+
30+
File.open("dojos.geojson", "w") do |file|
31+
JSON.dump(geojson, file)
32+
end

curl.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
2+
"query": {
3+
"verified": 1,
4+
"deleted": 0,
5+
"fields$": [
6+
"name",
7+
"geo_point",
8+
"stage",
9+
"url_slug",
10+
"start_time",
11+
"end_time",
12+
"private",
13+
"frequency",
14+
"alternative_frequency",
15+
"day"
16+
]
17+
}
18+
}' 'https://zen.coderdojo.com/api/2.0/dojos' -o dojos.json

dojos.geojson

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

dojos.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

index.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>dojos map</title>
7+
<style>
8+
body,
9+
html {
10+
width: 100%;
11+
height: 100%;
12+
margin: 0;
13+
padding: 0;
14+
}
15+
16+
.geolonia {
17+
width: 100%;
18+
height: 100%;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
24+
<script id="geojson" type="application/json">
25+
</script>
26+
<div
27+
class="geolonia"
28+
data-geojson="./dojos.geojson"
29+
data-lat="35.6809591"
30+
data-lng="139.7673068"
31+
data-zoom="7"
32+
data-marker="off"
33+
data-geolocate-control="on"
34+
></div>
35+
36+
<script
37+
type="text/javascript"
38+
src="https://cdn.geolonia.com/v1/embed?geolonia-api-key=YOUR-API-KEY"
39+
></script>
40+
</body>
41+
</html>

0 commit comments

Comments
 (0)