Skip to content

Commit

Permalink
added img_path option to map_layers
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalomiri committed Feb 19, 2010
1 parent eb64b88 commit cca810b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/view_helpers.rb
Expand Up @@ -9,7 +9,7 @@ module ViewHelpers
# * options[:yahoo] with Yahoo appid: Include Yahoo! Maps
# * options[:proxy] with name of controller with proxy action. Defaults to current controller.
def map_layers_includes(options = {})
options.assert_valid_keys(:google, :multimap, :openstreetmap, :virtualearth, :yahoo, :proxy)
options.assert_valid_keys(:google, :multimap, :openstreetmap, :virtualearth, :yahoo, :proxy,:img_path)
html = ''
if options.has_key?(:google)
html << "<script type=\"text/javascript\" src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=#{options[:google]}\"></script>"
Expand All @@ -23,7 +23,10 @@ def map_layers_includes(options = {})
if options.has_key?(:yahoo)
html << "<script type=\"text/javascript\" src=\"http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=#{options[:yahoo]}\"></script>"
end

img_path = '/images/OpenLayers/'
if options.has_key?(:img_path)
img_path = options[:img_path]
end
if RAILS_ENV == "development" && File.exist?(File.join(RAILS_ROOT, 'public/javascripts/lib/OpenLayers.js'))
html << '<script src="/javascripts/lib/Firebug/firebug.js"></script>'
html << '<script src="/javascripts/lib/OpenLayers.js"></script>'
Expand All @@ -32,7 +35,7 @@ def map_layers_includes(options = {})
end

html << stylesheet_link_tag("map")
html << javascript_tag("OpenLayers.ImgPath='/images/OpenLayers/';")
html << javascript_tag("OpenLayers.ImgPath='"+ (ActionController::Base.relative_url_root||"") +"/"+img_path + "';")
proxy = options.has_key?(:proxy) ? options[:proxy] : controller.controller_name
html << javascript_tag("OpenLayers.ProxyHost='/#{proxy}/proxy?url=';")

Expand Down

0 comments on commit cca810b

Please sign in to comment.