Javascript gmaps4rails 2.4.6未捕获参考错误:未定义Gmaps
我花了几个小时阅读StackOverflow的解决方案,并尝试了所有方法,但仍然没有找到解决方案 我要走了 未捕获参考错误:未定义GMAP 从 我已经多次重新安排我的脚本标签,试图解决这个问题。它们现在位于我的“application.html.erb”布局中,如下所示:Javascript gmaps4rails 2.4.6未捕获参考错误:未定义Gmaps,javascript,ruby-on-rails,gmaps4rails,Javascript,Ruby On Rails,Gmaps4rails,我花了几个小时阅读StackOverflow的解决方案,并尝试了所有方法,但仍然没有找到解决方案 我要走了 未捕获参考错误:未定义GMAP 从 我已经多次重新安排我的脚本标签,试图解决这个问题。它们现在位于我的“application.html.erb”布局中,如下所示: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <!-- Always force
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>NomadSpaces</title>
<meta name="description" content="">
<meta name="author" content="Christopher Dodd">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<%= favicon_link_tag '/favicon.ico' %>
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<%= stylesheet_link_tag('application', :media => 'all') %>
<%= stylesheet_link_tag('spaces', :media => 'all') %>
<%= javascript_include_tag 'application', "data-turbolinks-track" => true %>
<%= yield :javascripts %> // Code that calls Gmaps
<%= javascript_include_tag 'gmaps_api.js' %>
<%= javascript_include_tag 'markerclusterer_packed.js' %>
</head>
<body>
<%= yield %>
</body>
</html>
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require underscore
//= require gmaps/google
//= require bootstrap
//= require_tree .
详细介绍了违规功能:
handler.buildMap({
internal: {id: 'sidebar_builder'},
provider: {
zoom: 15,
center: new google.maps.LatLng(53.385873, -1.471471),
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: mapStyle
}
}, function(){
var json_array = <%=raw @hash.to_json %>;
var markers = handler.addMarkers(json_array);
_.each(json_array, function(json, index){
json.marker = markers[index];
});
createSidebar(json_array);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
地图应显示的空间:
<div class="row">
<div id="map-area">
<div id="sidebar_builder" class="visible"></div>
<div class="ball"></div>
<p class="loading">LOADING SPACES</p>
</div>
<div id='sidebar_container'></div>
</div>
请帮忙 我让一位朋友查看了我的项目,发现错误的原因是application.js没有编译,因此gmaps javascript没有加载到页面上 有了这些知识,我们回到了堆栈溢出,并尝试更改ruby版本来解决这个问题。不幸的是,这不起作用
为了解决这个问题,我启动了一个新的rails项目,并从旧项目中复制了重要的代码。我的application.js文件现在已正确加载,一切正常 您是否尝试重新启动服务器?谢谢您的评论。是的,在handler=Gmaps.build'Google';之后你有这个代码吗?handler.buildMap{provider:{},internal:{id:'map'}},函数{markers=handler.addMarkers[{lat:0,lng:0,图片:{url:https://addons.cdn.mozilla.net/img/uploads/addon_icons/13/13028-64.png,宽度:36,高度:36},信息窗口:你好!}];handler.bounds.extendWithmarkers;handler.fitMapToBounds;};这就是我拥有的:handler.buildMap{internal:{id:'sidebar_builder'},provider:{zoom:15,center:new google.maps.LatLng53.385873,-1.471471,mapTypeId:google.maps.mapTypeId.ROADMAP,styles:maptyle},函数{var json_array=;var markers=handler.addMarkersjson_array;389; eachjson_array,functionjson,index{json.marker=markers[index];};然后:createSidebarjson_array;handler.bounds.extendWithmarkers;handler.fitMapToBounds;
<div class="row">
<div id="map-area">
<div id="sidebar_builder" class="visible"></div>
<div class="ball"></div>
<p class="loading">LOADING SPACES</p>
</div>
<div id='sidebar_container'></div>
</div>