1

我使用的是mapstraction-rails插件,它在rails 2.3版本中工作正常。 當我升級的軌道版本3.2我已經開始收到此錯誤和地圖不會加載問題與mapstraction-rails JS

TypeError: this.location.toProprietary is not a function   

options.position = this.location.toProprietary(this.api); 

在螢火蟲我看到文件中的錯誤:在line 484

mxn.googlev3.core.js在軌使用

JQuery的版本是相同的2.3,即1.4

我使用的腳本標記

@map.initialize_map(:onload=>false) #=> in rails 2.3 

<%= @map.initialize_map(:onload=>false).first.html_safe %> #=> in rails 3.2 as this method returns the array with one element me in it. 

方法調用的函數whic h顯示地圖。

我檢查了這個元素this.location.toProprietary(this.api);在螢火蟲和它似乎「這」元素是不同的導軌3.2。請畫面截圖。

在導軌2.3

enter image description here

在軌道3.2

enter image description here

回答

1

有一個在插件LIB/mapstraction/latlon.rb一個文件。

它有一個方法:

def to_html 
    html =[] 
    html << "new mxn.LatLonPoint(#{@latitude},#{@longitude})" 
    return html 
end 

我修改返回值和「」對象在JavaScript是相同的,因爲它是在軌2.3版本。

修飾方法:

def to_html 
    html =[] 
    html << "new mxn.LatLonPoint(#{@latitude},#{@longitude})" 
    return html.join(" ").html_safe 
end