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

  • SEARCH
  • Home
  • 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 7729245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:55:12+00:00 2026-06-01T05:55:12+00:00

I am unable to get a Javascript callback to work with gmaps4_rails when the

  • 0

I am unable to get a Javascript callback to work with gmaps4_rails when the map has loaded or is in the ‘idle’ state.

Based on the wiki and this other SO question Dynamically load Google Maps Markers with gmaps4rails I thought this would fire all of the alerts in this view:

<%= gmaps(:map_options => {:detect_location => true,
                           :center_on_user => true,
                           :auto_zoom => true,
                           :zoom => 12,
                           :auto_adjust => false},
           :markers => {:data => @json,   
                        :options => {:processsing => "@json",
                                     :list_container => "markers_list",
                                     :do_clustering => true
                                                       } }) %>
<ul id="markers_list"> </ul>

<script type="text/javascript" charset="utf-8">
  alert("About to register callback");
  Gmaps.map.callback = function() {
    alert("Map Loaded Callback Reached");
  }

  function gmaps4rails_callback() {
     alert("gmaps4_rails callback");
  }
</script>

<%= yield :scripts %>

Instead I only get the “about to register callback” alert. The other functions never seem to be called. I have a feeling I’m misunderstanding something about the namespace but any insight would be appreciated- I’m trying to get things setup to refresh from a JSON endpoint as the map moved but I’m not having a lot of luck getting past this first step of making sure I can trigger a callback.

I should note the map appears normally and my initial data is all there.

  • 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-06-01T05:55:13+00:00Added an answer on June 1, 2026 at 5:55 am

    As per documentation here, you must wrap the js code in a content_for :scripts

    Why?

    because gmaps4rails js code should be loaded first.

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

Sidebar

Related Questions

I'm unable to get this jquery statement to work on page load but it
I have been unable to get my UIWebView to change location based in javascript.
I am unable to get the correct title for this, please change the title
I'm unable to get the height of a page in javascript when the page
I got this file : http://graphicgiants.com/mmjaicc.js But i was unable to get the source.I
This address is has a console javascript that i build with a custom jquery
I am unable to get a highcharts plugin to render a chart in a
I'm unable to get the Central Maven repo index. I'm running Netbeans 7.0.1 and
I'm unable to get the length of the following JSON array object. Actually I
I have the following code and I am still unable to get Hibernate to

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.