1

I am using mapstraction-rails plugin and it worked fine in the rails 2.3 version. When I upgraded the rails version to 3.2 I have started getting this error and map does not load

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.

JQuery version is same as used in rails 2.3 i.e 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); in the firebug and it seems the "this" element is different in rails 3.2. Please the screen shots.

In rails 2.3

enter image description here

In rails 3.2

enter image description here

Naveen Agarwal
  • 559
  • 4
  • 18

1 Answers1

1

There is a file in the plug-in 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.

Modified method:

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