Skip to content

Commit

Permalink
Add place address in infowindows
Browse files Browse the repository at this point in the history
  • Loading branch information
yamamuteki committed May 6, 2016
1 parent dc196eb commit 088f634
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/models/bus_stop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ class BusStop < ActiveRecord::Base
has_many :bus_routes, -> { order('operation_company, line_name') }, through: :bus_route_bus_stops
reverse_geocoded_by :latitude, :longitude
def address
# お試し実装。
Geocoder.address("#{self.latitude},#{self.longitude}").to_s
end
def formatted_address
# DBにキャッシュしたら返す。
''
end
end
2 changes: 1 addition & 1 deletion app/models/place.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Place
extend Forwardable

def_delegators :@spot, :name
def_delegators :@spot, :name, :formatted_address
def_delegator :@spot, :place_id, :id
def_delegator :@spot, :lat, :latitude
def_delegator :@spot, :lng, :longitude
Expand Down
7 changes: 6 additions & 1 deletion app/views/application/_infowindow.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
<%= link_to bus_stop.name, bus_stop_or_place_path(bus_stop) %>
<div>
<%= link_to bus_stop.name, bus_stop_or_place_path(bus_stop) %>
</div>
<div>
<%= bus_stop.formatted_address %>
</div>

0 comments on commit 088f634

Please sign in to comment.