Class: Ym4r::GmPlugin::GIcon

Inherits:
Object
  • Object
show all
Includes:
MappingObject
Defined in:
lib/gm_plugin/overlay.rb

Overview

Represents a definition of an icon. You can pass rubyfied versions of the attributes detailed in the Google Maps API documentation. You can initialize global icons to be used in the application by passing a icon object, along with a variable name, to GMap#icon_init. If you want to declare an icon outside this, you will need to declare it first, since the JavaScript constructor does not accept any argument.

Constant Summary

DEFAULT =
Variable.new("G_DEFAULT_ICON")

Instance Attribute Summary (collapse)

Attributes included from MappingObject

#variable

Instance Method Summary (collapse)

Methods included from MappingObject

#[], #assign_to, #declare, #declare_random, #declared?, escape_javascript, #get_property, javascriptify_method, javascriptify_variable, #method_missing, #set_property, #to_javascript

Constructor Details

- (GIcon) initialize(options = {})

Options can contain all the attributes (in rubyfied format) of a GIcon object (see Google's doc), as well as :copy_base, which indicates if the icon is copied from another one.



63
64
65
66
# File 'lib/gm_plugin/overlay.rb', line 63

def initialize(options = {})
  @copy_base = options.delete(:copy_base)
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ym4r::GmPlugin::MappingObject

Instance Attribute Details

- (Object) copy_base

Returns the value of attribute copy_base



60
61
62
# File 'lib/gm_plugin/overlay.rb', line 60

def copy_base
  @copy_base
end

- (Object) options

Returns the value of attribute options



60
61
62
# File 'lib/gm_plugin/overlay.rb', line 60

def options
  @options
end

Instance Method Details

- (Object) create

Creates a GIcon.



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/gm_plugin/overlay.rb', line 68

def create
  if @copy_base
    c = "new GIcon(#{MappingObject.javascriptify_variable(@copy_base)})"
  else
    c = "new GIcon()"
  end
  if !options.empty?
    "addOptionsToIcon(#{c},#{MappingObject.javascriptify_variable(@options)})"
  else
    c
  end
end