diff --git a/app/views/places/_map_attribution.html.haml b/app/views/places/_map_attribution.html.haml new file mode 100644 index 000000000..894c88f32 --- /dev/null +++ b/app/views/places/_map_attribution.html.haml @@ -0,0 +1,6 @@ +Map data © += link_to "OpenStreetMap", "http://openstreetmap.org" +contributors under += link_to "ODbL", "http://www.openstreetmap.org/copyright" +| Imagery © += link_to "CloudMade", "http://cloudmade.com" diff --git a/app/views/places/index.html.haml b/app/views/places/index.html.haml index 75a2b51b2..b5829905a 100644 --- a/app/views/places/index.html.haml +++ b/app/views/places/index.html.haml @@ -4,10 +4,11 @@ +- attribution = render(:partial => 'map_attribution').gsub(/\n/, " ") :javascript map = L.map('map').setView([0.0, -0.0], 2); L.tileLayer("http://{s}.tile.cloudmade.com/#{ ENV['CLOUDMADE_KEY'] }/997/256/{z}/{x}/{y}.png", { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade', + attribution: '#{ attribution }', maxZoom: 18 }).addTo(map); diff --git a/app/views/places/show.html.haml b/app/views/places/show.html.haml index 5a2e89d14..05428e85b 100644 --- a/app/views/places/show.html.haml +++ b/app/views/places/show.html.haml @@ -4,10 +4,11 @@ %div#map{ :style => "height:300px"} +- attribution = render(:partial => 'map_attribution').gsub(/\n/, " ") :javascript map = L.map('map').setView([#{ @latitude }, #{ @longitude }]).fitBounds([ [#{@sw_lat}, #{@sw_lng}], [#{@ne_lat}, #{@ne_lng}] ]); L.tileLayer("http://{s}.tile.cloudmade.com/#{ ENV['CLOUDMADE_KEY'] }/997/256/{z}/{x}/{y}.png", { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade', + attribution: '#{ attribution }', maxZoom: 18 }).addTo(map); diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb new file mode 100644 index 000000000..e3197dfba --- /dev/null +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe "places/_map_attribution.html.haml", :type => :view do + before(:each) do + render + end + + it "links to OpenStreetMap" do + assert_select "a", :href => "http://openstreetmap.org", + :text => "OpenStreetMap" + end + + it "links to the ODbL" do + assert_select "a", :href => "http://www.openstreetmap.org/copyright", + :text => "ODbL" + end + + it "links to CloudMade" do + assert_select "a", :href => "http://cloudmade.com", :text => "CloudMade" + end +end