Created
December 3, 2012 15:51
-
-
Save kiero/4195886 to your computer and use it in GitHub Desktop.
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 characters
| def index | |
| if params[:search].present? | |
| search = Spot.new(:address => params[:search], :name => params[:search]) | |
| search.geocode | |
| @spots = Spot.near(search, 5, :order => :distance) | |
| spotsForMap = @spots + [search] | |
| title = params[:search] | |
| elsif params[:latitude].present? | |
| currentLocationSpot = Spot.new(:name => "Your position", :longitude => params[:longitude], :latitude => params[:latitude]) | |
| @spots = Spot.near(currentLocationSpot, 5, :order => :distance) | |
| spotsForMap = @spots + [currentLocationSpot] | |
| title = "Your position" | |
| #debugging | |
| @position = params[:latitude] if params[:latitude] | |
| @position2 = params[:longitude] if params[:longitude] | |
| else | |
| currentLocationSpot = Spot.new(:name => "Your position", :longitude => 17.0385376, :latitude => 51.1078852) | |
| @spots = Spot.near(currentLocationSpot, 5, :order => :distance) | |
| spotsForMap = @spots + [currentLocationSpot] | |
| title = "Your position" | |
| end | |
| @markers = spotsForMap.to_gmaps4rails do |spot, marker| | |
| if spot.name == title | |
| marker.picture({ | |
| :picture => "http://oncogene.pl/wp-content/themes/onco/_ui/images/marker-active.png", | |
| :width => 51, | |
| :height => 40 | |
| }) | |
| end | |
| end | |
| respond_to do |format| | |
| format.html # index.html.erb | |
| format.json { render :json => @spots } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment