Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Additional GOverviewMapControl functionality
Expand options for adding an overview map with GOverviewMapControl.
In addition to passing a boolean value for the :overview_map option
of GMap#control_init, a hash with :hide and :size options can also
be used.

To have the overview map initialized in the closed state, set the
:hide option to true.

To override the default size of the overview map, set the :size
option to a GSize object.
  • Loading branch information
davec authored and ewildgoose committed Jun 18, 2009
1 parent 6c04a9b commit 24b65cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/gm_plugin/control.rb
Expand Up @@ -45,8 +45,11 @@ def create
#Overview map control. Report to the Google Maps API documentation for details.
class GOverviewMapControl
include MappingObject
def initialize(size = nil)
@size = size
end
def create
"new GOverviewMapControl()"
"new GOverviewMapControl(#{@size ? @size.create : ''})"
end
end

Expand Down
13 changes: 11 additions & 2 deletions lib/gm_plugin/map.rb
Expand Up @@ -75,15 +75,24 @@ def record_init(code)
@init << code
end

#Initializes the controls: you can pass a hash with keys <tt>:small_map</tt>, <tt>:large_map</tt>, <tt>:small_zoom</tt>, <tt>:scale</tt>, <tt>:map_type</tt>, <tt>:overview_map</tt> and a boolean value as the value (usually true, since the control is not displayed by default), <tt>:local_search</tt>, <tt>:local_search_options</tt>, and <tt>:show_on_focus</tt>
#Initializes the controls: you can pass a hash with keys <tt>:small_map</tt>, <tt>:large_map</tt>, <tt>:small_zoom</tt>, <tt>:scale</tt>, <tt>:map_type</tt>, <tt>:overview_map</tt> and hash of options controlling its display (<tt>:hide</tt> and <tt>:size</tt>), <tt>:local_search</tt>, <tt>:local_search_options</tt>, and <tt>:show_on_focus</tt>
def control_init(controls = {})
@init_end << add_control(GSmallMapControl.new) if controls[:small_map]
@init_end << add_control(GLargeMapControl.new) if controls[:large_map]
@init_end << add_control(GSmallZoomControl.new) if controls[:small_zoom]
@init_end << add_control(GScaleControl.new) if controls[:scale]
@init_end << add_control(GMapTypeControl.new) if controls[:map_type]
@init_end << add_control(GHierarchicalMapTypeControl.new) if controls[:hierarchical_map_type]
@init_end << add_control(GOverviewMapControl.new) if controls[:overview_map]
if controls[:overview_map]
if controls[:overview_map].is_a?(Hash)
hide = controls[:overview_map][:hide]
size = controls[:overview_map][:size]
end
overview_control = GOverviewMapControl.new(size)
@init_end << overview_control.declare("#{@variable}_ovm") if hide
@init_end << add_control(overview_control)
@init_end << "#{overview_control.variable}.hide(true);" if hide
end
@init_end << add_control(GLocalSearchControl.new(controls[:anchor], controls[:offset_width], controls[:offset_height], controls[:local_search_options])) if controls[:local_search]
if controls[:show_on_focus] # Should be last
@init_end << "#{@variable}.hideControls();"
Expand Down

0 comments on commit 24b65cc

Please sign in to comment.