# Google Map problems

**URL:** <https://www.ruby-forum.com/t/google-map-problems/60635>\
**Category:** Rails\
**Created:** [May 16, 2006, 1:03pm UTC](https://www.ruby-forum.com/t/google-map-problems/60635 "2006-05-16T13:03:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [May 16, 2006, 1:03pm UTC](https://www.ruby-forum.com/t/google-map-problems/60635/1 "2006-05-16T13:03:24Z")

</div>

I followed the setup from [http://cartographer.rubyforge.org/](http://cartographer.rubyforge.org/)  
but keep getting this error -

NoMethodError in Sandbox#map

Showing app/views/layouts/sandbox.rhtml where line #4 raised:

You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occured while evaluating nil.[]

Extracted source (around line #4):

1:   
2:   
3: Admin: \<%= controller.action\_name %\>  
4: \<%= gmaps\_header %\>  
5:

…Full Trace…

#{RAILS\_ROOT}/vendor/plugins/cartographer/lib/cartographer.rb:27:in  
`gmaps_header' #{RAILS_ROOT}/app/views/layouts/sandbox.rhtml:4:in `\_run\_rhtml\_layouts\_sandbox’

Any help would be great! thx

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [May 16, 2006, 1:28pm UTC](https://www.ruby-forum.com/t/google-map-problems/60635/2 "2006-05-16T13:28:20Z")

</div>

I had a similar problem. In my case, the issue was with keys.rb and my  
host  
name. Contrary to what the sample keys.rb led me to believe, the  
hostname  
command doesn’t return ‘localhost’ on my local system, or my public  
domain  
name on [hostingrails.com](http://hostingrails.com). Instead, it returns ‘My-Computer.local’ and  
‘[someserver].webserversystems.com’, respectively. Using the correct  
host  
names fixed the issue.

Alex.

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [May 16, 2006, 1:37pm UTC](https://www.ruby-forum.com/t/google-map-problems/60635/3 "2006-05-16T13:37:43Z")

</div>

Great but I’m still unclear on what to use instead of ‘hostname.’

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [May 16, 2006, 1:59pm UTC](https://www.ruby-forum.com/t/google-map-problems/60635/4 "2006-05-16T13:59:02Z")

</div>

You still use the hostname command, but you substitute the value that it  
returns in the when clauses below. For example:

GOOGLE\_MAPS\_API\_KEYS = case `hostname`.chomp # FIXME: this may not  
work on  
Windows?

```
when 'My-Computer.local'
  { 'directory/index' => 'ABQIAAAAAvd-Y2CbTw44IqBjXHWLGBTJw',
    'directory/search' => 'ABQIAAAAAvd-Y2CbTw44IqBjXHWLGBTJw',
    ...
  }

when 'servername.webserversystem.com'
  { 'directory/index' => 'laksjsdflkjsf',
    'directory/search' => 'sdlfkjdslkfjd',
    ...
  }

```

Alex.

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [May 16, 2006, 4:46pm UTC](https://www.ruby-forum.com/t/google-map-problems/60635/5 "2006-05-16T16:46:39Z")

</div>

Chang Sau S. wrote:

> Check out my JobMapper tutorial – it explains how to setup and use  
> cartographer. [http://saush.com/blog/?page\_id=48](http://saush.com/blog/?page_id=48)
> 
> Rob B. wrote:
> 
> > #{RAILS\_ROOT}/vendor/plugins/cartographer/lib/cartographer.rb:27:in  
> > `gmaps_header' #{RAILS_ROOT}/app/views/layouts/sandbox.rhtml:4:in `\_run\_rhtml\_layouts\_sandbox’
> > 
> > Any help would be great! thx
> 
> –  
> Sau S.
> 
> [http://blog.saush.com](http://blog.saush.com)  
> [http://www.projectible.com](http://www.projectible.com)  
> [http://jaccal.sourceforge.net](http://jaccal.sourceforge.net)

Great! Thank you both 🙂

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [May 16, 2006, 3:29pm UTC](https://www.ruby-forum.com/t/google-map-problems/60635/6 "2006-05-16T15:29:58Z")

</div>

Check out my JobMapper tutorial – it explains how to setup and use  
cartographer. [http://saush.com/blog/?page\_id=48](http://saush.com/blog/?page_id=48)

Rob B. wrote:

> #{RAILS\_ROOT}/vendor/plugins/cartographer/lib/cartographer.rb:27:in  
> `gmaps_header' #{RAILS_ROOT}/app/views/layouts/sandbox.rhtml:4:in `\_run\_rhtml\_layouts\_sandbox’
> 
> Any help would be great! thx

–  
Sau S.

[http://blog.saush.com](http://blog.saush.com)  
[http://www.projectible.com](http://www.projectible.com)  
[http://jaccal.sourceforge.net](http://jaccal.sourceforge.net)
