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 marker itself just gets attached to the marker with
the same :name attribute, which is presumably the last marker created
by the loop.

Thanks!

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

@map.markers << markername
@count += 1
end
On Mon, Mar 12, 2012 at 9:05 PM, Abram wrote:
Walter. Thanks for your response. Unfortunately this doesn't seem to
be the problem. W3C came up clean!
On Mon, Mar 12, 2012 at 8:06 AM, Walter Lee Davis wrote:
On Mar 11, 2012, at 2:56 PM, Abram wrote:

Thanks for that Colin.

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>

Thanks again
Validate the rendered HTML in the W3C validator, see if you have duplicate HTML Element IDs somehow. That's what this sounds like precisely.

Walter
On Mon, Mar 12, 2012 at 5:10 AM, Colin Law wrote:
On 10 March 2012 21:12, Abram wrote:
Hi guys (and gals),

The code formatting is so nice on SO.com, so I thought I'd just share
my post in hopes that someone from the group can help.

http://stackoverflow.com/questions/9643786/cartographer-shows-correct-info-box-but-over-wrong-marker
I may be wrong but I think that most here will not want to take the
time to go over there to look at your problem.  If you want to ask a
question here it is best to ask it.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 7 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedMar 10, '12 at 9:13p
activeMar 12, '12 at 1:52p
posts7
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase