0
我試圖實現leaflet-rails,提供了一個類似谷歌的地理編碼器。瓣葉軌寶石 - 「未定義的方法圖」
我收到從下面的第三行此錯誤消息:
undefined method `map' for
#<#<Class:0x007ff7052f47a8>:0x007ff6dca48758> Did you mean? tap
那就是:
<div class="col-sm-4">
<div id="mapid" style = "height: 400px; width: 200px; "></div>
<%= map(:center => {
:latlng => [51.52238797921441, -0.08366235665359283],
:zoom => 18
}) %>
</div>
我寫了這個代碼,就像他們建議:
配置/初始化/單張.RB:
Leaflet.tile_layer = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
Leaflet.attribution = '?'
Leaflet.max_zoom = 18
index.html.erb:
<div id="mapid" style = "height: 400px; width: 200px; "></div>
<%= map(:center => {
:latlng => [51.52238797921441, -0.08366235665359283],
:zoom => 18
}) %>
application.scss。
/*
*= require flexslider.css
*= require blueimp-gallery
*= require blueimp-gallery-indicator
*= require blueimp-gallery-video
*= require leaflet
*/
// Graphical variables
@import "config/variables";
@import "config/bootstrap_variables";
// External libraries
@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome";
// Your CSS
@import "layout/index";
@import "components/index";
@import "pages/index";
@import "vendor/index";
的application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require underscore
//= require jquery-fileupload/basic
//= require cloudinary/jquery.cloudinary
//= require attachinary
//= require jquery.flexslider
//= require blueimp-gallery
//= require blueimp-gallery-fullscreen
//= require blueimp-gallery-indicator
//= require blueimp-gallery-video
//= require jquery.blueimp-gallery
//= require leaflet
//= require_tree .
我跑bundle install
。
應該在哪裏map
叫?
嘗試'寶石「傳單護欄」,要求:「小葉護欄/ view_helpers」' – teddybear
你好,謝謝你的回答,對我也沒有工作。我用gemfile替換了這一行,並在沒有任何改變的情況下運行了bundle。 –
你可以發佈你的application.css和.js嗎? – teddybear