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.
Feel free to answer back via email if you don’t have an SO account.
Thanks!
Abram
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.
Feel free to answer back via email if you don’t have an SO account.
Thanks!
Abram
On 10 March 2012 21:12, Abram [email protected] 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.
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
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 %>
Thanks again
On Mar 11, 2012, at 2:56 PM, Abram wrote:
def find_map
@lat[@numrecords] = x.latitude
@count = 0
end
In my show.html.erb<%= raw Cartographer::Header.new.to_s %>
<%= raw @map.to_html %>[Map]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
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
Walter. Thanks for your response. Unfortunately this doesn’t seem to
be the problem. W3C came up clean!
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 <[email protected]>
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 D. <[email protected]> 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 L. <[email protected]> wrote:On 10 March 2012 21:12, Abram <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to [email protected].
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 [email protected]. To unsubscribe from this group, send email to [email protected]. 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 [email protected]. To unsubscribe from this group, send email to [email protected]. 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
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs