Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4579710
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:40:49+00:00 2026-05-21T20:40:49+00:00

Trying to get gmaps4rails to work in a rails 3 project. I have everything

  • 0

Trying to get gmaps4rails to work in a rails 3 project. I have everything setup according to the demo but my view only shows the map controls on top of a gray background where the map should be. Tried it in chrome and safari. Any thoughts?

In the model:

acts_as_gmappable :process_geocoding => false

def gmaps4rails_address
  "#{address}, #{city}, #{state} #{zip}"
end

In the controller:

@venues = Venue.limit(5)
@venue_map_data = @venues.to_gmaps4rails

In the view:

<%= gmaps4rails(@venue_map_data) %>

In the application.html.erb layout:

<!DOCTYPE html>
<html>
<head>
  <title>MapTest</title>
  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>
  <%= yield :head %>
</head>
<body>
   <%= yield %>
   <%= yield :scripts %>
</body>
</html>

Javascript stuff:

<script src="/javascripts/gmaps4rails.js" type="text/javascript"></script> 
<script type="text/javascript" src='http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_compiled.js'></script> 
<script type="text/javascript" charset="utf-8"> 
function gmaps4rails_init() {
    Gmaps4Rails.map_options.auto_adjust = true;
    Gmaps4Rails.initialize();
    Gmaps4Rails.markers = [{"longitude": "37.742956", "latitude": "-122.421695"},
           {"longitude": "37.742668", "latitude": "-122.421735"},
           {"longitude": "37.742578", "latitude": "-122.42178"},
           {"longitude": "37.742862", "latitude": "-122.421575"},
           {"longitude": "37.743123", "latitude": "-122.421485"}];
    Gmaps4Rails.create_markers();
    if(typeof gmaps4rails_callback == 'function') { gmaps4rails_callback(); }
}

function gmaps4rails_loadScript() {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.google.com/maps/api/js?sensor=false&libraries=geometry&callback=gmaps4rails_init";
    document.body.appendChild(script);
}

window.onload = gmaps4rails_loadScript;

</script> 

Venue data gathered in @venues:
name, address, city, state, zip, latitude, longitude
Altena Restaurant, 3346 Mission St, San Francisco, CA, 94110, -122.421695, 37.742956
LA Morena Latinoamericana, 3391 Mission St, San Francisco, CA, 94110, -122.421735, 37.742668
Costa Del Sol II, 3385 Mission St, San Francisco, CA, 94110, -122.42178, 37.742578
El Amigo Bar, 3355 Mission St, San Francisco, CA, 94110, -122.421575, 37.742862
Thirty Three Hundred Club, 3300 Mission St, San Francisco, CA, 94110, -122.421485, 37.743123

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:40:50+00:00Added an answer on May 21, 2026 at 8:40 pm

    Damn, just got it after 20 minutes looking back and forth…

    Nothing to do with the gem: look at your coordinates:

    Gmaps4Rails.markers = [{"longitude": "37.742956", "latitude": "-122.421695"},
           {"longitude": "37.742668", "latitude": "-122.421735"},
           {"longitude": "37.742578", "latitude": "-122.42178"},
           {"longitude": "37.742862", "latitude": "-122.421575"},
           {"longitude": "37.743123", "latitude": "-122.421485"}]
    

    You put your latitudes in the longitude table and vice-versa.

    Longitude = [-180, 180]

    Latitude = [-90, 90]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying get my first simple project in rails to run. I have
I'm trying get only the Saturdays and Sundays between two dates, but I don't
Trying to get tag-it to work with an ajax call. Everything works so far.
Trying to get started on view testing in Rails 3. I want to validate
I've been trying to get gmaps4rails working for hours. I think it's the load
I am trying get Struts 2 and Tiles to work and I am using
Trying to get an ASP application deployed; it worked for a while but then
Hi am trying get GPS using network provider and GPS provider. but am getting
Hello everyone I been trying get php uploader working but having a lot of
I've been at this for 12+ exhausting hours trying get it to work on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.