Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Another attempt, how tricky can this be?

  • Loading branch information...
commit 340420a8dd7d6b52c93c9c531a9e9afc549aa2db 1 parent 7589ce4
@aubergene aubergene authored
View
4 app/controllers/search_controller.rb
@@ -24,14 +24,14 @@ def index
def kml
bounds = params["BBOX"].to_s.split(",")
@facilities = []
+ @status_manager = StatusManager.new
if 4 == bounds.size
sw = GeoKit::LatLng.new(bounds[1],bounds[0])
ne = GeoKit::LatLng.new(bounds[3],bounds[2])
bounds = GeoKit::Bounds.new(sw,ne)
- @status_manager = StatusManager.new
@facilities = Facility.find(:all, :bounds => bounds, :limit => 10)
else
- render "network.kml"
+ @facilities = Facility.find(:all, :limit => 10)
end
end
View
7 app/views/search/index.kml.haml
@@ -1,5 +1,5 @@
!!! XML
-%kml{ :xmlns => "http://www.opengis.net/kml/2.2" }
+%kml{ :xmlns => "http://earth.google.com/kml/2.0" }
%Folder
%name Test Placemarks
%description These are just some of the different kinds of placemarks with which you can mark your favorite places
@@ -26,13 +26,12 @@
- @facilities.each do |f|
%Placemark
%name= h f.full_name
- %styleUrl= "##{@status_manager.status(f).downcase}Placemark" #openingTimesStyleMap
+ %styleUrl= "##{@status_manager.status(f).downcase}Placemark"
%description
=h("<p><b>Opening times:</b><br />#{f.summary_normal_openings}</p>")
=h("<p><b>Contact</b><br />#{f.full_address.gsub(',','<br />')}</p>")
=h("<p><b>Phone:</b><br />#{f.phone}</p>") if f.phone
- =h("<p><b>Website</b><br /><a href='#{f.url}'>website</a></p>") if f.url
- %visibility 1
+ =h("<p><a href='#{f.url}'>website</a></p>") if f.url
%Point
%coordinates= "#{f.lng},#{f.lat}"
View
24 app/views/search/network.kml.erb
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<kml xmlns="http://www.opengis.net/kml/2.2">
- <Folder>
- <name>Network Links</name>
- <visibility>0</visibility>
- <open>0</open>
- <description>Network link example 2</description>
- <NetworkLink>
- <name>View Centered Placemark</name>
- <visibility>0</visibility>
- <open>0</open>
- <description>The view-based refresh allows the remote server to calculate
- the center of your screen and return a placemark.</description>
- <refreshVisibility>0</refreshVisibility>
- <flyToView>0</flyToView>
- <Link>
- <href>http://<%= request.host_with_port %>/search.kml</href>
- <refreshInterval>2</refreshInterval>
- <viewRefreshMode>onStop</viewRefreshMode>
- <viewRefreshTime>1</viewRefreshTime>
- </Link>
- </NetworkLink>
- </Folder>
-</kml>
View
12 app/views/search/network_link.kml.erb
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://earth.google.com/kml/2.0">
+ <NetworkLink>
+ <name>Opening Times (TESTING)</name>
+ <description>Shows whether businesses are currently open or closed</description>
+ <Url>
+ <href>http://<%= request.host_with_port %>/search.kml</href>
+ <viewRefreshMode>onStop</viewRefreshMode>
+ <viewRefreshTime>1</viewRefreshTime>
+ </Url>
+ </NetworkLink>
+</kml>
View
2  config/routes.rb
@@ -13,7 +13,7 @@
map.resources :groups, :collection => { :sitemap => :get }
map.connect 'groups/:id/:page', :controller => :groups, :action => :show, :defaults => { :page => 1 }, :requirements => { :page => /\d*/ } # To allow page caching
- map.resources :search
+ map.resources :search, :collection => { :network_link => :get }
# map. 'search/kml', :controller => 'search', :action => 'kml'
map.login "login", :controller => "user_sessions", :action => "new"
Please sign in to comment.
Something went wrong with that request. Please try again.