回答編集履歴
1
test
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
+
解決したコード
|
1
2
|
```ここに言語を入力
|
2
3
|
<script>
|
3
|
-
|
4
|
+
function initMap(){
|
5
|
+
<% @places.each_with_index do |place,i| %>
|
6
|
+
<% unless current_user.checkcomp(place) %>
|
4
7
|
//Idの数だけマップを出力
|
5
|
-
<% @places.each_with_index do |place,i| %>
|
6
|
-
<% unless current_user.checkcomp?(place) %>
|
7
|
-
<div id="todo-maps<%=i%>" date-lat="<%=place.latitude%>" date-lng="<%=place.longitude%>" style='width: 100%; height: 500px;'></div>
|
8
|
-
|
8
|
+
document.getElementById('todo-maps<%=i%>');
|
9
|
-
|
9
|
+
var latlng = new google.maps.LatLng(<%=place.latitude%>,<%=place.longitude%>);
|
10
|
+
|
10
|
-
|
11
|
+
map = new google.maps.Map(document.getElementById('todo-maps<%=i%>'),{
|
11
|
-
|
12
|
+
center: {lat: <%=place.latitude%>, lng: <%=place.longitude%>},
|
12
|
-
|
13
|
+
zoom: 18
|
13
|
-
|
14
|
+
});
|
14
|
-
|
15
|
+
marker = new google.maps.Marker({
|
15
|
-
|
16
|
+
position: latlng,
|
16
|
-
|
17
|
+
map: map
|
17
|
-
|
18
|
+
});
|
18
|
-
|
19
|
+
<%end%>
|
19
|
-
|
20
|
+
<%end%>
|
20
|
-
|
21
|
+
}
|
21
22
|
</script>
|
22
23
|
```
|