Class: Ropenlayer::Openlayer::Layer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ropenlayer/openlayer/layer/base.rb

Direct Known Subclasses

ElementsMarker, ElementsVector

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 6

def config
  @config
end

#js_idObject (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

#mapObject (readonly)

Returns the value of attribute map.



9
10
11
# File 'lib/ropenlayer/openlayer/layer/base.rb', line 9

def map
  @map
end

#nameObject (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_jsObject



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