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