回答編集履歴
1
その後の解決
test
CHANGED
@@ -1 +1,231 @@
|
|
1
1
|
回答が付かないので、一旦閉じます
|
2
|
+
|
3
|
+
その後ですが、自力で解決しましたので、下記に全コードアップしておきます。
|
4
|
+
|
5
|
+
```javascript
|
6
|
+
|
7
|
+
<!DOCTYPE html>
|
8
|
+
|
9
|
+
<html>
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
<head>
|
14
|
+
|
15
|
+
<meta charset="UTF-8">
|
16
|
+
|
17
|
+
<title>leaflet + riot</title>
|
18
|
+
|
19
|
+
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0" />
|
20
|
+
|
21
|
+
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.css" />
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
<script src="https://npmcdn.com/leaflet@1.0.0-rc.1/dist/leaflet.js"></script>
|
26
|
+
|
27
|
+
<script src="https://cdn.jsdelivr.net/npm/riot@3.13/riot+compiler.min.js"></script>
|
28
|
+
|
29
|
+
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script-->
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
<style type="text/css">
|
34
|
+
|
35
|
+
/* id:# class:. */
|
36
|
+
|
37
|
+
* {padding: 0;margin: 0;}
|
38
|
+
|
39
|
+
html, body, #map {
|
40
|
+
|
41
|
+
height: 100%;
|
42
|
+
|
43
|
+
font: 11pt "Meiryo UI","Meiryo","ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro","MS Pゴシック",sans-serif;}
|
44
|
+
|
45
|
+
</style>
|
46
|
+
|
47
|
+
</head>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
<body>
|
52
|
+
|
53
|
+
<!--MAP-->
|
54
|
+
|
55
|
+
<div id="map"></div>
|
56
|
+
|
57
|
+
<!--定義タグ-->
|
58
|
+
|
59
|
+
<mytag></mytag>
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!--myboxタグをRiotで定義-->
|
64
|
+
|
65
|
+
<script type="riot/tag">
|
66
|
+
|
67
|
+
<mytag>
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
<style scoped> /* ローカルスタイル */
|
72
|
+
|
73
|
+
:scope {
|
74
|
+
|
75
|
+
display: block;
|
76
|
+
|
77
|
+
background-color: #fff;
|
78
|
+
|
79
|
+
font-size: 1.0rem;
|
80
|
+
|
81
|
+
line-height: 1.0em;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
p {line-height: 0.3em;}
|
86
|
+
|
87
|
+
</style>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
<!-- mytagの内容 -->
|
92
|
+
|
93
|
+
<iframe width="400" height="230" src="{src}" frameborder="0" allowfullscreen></iframe>
|
94
|
+
|
95
|
+
<p>名称: {opts.properties.name} </p>
|
96
|
+
|
97
|
+
<p>撮影日:{opts.properties["撮影日"]}</p>
|
98
|
+
|
99
|
+
<p>位置: {opts.geometry.coordinates}</p>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<!--GetEmbed_url呼び出し-->
|
104
|
+
|
105
|
+
this.src = GetEmbed_url(opts.properties.iframe);
|
106
|
+
|
107
|
+
</mytag>
|
108
|
+
|
109
|
+
</script>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<script type="text/javascript">
|
114
|
+
|
115
|
+
function GetEmbed_url(tmp){
|
116
|
+
|
117
|
+
//console.log("");
|
118
|
+
|
119
|
+
//alert ("");
|
120
|
+
|
121
|
+
// "iframe" : "<iframe width=\"400\" height=\"225\" src=\"https://www.youtube.com/embed/GnwjtKiT8n0?rel=0\" frameborder=\"0\" allowfullscreen></iframe>"
|
122
|
+
|
123
|
+
var result = [];
|
124
|
+
|
125
|
+
tmp = tmp.replace(/ /g,' ');
|
126
|
+
|
127
|
+
var result = tmp.split(' ');
|
128
|
+
|
129
|
+
tmp = result[3];
|
130
|
+
|
131
|
+
tmp = tmp.replace('src="', "");
|
132
|
+
|
133
|
+
tmp = tmp.replace(/"/g, "");
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
/**********/
|
138
|
+
|
139
|
+
tmp = tmp.replace("https://youtu.be/", "https://www.youtube.com/embed/");
|
140
|
+
|
141
|
+
return tmp.replace("https://www.youtube.com/watch?v=", "https://www.youtube.com/embed/");
|
142
|
+
|
143
|
+
/***************/
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
</script>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<script> //src="script.js
|
152
|
+
|
153
|
+
var map = L.map("map").setView([35.362222, 138.731389], 5);
|
154
|
+
|
155
|
+
L.tileLayer("https://cyberjapandata.gsi.go.jp/xyz/pale/{z}/{x}/{y}.png", {
|
156
|
+
|
157
|
+
attribution: "<a href='http://maps.gsi.go.jp/development/ichiran.html'>淡色地図 (地理院タイル)</a>"
|
158
|
+
|
159
|
+
}).addTo(map);
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
/*****fecth()メソッドに対象となるjsonのパスを指定し*******/
|
164
|
+
|
165
|
+
fetch("https://cyberjapandata.gsi.go.jp/xyz/20160414kumamoto_0416uav/2/3/1.geojson")
|
166
|
+
|
167
|
+
/****then()で繋げてjsonをオブジェクト形式に変換する****/
|
168
|
+
|
169
|
+
.then(function(response) {
|
170
|
+
|
171
|
+
return response.json();
|
172
|
+
|
173
|
+
})
|
174
|
+
|
175
|
+
/*****JSONデータを扱った処理など*******/
|
176
|
+
|
177
|
+
.then(function(geojson) {
|
178
|
+
|
179
|
+
//console.log(geojson);
|
180
|
+
|
181
|
+
var layer = L.geoJson(geojson, {
|
182
|
+
|
183
|
+
pointToLayer: function(feature, latlng) {
|
184
|
+
|
185
|
+
return L.marker(latlng, {
|
186
|
+
|
187
|
+
title: feature.properties.name
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
}).bindPopup(function(marker) {
|
192
|
+
|
193
|
+
var div = document.createElement("div");
|
194
|
+
|
195
|
+
riot.mount(div, "mytag", marker.feature);
|
196
|
+
|
197
|
+
return div;
|
198
|
+
|
199
|
+
}, {
|
200
|
+
|
201
|
+
maxWidth: 400,
|
202
|
+
|
203
|
+
minWidth: 400
|
204
|
+
|
205
|
+
});
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
});
|
210
|
+
|
211
|
+
map.addLayer(layer).fitBounds(layer.getBounds());
|
212
|
+
|
213
|
+
})
|
214
|
+
|
215
|
+
/****エラーを検出****/
|
216
|
+
|
217
|
+
.catch(function() {
|
218
|
+
|
219
|
+
console.log(arguments);
|
220
|
+
|
221
|
+
});
|
222
|
+
|
223
|
+
</script>
|
224
|
+
|
225
|
+
</body>
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
</html>
|
230
|
+
|
231
|
+
```
|