# ym4r/GM GLatLng and RJS

**URL:** <https://www.ruby-forum.com/t/ym4r-gm-glatlng-and-rjs/69412>\
**Category:** Rails\
**Created:** [September 20, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/ym4r-gm-glatlng-and-rjs/69412 "2006-09-20T22:09:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@shaper](https://www.ruby-forum.com/u/shaper)\
**Post date:** [September 20, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/ym4r-gm-glatlng-and-rjs/69412/1 "2006-09-20T22:09:57Z")

</div>

I’m stepping through a variant of the tutorial for the ym4r/GM mapping  
library here:

> **[thepochisuperstarmegashow.com](http://thepochisuperstarmegashow.com/2006/06/02/ym4r-georuby-spatial-adapter-demo/)**
>
> This domain may be for sale!

and with heavily simplified code I’m basically doing this in the  
controller (assume @map and @zoom are all good):

```
    @center = GLatLng.new([result.latitude, result.longitude])

```

and in the .rjs file:

```
     page << @map.set_center(@center, @zoom)

```

And using Firebug to look at the javascript that’s returned, I get  
this:

```
  map.setCenter(#<Ym4r::GmPlugin::GLatLng:0xb7530778>,12);

```

which makes it pretty clear that the GLatLng object is having to\_s  
called on it rather than the ym4r’s MappingObject.to\_javascript method.  
I’m still debugging but thought perhaps others have hit this issue.  
As far as I can tell this is exactly how both tutorials walk through  
doing this, so I’m not sure what’s going on.

Appreciate any suggestions or will let folks know what I find.

- Walter Korman – [http://www.lemurware.com](http://www.lemurware.com)

---

<div class="post-metadata">

**Author:** ![shaper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@shaper](https://www.ruby-forum.com/u/shaper)\
**Post date:** [September 21, 2006, 1:16am UTC](https://www.ruby-forum.com/t/ym4r-gm-glatlng-and-rjs/69412/2 "2006-09-21T01:16:14Z")

</div>

shaper wrote:

> And using Firebug to look at the javascript that’s returned, I get  
> this:
> 
> ```
> map.setCenter(#<Ym4r::GmPlugin::GLatLng:0xb7530778>,12);
> 
> ```
> 
> which makes it pretty clear that the GLatLng object is having to\_s  
> called on it rather than the ym4r’s MappingObject.to\_javascript method.  
> I’m still debugging but thought perhaps others have hit this issue.  
> As far as I can tell this is exactly how both tutorials walk through  
> doing this, so I’m not sure what’s going on.

Solution: don’t have both the ym4r\_gm and ym4r\_mapstraction plugins  
installed in the same app at the same time. Removing the mapstraction  
plugin fixes the problem. It appears there is an ambiguous reference  
to the MappingObject, which resides in mapping.rb in both plugins.  
Insidious and evil. Foolish me for having both installed as I toyed  
about. May others learn from my mistake.

- Walter

---

<div class="post-metadata">

**Author:** ![shaper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@shaper](https://www.ruby-forum.com/u/shaper)\
**Post date:** [September 21, 2006, 1:30am UTC](https://www.ruby-forum.com/t/ym4r-gm-glatlng-and-rjs/69412/3 "2006-09-21T01:30:15Z")

</div>

I use the plug-in with great success, along with RJS.

I think some of the tutorials are a bit out of date.

Personally, I use this to set the map center:

@map.center\_zoom\_init([@last\_location.latitude,  
@last\_location.longitude],  
15)

I believe the init method is required to be called at least once, no?

---

<div class="post-metadata">

**Author:** ![shaper](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@shaper](https://www.ruby-forum.com/u/shaper)\
**Post date:** [February 9, 2010, 7:26pm UTC](https://www.ruby-forum.com/t/ym4r-gm-glatlng-and-rjs/69412/4 "2010-02-09T19:26:30Z")

</div>

shaper wrote:

> shaper wrote:
> 
> > And using Firebug to look at the javascript that’s returned, I get  
> > this:
> > 
> > ```
> > map.setCenter(#<Ym4r::GmPlugin::GLatLng:0xb7530778>,12);
> > 
> > ```
> > 
> > which makes it pretty clear that the GLatLng object is having to\_s  
> > called on it rather than the ym4r’s MappingObject.to\_javascript method.  
> > I’m still debugging but thought perhaps others have hit this issue.  
> > As far as I can tell this is exactly how both tutorials walk through  
> > doing this, so I’m not sure what’s going on.
> 
> Solution: don’t have both the ym4r\_gm and ym4r\_mapstraction plugins  
> installed in the same app at the same time. Removing the mapstraction  
> plugin fixes the problem. It appears there is an ambiguous reference  
> to the MappingObject, which resides in mapping.rb in both plugins.  
> Insidious and evil. Foolish me for having both installed as I toyed  
> about. May others learn from my mistake.
> 
> - Walter

Thank you for posting this! I’ve been struggling with the same  
problemâ€¦now on to the next one! 😛
