gmaps4rails 2.4.6 unCaught Ошибка ссылки: Gmaps не определены

Я часами читал решения на StackOverflow и перепробовал все, но так и не нашел решения.

я собираюсь

Ошибка ссылки unCaught: Gmaps не определены

Из

handler = Gmaps.build('Google');

Я много раз переставлял теги сценария, чтобы попытаться исправить это. Теперь они находятся в моем макете 'application.html.erb', который выглядит так:

<!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>

Мой файл application.js выглядит так:

    // 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>

Пожалуйста помоги!


person christhefreelancer    schedule 07.04.2015    source источник
comment
Вы пробовали перезапускать сервер?   -  person Andrew Hendrie    schedule 07.04.2015
comment
Спасибо за ваш комментарий. да   -  person christhefreelancer    schedule 07.04.2015
comment
У вас есть этот код после handler = Gmaps.build('Google'); ?handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ markers = handler.addMarkers([ { "lat": 0, "lng": 0, "picture": { "url": "https://addons.cdn.mozilla.net/img/uploads/addon_icons/13/13028-64.png", "width": 36, "height": 36 }, "infowindow": "hello!" } ]); handler.bounds.extendWith(markers); handler.fitMapToBounds(); });   -  person Andrew Hendrie    schedule 07.04.2015
comment
Вот что у меня есть: handler.buildMap({internal: {id: 'sidebar_builder'}, provider: { zoom: 15, center: new google.maps.LatLng(53.385873, -1.471471), mapTypeId: google.maps.MapTypeId .ROADMAP, стили: mapStyle } }, function(){ var json_array = ‹%=raw @hash.to_json %›; var markers = handler.addMarkers(json_array); _.each(json_array, function(json, index){ json.marker = маркеры[индекс];});   -  person christhefreelancer    schedule 07.04.2015
comment
Затем: createSidebar(json_array); обработчик.bounds.extendWith (маркеры); обработчик.fitMapToBounds();   -  person christhefreelancer    schedule 07.04.2015
comment
Я не хочу это читать, лол. Добавьте это к своему вопросу, отформатированному все красиво?   -  person Andrew Hendrie    schedule 07.04.2015
comment
Извиняюсь. Немного нуба в StackOverflow   -  person christhefreelancer    schedule 07.04.2015
comment
Я просто обновлю вопрос   -  person christhefreelancer    schedule 07.04.2015


Ответы (1)


Я попросил друга просмотреть мой проект и обнаружил, что причиной ошибки было то, что application.js не компилировался, и поэтому javascript gmaps не был загружен на страницу.

Вооружившись этими знаниями, мы вернулись к Stack Overflow и попытались изменить версию ruby, чтобы исправить это. К сожалению, это не сработало.

Чтобы решить эту проблему, я начал новый проект rails и скопировал важный код из старого проекта. Мой файл application.js теперь загружается правильно, и все снова работает.

person christhefreelancer    schedule 09.04.2015