1

ActiveAdmin Rails 4谷歌靜態地圖問題 下面的代碼顯示了給定地址的正確緯度和長度,但在googlemap靜態地圖中使用它顯示完全不正確的地圖。任何你能想到的理由?如果我手動將lat和long放入http:map字符串中,則會顯示正確的地圖。Rails - 不正確的谷歌靜態地圖 - 拉特長期正確的給定地址 - 活動管理 - image_tag

ActiveAdmin.register Address do 
 

 
    permit_params :address, :longitude, :latitude 
 
    # See permitted parameters documentation: 
 
    # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters 
 
    # 
 
    # 
 
    # or 
 
    # 
 
    # permit_params do 
 
    # permitted = [:permitted, :attributes] 
 
    # permitted << :other if resource.something? 
 
    # permitted 
 
    # end 
 

 

 
    index do 
 
    selectable_column 
 
    id_column 
 
    column :address 
 
    actions 
 
    end 
 

 
    filter :address 
 

 
    form do |f| 
 
    f.inputs "Address Details" do 
 
     f.inputs :address 
 
    end 
 
    f.actions 
 
    end 
 

 
    show do 
 
    attributes_table do 
 
     # other rows 
 
     row :address 
 
     row :latitude 
 
     row :longitude 
 
     content do 
 
     render 'googlemap' 
 
     end 
 
     row :addressMap do 
 
    image_tag "https://maps.googleapis.com/maps/api/staticmap?center=#{:latitude},#{:longitude}&zoom=13&size=600x300&maptype=roadmap" 
 
     end 
 
    end 
 
    end 
 

 
end

回答

0

端向上插件它作爲部分

改變activeadmin地址形式/app/admin/address.rb

show do 
 

 
    attributes_table do 
 
     # other rows 
 
     row :address 
 
     row :latitude 
 
     row :longitude 
 
    end 
 

 
# renders app/views/admin/addresses/_googlemap.html.erb 
 
    render partial: 'googlemap' 
 
    active_admin_comments 
 
    end

和部分到/app/views/admin/adresses/_google.html.erb

<%= image_tag "https://maps.googleapis.com/maps/api/staticmap?center=#{@address.latitude},#{@address.longitude}&zoom=18&size=600x300&maptype=roadmap&format=png&visual_refresh=true&markers=size:mid%7Ccolor:red%7Clabel:1%7C#{@address.latitude},#{@address.longitude}" 
 
%>

相關問題