Google-Maps-for-Rails'出了问题。宝石

时间:2014-07-31 14:54:55

标签: ruby-on-rails

使用rails(4)gem 'Gogle-Maps-for-Rails'我有一个空白页面和js-error下面:

Uncaught TypeError: Cannot read property 'offsetWidth' of null main.js:39
yl main.js:39
am main.js:45
Map map.js?body=1:13
build builder.js?body=1:9
Gmaps.Objects.Handler.Handler.buildMap handler.js?body=1:18
(anonymous function)

我的Application.html.slim(简单):

/ encoding: utf-8
doctype html
html
  head
    meta charset="utf-8"
      meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
      meta name="viewport" content="width=device-width, initial-scale=1.0"
      title
        = page_title
      = csrf_meta_tags
      = stylesheet_link_tag "application", :media => "all"
      = favicon_link_tag 'favicon.ico', :rel => 'shortcut icon'

      script src="http://yandex.st/jquery/2.1.1/jquery.js"
      script src="http://yandex.st/underscore/1.6.0/underscore-min.js"
      script src="//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry"
      script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js'

      = javascript_include_tag "application"

body
  = yield

我的application.js文件:

//= require jquery
//= require jquery_ujs
//= require gmaps/google
//= require_tree .

handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map-canvas'}}, 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();
});

我的观点文件:

<div style='width: 800px;'>
  <div id="map-canvas" style='width: 800px; height: 400px;'></div>
</div>

可能是什么问题? 我认为这是有问题的优先级连接文件,但是......

0 个答案:

没有答案