apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Auto Detect not working? #45

Closed jah2488 closed 13 years ago

jah2488 commented 13 years ago

I've set up auto detect location in my view according to the wik, but it just continues to show a map of the world and never attempt to retrieve the user's location. Perhaps I am doing it wrong?

<%= gmaps4rails({ "map_options" => { "container_id" => "connections_map_container", "auto_adjust" => "true", "detect_location" => "true", "center_on_user" => "true" } })%>

apneadiving commented 13 years ago

There are two helpers: gmaps and gmaps4rails.

The first accepts options, the second doesn't it just comes with the more common features.

See details in source code: https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/lib/gmaps4rails_helper.rb

jah2488 commented 13 years ago

Thanks

apneadiving commented 13 years ago

You're welcome, if ever you've another question please ask it on stackoverflow so that everyone could find the answer again: it's great for googling :)

jah2488 commented 13 years ago

WIll do, I'm actually still having trouble. I read the code and realized I should have been using the gmaps function and now the end source correctly addresses the options I specified, but the problem is that it still wont detect the location or ask for it.

<%= gmaps({
            "map_options" => {
                                "container_id" => "connections_map_container",
                                 "auto_adjust" => "true",
                                 "detect_location" => "true",
                                "center_on_user" => "true"
                             }      
          })%>

produces

<script type="text/javascript" charset="utf-8"> 
function gmaps4rails_init() {
    Gmaps4Rails.map_options.center_on_user = 'true'; 
   Gmaps4Rails.map_options.container_id = 'connections_map_container';
  Gmaps4Rails.map_options.detect_location = 'true';
 Gmaps4Rails.map_options.auto_adjust = 'true';
 Gmaps4Rails.initialize();
if(typeof gmaps4rails_callback == 'function') { gmaps4rails_callback(); }
}

window.onload = gmaps4rails_init;

However, I still have a simple world map loaded with no auto focus or detection. I'm sure its something I've done wrong. Any advice as to where to look will be great.

perhaps i should have moved this to stack overflow, lol.

jayandra commented 12 years ago

Hi Justin,

I think the value "true" is causing the problem. It should be boolean (true/false) not string ("true"/"false").

Hope it helps