0
在地面上使用gmaps4rails进行地图功能:在控制器中结合变量
这个想法是在地图上显示房子的标记加上多个景点。
我有这段代码;
控制器:
@house = House.friendly.find(params[:id])
@location = @house.location
@sights_markers = Location.where("category = 'sights'")
records = [@location, @sights_markers].compact
@hash = Gmaps4rails.build_markers(records) do |location, marker|
marker.lat location.latitude
marker.lng location.longitude
end
观点:
<div id="map" style='width: 100%; height: 500px; margin-top: 10px; margin-bottom: 20px;' ></div>
<script type=text/javascript>
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
</script>
我得到发现 “纬度”
我在做什么错了一个错误message..no方法?
什么是你的位置表的方案?它有'纬度'字段吗? – DiegoSalazar 2014-09-29 17:05:33