- render :update do |page|
- page.replace_html :sidebar_content, :partial => 'results', :object => results
- page.call "openSidebar"
+ # decode the location
+ if m = query.match(/^\s*([+-]?\d+(\.\d*)?)\s*[\s,]\s*([+-]?\d+(\.\d*)?)\s*$/)
+ lat = m[1].to_f
+ lon = m[3].to_f
+ end
+
+ # generate results
+ if lat < -90 or lat > 90
+ @error = "Latitude #{lat} out of range"
+ render :action => "error"
+ elsif lon < -180 or lon > 180
+ @error = "Longitude #{lon} out of range"
+ render :action => "error"
+ else
+ @results.push({:lat => lat, :lon => lon,
+ :zoom => APP_CONFIG['postcode_zoom'],
+ :name => "#{lat}, #{lon}"})
+
+ render :action => "results"