Class: Ym4r::GmPlugin::GPolylineEncoded

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

Overview

Encoded GPolyline class

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

#initialize(options = {}) ⇒ GPolylineEncoded



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/gm_plugin/overlay.rb', line 112

def initialize(options={})
  #points = options[:points]
  #if !points.empty? and points[0].is_a?(Array)
  #  @points = points.collect { |pt| GLatLng.new(pt) }
  #else
  #@points = points
    #end
  @points = options[:points]
  @color = options[:color]
  @weight = options[:weight]
  @opacity = options[:opacity]
  @levels = options[:levels] || "BBBBBBBBBBBB"
  @zoom_factor = options[:zoom_factor] || 32
  @num_levels = options[:num_levels] || 4
end

Dynamic Method Handling

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

Instance Attribute Details

#colorObject

Returns the value of attribute color



110
111
112
# File 'lib/gm_plugin/overlay.rb', line 110

def color
  @color
end

#levelsObject

Returns the value of attribute levels



110
111
112
# File 'lib/gm_plugin/overlay.rb', line 110

def levels
  @levels
end

#num_levelsObject

Returns the value of attribute num_levels



110
111
112
# File 'lib/gm_plugin/overlay.rb', line 110

def num_levels
  @num_levels
end

#opacityObject

Returns the value of attribute opacity



110
111
112
# File 'lib/gm_plugin/overlay.rb', line 110

def opacity
  @opacity
end

#pointsObject

Returns the value of attribute points



110
111
112
# File 'lib/gm_plugin/overlay.rb', line 110

def points
  @points
end

#weightObject

Returns the value of attribute weight



110
111
112
# File 'lib/gm_plugin/overlay.rb', line 110

def weight
  @weight
end

#zoom_factorObject

Returns the value of attribute zoom_factor



110
111
112
# File 'lib/gm_plugin/overlay.rb', line 110

def zoom_factor
  @zoom_factor
end

Instance Method Details

#createObject



127
128
129
130
131
132
133
134
135
136
# File 'lib/gm_plugin/overlay.rb', line 127

def create
  a = "new GPolyline.fromEncoded({points: #{MappingObject.javascriptify_variable(points)},\n" 
  a << "levels: #{MappingObject.javascriptify_variable(@levels)},"
  a << "zoomFactor: #{MappingObject.javascriptify_variable(@zoom_factor)},"
  a << "numLevels: #{MappingObject.javascriptify_variable(@num_levels)}"
  a << ",color: #{MappingObject.javascriptify_variable(@color)}" if @color
  a << ",weight: #{MappingObject.javascriptify_variable(@weight)}" if @weight
  a << ",opacity: #{MappingObject.javascriptify_variable(@opacity)}" if @opacity
  a << "})"
end