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
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.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 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