Last active
August 29, 2015 14:01
-
-
Save brooksreese/a7533da01f410ed623df to your computer and use it in GitHub Desktop.
Revisions
-
brooksreese revised this gist
May 21, 2014 . 1 changed file with 0 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,18 +38,6 @@ end end marker.infowindow "<b>#{location.name}</b> <br/><i>#{location.address}</i> <br/><i>#{location.city} #{location.state}., #{location.zip}</i> -
brooksreese created this gist
May 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ def set_gmap_markers markers = { :ddtcs => ActionController::Base.helpers.asset_path('marker_DDTCS.png'), :chms => ActionController::Base.helpers.asset_path('marker_CHMS.png'), :all => ActionController::Base.helpers.asset_path('marker_CHMS-DDTCS.png') } @hash = Gmaps4rails.build_markers(@locations) do |location, marker| marker.lat location.latitude marker.lng location.longitude ################################## # code before refactoring ################################## # if location.services.length == 2 # marker.picture({ :url => markers[:all], :width => 32, :height => 32 }) # end # if location.services.length == 1 && location.services[0].name == 'CHMS' # marker.picture({ :url => markers[:chms], :width => 32, :height => 32 }) # end # if location.services.length == 1 && location.services[0].name == 'DDTCS' # marker.picture({ :url => markers[:ddtcs], :width => 32, :height => 32 }) # end ################################## # code after refactoring ################################## case location.services.length when 2 marker.picture({ :url => markers[:all], :width => 32, :height => 32 }) when 1 if location.services[0].name == 'CHMS' marker.picture({ :url => markers[:chms], :width => 32, :height => 32 }) else marker.picture({ :url => markers[:ddtcs], :width => 32, :height => 32 }) end end ################################## # refactored case statement to if ################################## if location.services.length != 0 # zero would mean no services were selected if location.services.length == 1 else marker.picture({ :url => markers[:all], :width => 32, :height => 32 }) end end marker.infowindow "<b>#{location.name}</b> <br/><i>#{location.address}</i> <br/><i>#{location.city} #{location.state}., #{location.zip}</i> <p/>#{location.services.map{|service| service.name }.join(', ') } <p/><a href=\"#{location_path(location)}\">Location Details</a>" end end