Ruby on Rails 在个人资料视图中在Google地图上显示地址
示例
在个人资料视图上,在列表中显示用户或组的个人资料字段以及googlemap上的地址字段。
- #app/views/profiles/show.html.haml
%h1 Contact Information
.profile_fields
= render @profile_fields
.google_map{data: address_fields: @address_fields.to_json }相应的@profile_fields和@address_fields在控制器中设置:
#app/controllers/profiles_controller.rb
class ProfilesController < ApplicationController
def show
#...
@profile_fields = @user_or_group.profile_fields
@address_fields = @profile_fields.where(type: 'ProfileFields::Address')
end
end初始化映射,放置标记,使用javascript设置缩放比例和其他映射设置。
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志