Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
91 lines (82 sloc) 3.45 KB
<div class="contentMapMarkers">
<div id="map_canvas" style="height: 350px; width: 700px;"></div>
<%= javascript_include_tag 'http://maps.googleapis.com/maps/api/js?sensor=false&region=jp' %>
<%= javascript_include_tag '/_common/modules/map/js/map.js' %>
<%= javascript_tag do -%>
var map;
google.maps.event.addDomListener(window, 'load', function (event) {
<%- unless @all_markers.empty?
bounds = @all_markers.inject(min: {}, max: {}){|result, marker|
min = result[:min]
max = result[:max]
m_lat = marker.latitude.to_f
m_lon = marker.longitude.to_f
min[:lat] ||= m_lat
min[:lon] ||= m_lon
max[:lat] ||= m_lat
max[:lon] ||= m_lon
min[:lat] = m_lat if min[:lat] > m_lat
min[:lon] = m_lon if min[:lon] > m_lon
max[:lat] = m_lat if max[:lat] < m_lat
max[:lon] = m_lon if max[:lon] < m_lon
result
} -%>
map = new Map('map_canvas', <%= bounds[:min][:lat] %>, <%= bounds[:min][:lon] %>,
<%= bounds[:max][:lat] %>, <%= bounds[:max][:lon] %>);
<%- else -%>
map = new Map('map_canvas', default_latitude, default_longitude);
<%- end -%>
<%- @all_markers.each do |marker| -%>
map.set_marker('<%= "#{marker.latitude}_#{marker.longitude}" %>', <%= marker.latitude %>, <%= marker.longitude %>, '<%= marker.title %>',
'<%=raw simple_format(marker.window_text, {}, sanitize: false).gsub(/\r|\n/, '').gsub("'", '&#x27;') %>',
'<%= @content.icon_image(marker.icon_category || (marker.categories.include?(@specified_category) ? @specified_category
: marker.categories.first), true) %>');
<%- end -%>
});
<%- end -%>
<%- unless @markers.empty? -%>
<table>
<tr>
<th>カテゴリ</th>
<%- if @content.show_images? -%>
<th>画像</th>
<%- end -%>
<th>名称</th>
<th>地図</th>
</tr>
<%- @markers.each do |marker| -%>
<tr>
<td class="markerCategories">
<%- marker.categories.each do |category| -%>
<div class="<%= category.name -%>"><%= category.title %></div>
<%- end -%>
</td>
<%- if @content.show_images? -%>
<td class="markerImage">
<%- if marker.files.empty? -%>
<%- if @content.default_image.blank? -%>
画像がありません。
<%- else -%>
<%= image_tag @content.default_image %>
<%- end -%>
<%- else -%>
<%- unless (mi = marker_image(marker)).blank? -%>
<%= mi %>
<%- else -%>
<%- if @content.default_image.blank? -%>
画像がありません。
<%- else -%>
<%= image_tag @content.default_image %>
<%- end -%>
<%- end -%>
<%- end -%>
</td>
<%- end -%>
<td class="markerTitle"><%= marker.doc ? title_replace(marker.doc, @content.title_style) : marker.title %></td>
<td class="marker"><%= link_to '表示', '#map_canvas', onclick: "map.move_to('#{marker.latitude}_#{marker.longitude}')" %></td>
</tr>
<%- end -%>
</table>
<%- end -%>
<%= paginate @markers %>
</div>
You can’t perform that action at this time.