0
DBから取り出したディスペンサーのマーカーを使って地図を作成しようとしています。私は正常にこれを行うことができますが、マーカーをクリックするたびに情報ボックスは常に同じマーカー上に表示されます。 CORRECTディスペンサーの情報ボックスが地図上に表示されていますが、間違ったマーカーに!この問題を抱えている人はいますか?私のコントローラで地図作成者が正しい情報ボックスを表示しますが、間違ったマーカーで表示されます。
:
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
私show.html.erb
<%= raw Cartographer::Header.new.to_s %>
<%= raw @map.to_html %>
<div style="width:350px;height:250px;" id="map" > [Map]</div>