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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:24:10+00:00 2026-05-31T06:24:10+00:00

I am trying to create a map with markers for Dispensers pulled from the

  • 0

I am trying to create a map with markers for Dispensers pulled from the DB. I am able to successfully do this, however, whenever I click on the markers the info box always appears over the same marker. The CORRECT dispenser’s info box is popping up on the map, but over the wrong marker! Has anyone run across this issue?

In my controller:

def find_map

    @location = Location.new
    @location.address = params[:location][:address]
    @latlon = @location.geocode
    @dispensers = Dispenser.near(@latlon)
    @numrecords = 0
    @lat = []
    @long = []
    @user_id = []
    @dispensers.each do |x|
      @lat[@numrecords] = x.latitude
      @long[@numrecords] = x.longitude
      @user_id[@numrecords] = x.user_id
      @numrecords += 1
    end 

    @map = Cartographer::Gmap.new( 'map')
    @map.zoom = :bound
    @icon = Cartographer::Gicon.new()
    @map.icons <<  @icon

    @count = 0
    @numrecords.times do 
      markername = "marker#{@count}"
      markername = Cartographer::Gmarker.new(:name=> "Business", :marker_type => "Building",
                             :position => [@lat[@count], @long[@count]],
                             :info_window_url => "/bio/#{@user_id[@count]}", :icon => @icon)

      @map.markers << markername
      @count += 1
    end

In my show.html.erb

  <%= raw Cartographer::Header.new.to_s %>
  <%= raw @map.to_html %>

  <div style="width:350px;height:250px;" id="map" > [Map]</div> 
  • 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-31T06:24:11+00:00Added an answer on May 31, 2026 at 6:24 am

    Great news, I figured it out. In the code below I had to add #{@count}
    to the business name… I am assuming the marker location is set with
    position and the info box location is set to the marker with
    the same :name attribute, which is presumably the last marker created
    by the loop.

    Thanks!

    markername = Cartographer::Gmarker.new(:name=> "Business#{@count}", :marker_type => "Building",
                                 :position => [@lat[@count], @long[@count]],
                                 :info_window_url => "/bio/#{@user_id[@count]}", :icon => @icon)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to center a google map on a single marker pulled from a
I am trying to create several markers along a route from google maps directions.
I am trying to create a map with 3 different markers, but currently each
I'm trying to create a Google Map with multiple markers on it, that loads
So I've got this script where I'm trying to add markers to a map
I'm trying to create a map, where the key is an int , and
I am trying to create a wpf control that will display a map image
I am trying to create a Google Map where the user can plot the
I am trying to add infowindows to markers/pushpins on the map. ATM, it is
I'm trying to create a map using gmap3.net plugin with Jquery, the script should

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.