【问题标题】:Rails_admin geocoder using google mapsRails_admin 地理编码器使用谷歌地图
【发布时间】:2015-08-08 12:20:02
【问题描述】:

您好,我目前正在做一个项目,但他们需要 rails_admin 中的谷歌地图才能进行地理编码,以便他们可以直接使用谷歌地图,而不仅仅是在执行之前获取位置坐标。

我已经检查了https://github.com/beyondthestory/rails_admin_map_field,但问题是我收到了这个错误

Fetching git://github.com/jasonl/rails_admin_map_field.git
fatal: remote error: 
  Repository not found.
Retrying git clone 'git://github.com/jasonl/rails_admin_map_field.git' "/home/simplybel/.rvm/gems/ruby-2.1.2/cache/bundler/git/rails_admin_map_field-b98ef0a93697bab8818013f8738b246fe83822a9" --bare --no-hardlinks --quiet due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git://github.com/jasonl/rails_admin_map_field.git' "/home/simplybel/.rvm/gems/ruby-2.1.2/cache/bundler/git/rails_admin_map_field-b98ef0a93697bab8818013f8738b246fe83822a9" --bare --no-hardlinks --quiet` in directory /home/simplybel/gamification/rigpirateprivate has failed.
fatal: remote error: 
  Repository not found.
Retrying git clone 'git://github.com/jasonl/rails_admin_map_field.git' "/home/simplybel/.rvm/gems/ruby-2.1.2/cache/bundler/git/rails_admin_map_field-b98ef0a93697bab8818013f8738b246fe83822a9" --bare --no-hardlinks --quiet due to error (3/3): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git://github.com/jasonl/rails_admin_map_field.git' "/home/simplybel/.rvm/gems/ruby-2.1.2/cache/bundler/git/rails_admin_map_field-b98ef0a93697bab8818013f8738b246fe83822a9" --bare --no-hardlinks --quiet` in directory /home/simplybel/gamification/rigpirateprivate has failed.
fatal: remote error: 
  Repository not found.
Git error: command `git clone

'git://github.com/jasonl/rails_admin_map_field.git' “/home/simplybel/.rvm/gems/ruby-2.1.2/cache/bundler/git/rails_admin_map_field-b98ef0a93697bab8818013f8738b246fe83822a9” --bare --no-hardlinks --quiet` 在目录中 /home/simplybel/gamification/rigpirateprivate 失败了。

现在我不知道该做什么或如何使它工作任何帮助都会有很大帮助!使用 rails 4.2 ,设计和地理编码器

【问题讨论】:

    标签: google-maps rails-admin ruby-on-rails-4.2 rails-geocoder


    【解决方案1】:

    应该可以在showlistmodel 视图中使用 iframe embed google maps

    <iframe
      width="600"
      height="450"
      frameborder="0" style="border:0"
      src="https://www.google.com/maps/embed/v1/place?key=API_KEY
        &q=Space+Needle,Seattle+WA" allowfullscreen>
    </iframe>
    

    您需要为使用上面代码块中提到的iframe 内容呈现地图的字段设置pretty_value

    RailsAdmin.config do |config|
      config.model 'Shop' do
        show do
          field :location do
            pretty_value do
              iframe_content(value).html_safe
            end
        end
      end
    end
    

    这里iframe_content 呈现iframe,谷歌地图要求你把它放在你的页面上。需要调用html_safe,以便rails 了解此html 内容已被清理,不会造成任何安全风险,否则会将其解释为纯字符串。

    iframe_content 必须是在 Shop 模型中定义的方法。

    您可能需要对此解决方案进行一些更改,它可能无法直接使用。希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多