_google_maps.rhtml
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<%= content_tag('script', '', :src => GoogleMaps.api_url, :type => 'text/javascript') %>
<div style='text-align: center;'>
<div id="map"></div>
</div>
<script type='text/javascript'>
function putMarker(lat, lng, title, summary) {
var point = new GLatLng(lat, lng);
var options = { 'title' : title };
var marker = new GMarker(point, options);
map.addOverlay(marker);
GEvent.addListener(marker, 'click', function() {
map.openInfoWindowHtml(point, summary);
});
}
window.unload = function() {
GUnload();
};
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
new GKeyboardHandler(map);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
centerPoint = new GLatLng(-15.0, -50.1419);
map.setCenter(centerPoint, <%= GoogleMaps.initial_zoom.to_json %>);
<%
missed = false
@results.each do |name,results|
results.each do |item|
if item.lat && item.lng
%>
putMarker(<%= item.lat.to_json %>, <%= item.lng.to_json %>, <%= item.name.to_json %>, <%= display_profile_info(item).to_json %>);
<%
else
missed = true
end
end
end
%>
<% if missed %>
<%= "map.openInfoWindowHtml(centerPoint, %s);" % _("One or more items don't have geographical information, and won't be shown in the map. Choose \"Display in list\" to see them.").to_json %>
<% end %>
}
</script>