简体   繁体   English

mapstraction-rails JS的问题

[英]Issue with mapstraction-rails JS

I am using mapstraction-rails plugin and it worked fine in the rails 2.3 version. 我正在使用mapstraction-rails插件,它在rails 2.3版本中工作正常。 When I upgraded the rails version to 3.2 I have started getting this error and map does not load 当我将Rails版本升级到3.2时,我开始出现此错误,并且地图未加载

TypeError: this.location.toProprietary is not a function        

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

In the firebug I see the error in the file: mxn.googlev3.core.js at line 484. 在萤火虫中,我在第484行的文件mxn.googlev3.core.js中看到错误。

JQuery version is same as used in rails 2.3 ie 1.4 jQuery版本与Rails 2.3(即1.4)中使用的版本相同

I am using 我在用

@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.

method in the script tag to call the function which shows the map. 脚本标签中的方法调用显示地图的函数。

I have inspected the this element of the this.location.toProprietary(this.api); 我已经检查了this.location.toProprietary(this.api);this元素 in the firebug and it seems the "this" element is different in rails 3.2. 在萤火虫中,看来“ this”元素在Rails 3.2中有所不同。 Please the screen shots. 请截屏。

In rails 2.3 在Rails 2.3中

在此处输入图片说明

In rails 3.2 在导轨3.2中

在此处输入图片说明

There is a file in the plug-in lib/mapstraction/latlon.rb. 插件lib / mapstraction / latlon.rb中有一个文件。

It has a method: 它有一个方法:

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

I modified the return value and " this " object in the JavaScript was same as it was in the rails 2.3 version. 我修改了返回值,JavaScript中的“ this ”对象与rails 2.3版本中的对象相同。

Modified method: 修改方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM