質問編集履歴
2
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -69,3 +69,69 @@
|
|
69
69
|
end
|
70
70
|
|
71
71
|
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
因みにmap/index.html.erbを下記のように書き直すと正しく表示されます。
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<div style='width: 100%; '>
|
90
|
+
|
91
|
+
<div id="map" style='width: 100%; height: 400px;'></div>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<script type="text/javascript">
|
98
|
+
|
99
|
+
handler = Gmaps.build('Google');
|
100
|
+
|
101
|
+
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
|
102
|
+
|
103
|
+
markers = handler.addMarkers([
|
104
|
+
|
105
|
+
{
|
106
|
+
|
107
|
+
"lat": 0,
|
108
|
+
|
109
|
+
"lng": 0,
|
110
|
+
|
111
|
+
"picture": {
|
112
|
+
|
113
|
+
"url": "http://people.mozilla.com/~faaborg/files/shiretoko/firefoxIcon/firefox-32.png",
|
114
|
+
|
115
|
+
"width": 32,
|
116
|
+
|
117
|
+
"height": 32
|
118
|
+
|
119
|
+
},
|
120
|
+
|
121
|
+
"infowindow": "hello!"
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
]);
|
126
|
+
|
127
|
+
handler.bounds.extendWith(markers);
|
128
|
+
|
129
|
+
handler.fitMapToBounds();
|
130
|
+
|
131
|
+
});
|
132
|
+
|
133
|
+
</script>
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
```
|
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,3 +9,63 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
どうしたらしっかり表示できるでしょうか?
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
map/index.html.erb
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
<div style='width: 800px;'>
|
22
|
+
|
23
|
+
<div id="map" style='width: 800px; height: 400px;'></div>
|
24
|
+
|
25
|
+
</div>
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
<script type="text/javascript">
|
30
|
+
|
31
|
+
handler = Gmaps.build('Google');
|
32
|
+
|
33
|
+
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
|
34
|
+
|
35
|
+
markers = handler.addMarkers(<%=raw @hash.to_json %>);
|
36
|
+
|
37
|
+
handler.bounds.extendWith(markers);
|
38
|
+
|
39
|
+
handler.fitMapToBounds();
|
40
|
+
|
41
|
+
});
|
42
|
+
|
43
|
+
</script>
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
MapController
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
|
55
|
+
def index
|
56
|
+
|
57
|
+
@items = Item.all
|
58
|
+
|
59
|
+
@hash = Gmaps4rails.build_markers(@items) do |item, marker|
|
60
|
+
|
61
|
+
marker.lat item.latitude
|
62
|
+
|
63
|
+
marker.lng item.longitude
|
64
|
+
|
65
|
+
marker.json({title: item.title})
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
```
|