Class: Ropenlayer::Openlayer::Layer::Base
- Inherits:
-
Object
- Object
- Ropenlayer::Openlayer::Layer::Base
- Defined in:
- lib/ropenlayer/openlayer/layer/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#js_id ⇒ Object
readonly
Returns the value of attribute js_id.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, map) ⇒ Base
constructor
A new instance of Base.
- #to_js ⇒ Object
Constructor Details
#initialize(name, map) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 |
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 18 def initialize(name, map) @name = name @map = map @js_id = "#{ map.js_id }_#{ name }" @config = self.class.layers_config[name] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 6 def config @config end |
#js_id ⇒ Object (readonly)
Returns the value of attribute js_id.
8 9 10 |
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 8 def js_id @js_id end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
9 10 11 |
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 9 def map @map end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 7 def name @name end |
Class Method Details
.build_collection(map) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 11 def self.build_collection(map) map.layer_names.uniq.inject([]) do |layers, layer_name| layers << new(layer_name, map) layers end end |
Instance Method Details
#to_js ⇒ Object
25 26 27 28 29 |
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 25 def to_js %( // Adding #{ @name } layer #{ Ropenlayer::Openlayer::Js.new_var(@js_id, "#{ Ropenlayer::Openlayer::Js.new_method(@config[:method], @config) }").to_js } #{ Ropenlayer::Openlayer::Js.new("#{ map.js_id }.addLayer(#{ @js_id })").to_js } ) end |