# Dynamic Google Maps

**URL:** <https://www.ruby-forum.com/t/dynamic-google-maps/192015>\
**Category:** Rails\
**Created:** [July 22, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015 "2010-07-22T13:39:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 22, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/1 "2010-07-22T13:39:18Z")

</div>

My Rails application (Rails: V 2.1.0, Ruby: V 1.8.6) has on it, the  
ability for users to submit stories with their address information,  
which _will_ be atomised into appropriate fields.

A front end form allows users to submit stories, these stories are saved  
into a database table. They are then approved by my client and are  
displayed on a map.

Currently, this map is static and has to be changed by my client and  
re-embedded every time a story, with a postcode, is submitted. So, the  
map displays markers in the position of the postcode that is submitted  
with the story.

My question is: what would you recommend as the most effective way to  
automate this process to omit the need for my client to re-embed this  
code?

If my request is not clear, please post whatever else you may need.

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 22, 2010, 2:42pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/2 "2010-07-22T14:42:51Z")

</div>

You can use geokit ([GitHub - andre/geokit-gem: Geokit has a new home](http://github.com/andre/geokit-gem)) + (  
[http://github.com/andre/geokit-rails](http://github.com/andre/geokit-rails)) to geocode the story location and  
then  
use the YM4R-GM plugin to display the geocoded locations on a google map  
(  
[GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)) .

This article might be a bit dated, but it goes how you can interact with  
the  
YM4R-GM plugin:

> **[Adding Google Maps To Your Rails Applications | Developer.com](https://www.developer.com/open-source/adding-google-maps-to-your-rails-applications/)**
>
> In the months following publication of the final part of the very popular series on integrating Google Maps into PHP applications, I've spent quite a bit

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 22, 2010, 4:13pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/3 "2010-07-22T16:13:09Z")

</div>

Patrick R. wrote:

> You can use geokit ([GitHub - andre/geokit-gem: Geokit has a new home](http://github.com/andre/geokit-gem)) + (  
> [http://github.com/andre/geokit-rails](http://github.com/andre/geokit-rails)) to geocode the story location and  
> then  
> use the YM4R-GM plugin to display the geocoded locations on a google map  
> (  
> [GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)) .
> 
> This article might be a bit dated, but it goes how you can interact with  
> the  
> YM4R-GM plugin:  
> [http://www.developer.com/open/article.php/3757576/Adding-Google-Maps-To-Your-Rails-Applications.htm](http://www.developer.com/open/article.php/3757576/Adding-Google-Maps-To-Your-Rails-Applications.htm)

Does this generate a new map with each post code that I will pass or  
will it add a marker to the existing map?

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 23, 2010, 3:07pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/4 "2010-07-23T15:07:05Z")

</div>

a = Geokit::Geocoders::YahooGeocoder.geocode  
“#{ModelName.first.address}”  
a.ll

The above works in my console and returns the latitude and longitude as  
requested. I cannot get this to work in my (development) application.

When I attempt to run “script/plugin install  
svn://rubyforge.org/var/svn/ym4r/Plugins/GM/trunk/ym4r\_gm”, it returns  
“svn: not found”.

I assume this is a result of me missing subversion. Is there another way  
to install this plugin.

Alternatively, can anyone tell me any better ways of finding the geocode  
from an address or postcode?

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 23, 2010, 3:16pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/5 "2010-07-23T15:16:20Z")

</div>

> I assume this is a result of me missing subversion. Is there another way

to install this plugin.

Alternatively, can anyone tell me any better ways of finding the geocode

from an address or postcode?

[GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm) is a port onto github that I’ve used in  
the  
past.

If your model is using geokit (acts\_as\_mappable) , lat/lng are  
attributes  
from a provided address. Otherwise you have to geocode from calling  
that  
geocode method. acts\_as\_mappable provides convenience on top  
ActiveRecords  
find method as well for a geocodable model.

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 28, 2010, 8:14pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/6 "2010-07-28T20:14:18Z")

</div>

Pale H. wrote:  
[…]

> Installing the plugin from that port causes an error:
> 
> script/plugin install [GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)
> 
> - ./opensearch.xml  
> Plugin not found: [“[GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)”]

You may need to tack “.git” on to the end of that URL.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 28, 2010, 10:11am UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/7 "2010-07-28T10:11:50Z")

</div>

Patrick R. wrote:

> I assume this is a result of me missing subversion. Is there another way to install this plugin.
> 
> Alternatively, can anyone tell me any better ways of finding the geocode from an address or postcode?
> 
> [GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm) is a port onto github that I’ve used in  
> the  
> past.
> 
> If your model is using geokit (acts\_as\_mappable) , lat/lng are  
> attributes  
> from a provided address. Otherwise you have to geocode from calling  
> that  
> geocode method. acts\_as\_mappable provides convenience on top  
> ActiveRecords  
> find method as well for a geocodable model.

Installing the plugin from that port causes an error:

script/plugin install [GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)

- ./opensearch.xml  
Plugin not found: [“[GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)”]

Is there a way to produce the process of automatically adding custom  
markers with info-windows onto Google Maps without a plugin or gem using  
a provided address and postcode?

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [July 29, 2010, 3:59pm UTC](https://www.ruby-forum.com/t/dynamic-google-maps/192015/8 "2010-07-29T15:59:32Z")

</div>

Marnen Laibow-Koser wrote:

> Pale H. wrote:  
> […]
> 
> > Installing the plugin from that port causes an error:
> > 
> > script/plugin install [GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)
> > 
> > - ./opensearch.xml  
> > Plugin not found: [“[GitHub - queso/ym4r-gm: A port of the YM4R-GM plugin for rails, to github](http://github.com/queso/ym4r-gm)”]
> 
> You may need to tack “.git” on to the end of that URL.
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid

Thank you, Marnen.
