我收到以下错误
ReferenceError:找不到变量: google
当我第一次呈现一个页面时,应该显示谷歌地图。页面的第一部分显示正确,但在底部缺少带地图的整个div。单击刷新后,页面将正确呈现。这个错误在dev和prod中是相同的,并显示在包含google地图的应用程序中的页面。不知道怎么修。以下是有关Safari控制台中错误的更多详细信息:
TypeError: 'undefined' is not a constructor (evaluating 'new google.maps.OverlayView()')
TypeError: 'undefined' is not a constructor (evaluating 'new google.maps.OverlayView')下面是产生上述错误的其中一个页面的代码。
<% provide(:title, 'Current TBMs Location and Statistics') %>
<% if signed_in? %>
<h3>TBMs location and statistics - Today's date: <%=@current_date%></h3>
<div>
<div class="pull-left">
<%= link_to "Daily Progress", progresstable_path, class: "btn btn-sm btn-primary" %>
<%= link_to "Daily Stats", tbms_stats_table_path, class: "btn btn-sm btn-primary" %>
</div>
<div class="pull-right">
<%= "Today's: " %>
<%= link_to "Schedule", schedules_path, class: "btn btn-sm btn-primary" %>
<%= link_to "Readings List", all_readings_path, class: "btn btn-sm btn-primary" %>
</div>
</div>
</br></br>
<div class="container">
<div class="pull-left">
<h5>
<%= "TBM ID: " %>
<%= @tbms_progress_W.tbm_id %>
<%= "aka TBM1 or 26900"%>
</h5>
<%= "Last Date: " %>
<%= @tbms_progress_W.daily_date %>
<%= "Max Station: " %>
<%= number_with_precision @tbm_w_location, precision: 2 %>
<%= "Status: " %>
<%= @tbms_progress_W.tbm_status %>
<%= "Since: " %>
<%= @tbm_w_days_since %>
</br>
<%= "Days total: " %>
<%= @tbm_w_days_since_commissioned %>
<%= "Days working: "%>
<%= @tbm_w_working_days %>
<%= "Days stopped: " %>
<%= @tbm_w_stopped_days %>
<%= "Located between: " %>
<% if @smp_w_after.present? %>
<%= @smp_w_after.smp_id %>
<% else %>
<%= "Unknown" %>
<% end %>
<%= " and: " %>
<% if @smp_w_before.present? %>
<%= @smp_w_before.smp_id %>
<% else %>
<%= "Unknown" %>
<% end %>
</br>
<%= "Total excavated: " %>
<% if @tbm_w_location.present? %>
<%= @tbm_w_location - @tbms_W_initial.max_station %> <%="m"%>
<% else %>
<%= "Unknown" %>
<% end %>
<%= "Excavation speed: " %>
<% if @tbm_w_location.present? %>
<%= number_with_precision (@tbm_w_location - @tbms_W_initial.max_station) / @tbm_w_working_days, precision: 2 %> <%="m/day"%>
<% else %>
<%= "Unknown" %>
<% end %>
<%= "Excavated since yesterday cut off time: " %>
<% if @tbm_w_location.present? %>
<%= @tbm_w_location - @tbms_progress_W2.max_station %> <%="m"%>
<% else %>
<%= "Unknown" %>
<% end %>
</br>
<%= "Average distance excavated in the previous 24 hours: " %>
<% if @tbm_w_location.present? %>
<%= @tbms_progress_W2.max_station - @tbms_progress_W1.max_station %> <%="m"%>
<% else %>
<%= "Unknown" %>
<% end %>
<% if @tbm_w_lat == nil or @tbm_w_lon == nil %>
</br>
<%= "TBM latitude and longitude cannot be calculated, missing near SMP northing and easting" %>
</br>
<%= "TBM approximate address: not available" %>
<% else %>
</br>
<%= "Latitude: " %>
<%= number_with_precision @tbm_w_lat, precision: 6 %>
<%= " Longitude: " %>
<%= number_with_precision @tbm_w_lon, precision: 6 %>
<%= "Address: " %>
<% if @tbm_w_result.empty? %>
<%= "Cannot calculate TBM W address, Geocoder unavailable" %>
<% else %>
<%= @tbm_w_result[0].address %>
<% end %>
<% end %>
<% if @current_date != @tbms_progress_W.daily_date %>
<h6 class="error-message">
<%= "Today's location for TBM W is not loaded" %>
<%= " Last TBM W recorded date was: " %>
<%=@tbms_progress_W.daily_date %>
</h6>
<% end %>
<h6> SMPs ahead of the current TBM W location: </h6>
<% if @tbm_w_location.present? and @smps_w_ahead.present? %>
<ol>
<li>
<%= "First line: " %>
<%= @smps_w_ahead[0].smp_id %> <%= @smps_w_ahead[0].final_inst_status %> <%= @smps_w_ahead[1].smp_id %> <%= @smps_w_ahead[1].final_inst_status %>
</li>
<li>
<%= "Second line: " %>
<%= @smps_w_ahead[2].smp_id %> <%= @smps_w_ahead[2].final_inst_status %> <%= @smps_w_ahead[3].smp_id %> <%= @smps_w_ahead[3].final_inst_status %>
</li>
<li>
<%= "Third line: " %>
<%= @smps_w_ahead[4].smp_id %> <%= @smps_w_ahead[4].final_inst_status %> <%= @smps_w_ahead[5].smp_id %> <%= @smps_w_ahead[5].final_inst_status %>
</li>
<li>
<%= "Fourth line: " %>
<%= @smps_w_ahead[6].smp_id %> <%= @smps_w_ahead[6].final_inst_status %> <%= @smps_w_ahead[7].smp_id %> <%= @smps_w_ahead[7].final_inst_status %>
</li>
</ol>
<% else %>
<%= "Unknown" %>
<% end %>
<h5>
<%= "TBM ID: " %>
<%= @tbms_progress_E.tbm_id %>
<%= "aka TBM2 or 27000"%>
</h5>
<%= "Last Date: " %>
<%= @tbms_progress_E.daily_date %>
<%= "Max Station: " %>
<%= number_with_precision @tbm_e_location, precision: 2 %>
<%= "Status: " %>
<%= @tbms_progress_E.tbm_status %>
<%= "Since: " %>
<%= @tbm_e_days_since %>
</br>
<%= "Days total: " %>
<%= @tbm_e_days_since_commissioned %>
<%= "Days working: "%>
<%= @tbm_e_working_days %>
<%= "Days stopped: " %>
<%= @tbm_e_stopped_days %>
<%= "Located between: " %>
<% if @smp_e_after.present? %>
<%= @smp_e_after.smp_id %>
<% else %>
<%= "Unknown" %>
<% end %>
<%= " and: " %>
<% if @smp_e_before.present? %>
<%= @smp_e_before.smp_id %>
<% else %>
<%= "Unknown" %>
<% end %>
</br>
<%= "Total excavated: " %>
<% if @tbm_e_location.present? %>
<%= @tbm_e_location - @tbms_E_initial.max_station %> <%="m"%>
<% else %>
<%= "Unknown" %>
<% end %>
<%= "Excavation speed: " %>
<% if @tbm_e_location.present? %>
<%= number_with_precision (@tbm_e_location - @tbms_E_initial.max_station) / @tbm_e_working_days, precision: 2 %> <%="m/day"%>
<% else %>
<%= "Unknown" %>
<% end %>
<%= "Excavated since yesterday cut off time: " %>
<% if @tbm_e_location.present? %>
<%= @tbm_e_location - @tbms_progress_E2.max_station %> <%="m"%>
<% else %>
<%= "Unknown" %>
<% end %>
</br>
<%= "Average distance excavated in the previous 24 hours: " %>
<% if @tbm_e_location.present? %>
<%= @tbms_progress_E2.max_station - @tbms_progress_E1.max_station %> <%="m"%>
<% else %>
<%= "Unknown" %>
<% end %>
<% if @tbm_e_lat == nil or @tbm_e_lon == nil %>
</br>
<%= "TBM latitude and longitude cannot be calculated, missing near SMP northing and easting" %>
</br>
<%= "TBM approximate address: not available" %>
<% else %>
</br>
<%= "Latitude: " %>
<%= number_with_precision @tbm_e_lat, precision: 6 %>
<%= " Longitude: " %>
<%= number_with_precision @tbm_e_lon, precision: 6 %>
<%= "Address: " %>
<% if @tbm_e_result.empty? %>
<%= "Cannot calculate TBM E address, Geocoder unavailable" %>
<% else %>
<%= @tbm_e_result[0].address %>
<% end %>
<% end %>
<% if @current_date != @tbms_progress_E.daily_date %>
<h6 class="error-message">
<%= "Today's location for TBM E is not loaded" %>
<%= " Last TBM E recorded date was: " %>
<%=@tbms_progress_E.daily_date %>
</h6>
<% end %>
<h6> SMPs ahead of the current TBM E location: </h6>
<% if @tbm_e_location.present? and @smps_e_ahead.present? %>
<ol>
<li>
<%= "First line: " %>
<%= @smps_e_ahead[0].smp_id %> <%= @smps_e_ahead[0].final_inst_status %> <%= @smps_e_ahead[1].smp_id %> <%= @smps_e_ahead[1].final_inst_status %>
</li>
<li>
<%= "Second line: " %>
<%= @smps_e_ahead[2].smp_id %> <%= @smps_e_ahead[2].final_inst_status %> <%= @smps_e_ahead[3].smp_id %> <%= @smps_e_ahead[3].final_inst_status %>
</li>
<li>
<%= "Third line: " %>
<%= @smps_e_ahead[4].smp_id %> <%= @smps_e_ahead[4].final_inst_status %> <%= @smps_e_ahead[5].smp_id %> <%= @smps_e_ahead[5].final_inst_status %>
</li>
<li>
<%= "Fourth line: " %>
<%= @smps_e_ahead[6].smp_id %> <%= @smps_e_ahead[6].final_inst_status %> <%= @smps_e_ahead[7].smp_id %> <%= @smps_e_ahead[7].final_inst_status %>
</li>
</ol>
<% else %>
<%= "Unknown" %>
<% end %>
</div>
</div>
<div style='width: 800px;'>
<div id="map" style='width: 920px; height: 500px;'></div>
</div>
<% else %>
<%= render 'instruments/unsigned' %>
<% end %>
<script src="//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry" type="text/javascript"></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js' type='text/javascript'></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js' type='text/javascript'></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js' type='text/javascript'></script>
<script type="text/javascript">
buildMap (<%=raw @hash.to_json %>);
</script>发布于 2014-09-22 12:28:15
问题解决:把所有的链接参考到css和js在application.html.erb,后转弯处和好的错误。似乎浏览器需要在应用程序中的页面x进行渲染之前缓存所有这些。
https://stackoverflow.com/questions/25337650
复制相似问题