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 7816797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:00:08+00:00 2026-06-02T06:00:08+00:00

I am using Gmaps4rails. It’s working really fine. But now I got an issue

  • 0

I am using Gmaps4rails. It’s working really fine. But now I got an issue in trying geolocate my user via the browser.

My view:

   <%= gmaps(:markers => { :data => @json},
        :map_options => { :container_class => "map_container",:id => "map",:class => "gmaps4rails_map"},
        :scripts     => :none ) %>

        <% content_for :scripts do %>
        <script type="text/javascript">
         Gmaps.map.callback = function() {
          setInterval(function(){Gmaps.map.createMarker({
                        Lat: Gmaps.map.userLocation.lat(),
                        Lng: Gmaps.map.userLocation.lng(), 
                        rich_marker: null, 
                        marker_picture: "/images/icon.png",
                       })},10000)
            }


        </script>
        <% end %>

I tried a setinterval method for the browser geolocation delay as discussed in How do I display the user's location with a marker in gmaps4rails?

my gmaps coffee script

  detect_location: true  # should the browser attempt to use geolocation detection features of HTML5?
  center_on_user: true   # centers map on the location detected through the browser

I got this error in my google chrome console.

Uncaught TypeError: Cannot read property ‘0’ of undefined
Gmaps4Rails.Gmaps4Rails.createImageAnchorPositiongmaps4rails.base.js:377
Gmaps4RailsGoogle.Gmaps4RailsGoogle.createMarkergmaps4rails.googlemaps.js:127
(anonymous function)

What am I missing ?? Thanks

Stephane

  • 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-02T06:00:16+00:00Added an answer on June 2, 2026 at 6:00 am

    You should do:

     setInterval( function(){
     Gmaps.map.createMarker({
       Lat: Gmaps.map.userLocation.lat(),
       Lng: Gmaps.map.userLocation.lng(), 
       rich_marker: null, 
       marker_picture: "https://a248.e.akamai.net/assets.github.com/images/modules/about_page/octocat.png?1315937507",
       marker_width: 80,
       marker_height: 80,
       marker_anchor: null,
       shadow_anchor: null,
       shadow_picture: null,
       shadow_width: null,
       shadow_height: null
       })},10000)
    

    Verbose but wasn’t supposed to be used directly 🙂

    BTW, it’s not a good implementation:

    what if the user takes more time to accept geolocation (or simply refuses)?

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

Sidebar

Related Questions

I'm using gmaps4rails and really enjoying it, but, I missed setting some properties, such
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
I'm using gmaps4rails on my project. This gem works amazing but i have a
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
i've got confused trying to change the map controls like said here But don`t
I'm using gmaps4rails and I have a good amount of markers, now when I
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using C#, I need a class called User that has a username, password, active
I'm using gem gmaps4rails and gem cells both of which by themselves work brilliantly.
I've been using the gmaps4rails gem for a while in rails 3.1 and it

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.