0

我有一个应用程序,我在其中显示业务列表,然后显示与该业务相关的各种工作。工作地点工作得很好,但我想为应该在中心的业务添加一个标记,然后我可以对其进行自定义。

这是我的控制器/business_controller

def show
  @business = Business.find(params[:id])
  @distance = @business.service_area
  @jobs = Job.near(@business.location, @distance, {:order => :distance, :units => :km})
  @json = @jobs.to_gmaps4rails
  @mapoptions = {
       "map_options" => {"center_latitude" => @business.latitude, 
                         "center_longitude" => @business.longitude,
                         "auto_zoom" => true}
                 }
  respond_to do |format|
    format.html
  end
end

在我看来视图/企业/节目

<p><%= gmaps(:map_options => @mapoptions,"markers" => { "data" => @json }) %></p>

如何为营业地点创建标记?

4

1 回答 1

0

我会说:

markers_array = JSON.parse @jobs.to_gmaps4rails
markers_array << {lat: @business.latitude, lng: @business.longitude}
@json = markers_array.to_json
于 2012-10-16T07:49:24.030 回答