File tree Expand file tree Collapse file tree 6 files changed +112
-0
lines changed Expand file tree Collapse file tree 6 files changed +112
-0
lines changed Original file line number Diff line number Diff line change
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
+ ```
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
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 >
You can’t perform that action at this time.
0 commit comments