【问题标题】:Issue with mapstraction-rails JSmapstraction-rails JS 的问题
【发布时间】:2013-10-15 12:19:09
【问题描述】:

我正在使用 mapstraction-rails 插件,它在 rails 2.3 版本中运行良好。 当我将 rails 版本升级到 3.2 时,我开始收到此错误并且地图无法加载

TypeError: this.location.toProprietary is not a function        

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

在萤火虫中,我看到文件中的错误:mxn.googlev3.core.js 在第 484 行。

JQuery 版本与 Rails 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.

脚本标签中的方法来调用显示地图的函数。

我在萤火虫中检查了 this.location.toProprietary(this.api); 的 this 元素,似乎“this”元素在导轨 3.2.请截图。

在轨道 2.3 中

在轨道 3.2 中

【问题讨论】:

    标签: jquery ruby-on-rails ruby-on-rails-3 google-maps mapstraction


    【解决方案1】:

    插件lib/mapstraction/latlon.rb中有一个文件。

    它有一个方法:

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

    我修改了返回值,JavaScript 中的“this”对象与 Rails 2.3 版本中的相同。

    修改方法:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-07
      • 1970-01-01
      • 1970-01-01
      • 2013-06-08
      • 1970-01-01
      • 2012-06-05
      相关资源
      最近更新 更多