Skip to content

Instantly share code, notes, and snippets.

@laurynas
Created August 11, 2010 18:59
Show Gist options
  • Save laurynas/519530 to your computer and use it in GitHub Desktop.
Save laurynas/519530 to your computer and use it in GitHub Desktop.
Generate "Add to TomTom" button
module TomTomHelper
# Generate Add To TomTom button
# You can pass following options hash:
# name - place name
# latitude - decimal latitude
# longitude - decimal longitude
# attribution - your attribution
# logo - link to your logo
#
# You can get API key here:
# https://www.tomtom.com/myTomTom/myProfile/apikey.php?generate=1
#
# More information:
# http://www.tomtom.com/lib/doc/TomTomTips/index.html
def add_to_tomtom_button(options)
options = {
:action => 'add',
:apikey => 'YOUR TOM TOM APIKEY',
:name => nil,
:latitude => nil,
:longitude => nil,
:attribution => t('generic.page_title'),
:logo => nil
}.merge(options)
url = "http://addto.tomtom.com/api/home/v2/georeference?"
options.each { |k,v| url << [ k, CGI::escape(v.to_s) ].join('=') + '&' }
img = image_tag('http://addto.tomtom.com/api/images/addtotomtom-button.gif', :alt => 'Add to TomTom')
link_to img, url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment