Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 如何在标签中使用谷歌地图与gmaps4rails 2.0.3_Ruby On Rails 4_Gmaps4rails - Fatal编程技术网

Ruby on rails 4 如何在标签中使用谷歌地图与gmaps4rails 2.0.3

Ruby on rails 4 如何在标签中使用谷歌地图与gmaps4rails 2.0.3,ruby-on-rails-4,gmaps4rails,Ruby On Rails 4,Gmaps4rails,我使用的是gmaps4rails 2+rails 4.0.0+ruby 2.0+Geocoder+TwitterBootstrap 3+ajax_调用 假设我正在创建一个包含一些详细信息的表单,地址/位置创建工作正常,数据保存到带有纬度和经度的数据库中。=>好的 @我也能看到地图 但是,当我打算进行ajax调用simple的更新时,我正在刷新div,因为googlemap不会出现 同样的事情发生在#弹出#上,如果我要用它来更新纬度和经度,那么地图也不会出现 我猜gmap文件没有加载,或者我对aj

我使用的是gmaps4rails 2+rails 4.0.0+ruby 2.0+Geocoder+TwitterBootstrap 3+ajax_调用

假设我正在创建一个包含一些详细信息的表单,地址/位置创建工作正常,数据保存到带有纬度和经度的数据库中。=>好的

@我也能看到地图

但是,当我打算进行ajax调用simple的更新时,我正在刷新div,因为googlemap不会出现

同样的事情发生在#弹出#上,如果我要用它来更新纬度和经度,那么地图也不会出现

我猜gmap文件没有加载,或者我对ajax调用有问题?有什么解决办法吗

控制器的动作

  def update_content
      @geo_hash = CommonUtils.get_gmap_hash(@seo_content) #getting latitude & longitude
    end
update.js.erb

$('.container-fluid').html("<%= escape_javascript(render 'view_content', :seo_content => @seo_content) %>");
<script src="//maps.google.com/maps/api/js?v=3.13&amp;sensor=false&amp;libraries=geometry" type="text/javascript"></script>

<script type="text/javascript">
handler = Gmaps.build('Google');
handler.buildMap({ provider: { Zoom: 10 }, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%=raw @geo_hash.to_json unless @geo_hash.blank? %>);
});
handler.map.centerOn({ lat: <%=raw @geo_hash[0][:lat] unless @geo_hash.blank? %>, lng: <%=raw @geo_hash[0][:lng] unless @geo_hash.blank? %> })
</script>

显示您的代码。我个人总是使用ajax,所以我不知道gem和ajax都不该怪我,我不是在怪gem或ajax。。我只是假设你不能按你的方式插入javascript,不管是google脚本还是处理器调用。请了解您的基本信息我在application.js/=require gmap\u google/=require markerclusterer\u packed/=require下划线中添加了此文件
//= require gmaps_google
//= require markerclusterer_packed
//= require underscore