]> git.openstreetmap.org Git - rails.git/blob - app/helpers/geocoder_helper.rb
Use bounding box information to zoom to search results when possible.
[rails.git] / app / helpers / geocoder_helper.rb
1 module GeocoderHelper
2   def result_to_html(result)
3     html_options = {}
4     #html_options[:title] = strip_tags(result[:description]) if result[:description]
5     html_options[:href] = "?mlat=#{result[:lat]}&mlon=#{result[:lon]}&zoom=#{result[:zoom]}"
6     html = ""
7     html << result[:prefix] if result[:prefix]
8     html << " " if result[:prefix] and result[:name]
9
10     if result[:min_lon] and result[:min_lat] and result[:max_lon] and result[:max_lat]
11       html << link_to_function(result[:name],"setPosition(#{result[:lat]}, #{result[:lon]}, #{result[:zoom]}, #{result[:min_lon]}, #{result[:min_lat]}, #{result[:max_lon]}, #{result[:max_lat]})", html_options)  if result[:name]
12     else
13       html << link_to_function(result[:name],"setPosition(#{result[:lat]}, #{result[:lon]}, #{result[:zoom]})", html_options)  if result[:name]
14     end
15
16     html << result[:suffix] if result[:suffix]
17     return html
18   end
19 end