Skip to content

Commit

Permalink
updated to include the 'sensor' parameter in the GET API string for G…
Browse files Browse the repository at this point in the history
…oogle Maps. [patch by Xabriel J Collazo Mojica <[email protected]>]

git-svn-id: http://ym4r.rubyforge.org/svn/Plugins/GM/trunk/ym4r_gm@108 c9bc9743-7714-0410-b404-d8b1d4e1ace9
  • Loading branch information
erbmicha committed Apr 13, 2009
1 parent 4036a30 commit 5f6e606
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,13 @@ You can pass options to the control_init as well. They are:
So if you wanted the local search control to be at the bottom right of the map, 30 pixel in from the right and 20 pixels above the bottom and some local search options it would look like this:
@map.control_init(:large_map => true, :map_type => true, :local_search => true, :anchor => :bottom_right, :offset_width => 30, :offset_height => 20, :local_search_options => "{suppressZoomToBounds : true, resultList : google.maps.LocalSearch.RESULT_LIST_INLINE, suppressInitialResultSelection : true, searchFormHint : 'Local Search powered by Google', linkTarget : GSearch.LINK_TARGET_BLANK}")

==Sensor
Google now requires the 'sensor' attribute in the GET API request. It is defaulted to 'false', but if you are writing an application for one of the new cellphones with GPS out there then you can enable it by using the following call:

<%= GMap.header :sensor => true %>

==Recent changes
- 'sensor' added to GET URL per Google API Terms of Use. 'false' by default.
- Local Search overlay added. See above for implementation.
- GMarker can now be placed by address (in addition to coordinates). Some code to geocode the address when the marker is initialized is added
- Addition of a +center_zoom_on_points_init+ to center and zoom on a group of pixel
Expand Down
3 changes: 2 additions & 1 deletion lib/gm_plugin/geocoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ module Geocoding
#Gets placemarks by querying the Google Maps Geocoding service with the +request+ string. Options can either an explicity GMaps API key (<tt>:key</tt>) or a host, (<tt>:host</tt>).
def self.get(request,options = {})
api_key = ApiKey.get(options)
sensor = options[:sensor] || false
output = options[:output] || "kml"
url = "http://maps.google.com/maps/geo?q=#{URI.encode(request)}&key=#{api_key}&output=#{output}"
url = "http://maps.google.com/maps/geo?q=#{URI.encode(request)}&key=#{api_key}&sensor=#{sensor}&output=#{output}"

res = open(url).read

Expand Down
3 changes: 2 additions & 1 deletion lib/gm_plugin/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def self.header(options = {})
options[:with_vml] = true unless options.has_key?(:with_vml)
options[:hl] ||= ''
options[:local_search] = false unless options.has_key?(:local_search)
options[:sensor] = false unless options.has_key?(:sensor)
api_key = ApiKey.get(options)
a = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=#{api_key}&amp;hl=#{options[:hl]}\" type=\"text/javascript\"></script>\n"
a = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=#{api_key}&amp;hl=#{options[:hl]}&amp;sensor=#{options[:sensor]}\" type=\"text/javascript\"></script>\n"
a << "<script src=\"#{ActionController::Base.relative_url_root}/javascripts/ym4r-gm.js\" type=\"text/javascript\"></script>\n" unless options[:without_js]
a << "<style type=\"text/css\">\n v\:* { behavior:url(#default#VML);}\n</style>" if options[:with_vml]
a << "<script src=\"http://www.google.com/uds/api?file=uds.js&amp;v=1.0\" type=\"text/javascript\"></script>" if options[:local_search]
Expand Down

0 comments on commit 5f6e606

Please sign in to comment.