ropenlayer 0.0.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/History.txt +9 -0
  2. data/Manifest.txt +0 -20
  3. data/PostInstall.txt +1 -2
  4. data/README.rdoc +161 -23
  5. data/lib/generators/ropenlayer/install/INSTALL +16 -0
  6. data/lib/generators/ropenlayer/install/USAGE +7 -0
  7. data/lib/generators/ropenlayer/install/install_generator.rb +20 -0
  8. data/lib/generators/ropenlayer/install/templates/config/initializers/ropenlayer.rb +13 -0
  9. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/add_point_off.png +0 -0
  10. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/add_point_on.png +0 -0
  11. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/blank.gif +0 -0
  12. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/close.gif +0 -0
  13. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/default_marker.png +0 -0
  14. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/drag-rectangle-off.png +0 -0
  15. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/drag-rectangle-on.png +0 -0
  16. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_line_off.png +0 -0
  17. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_line_on.png +0 -0
  18. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_point_off.png +0 -0
  19. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_point_on.png +0 -0
  20. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_polygon_off.png +0 -0
  21. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_polygon_on.png +0 -0
  22. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/edit_map.png +0 -0
  23. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/edit_map_active.png +0 -0
  24. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/editing_tool_bar.png +0 -0
  25. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/layers_switch.png +0 -0
  26. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/layers_switch_active.png +0 -0
  27. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/move_feature_off.png +0 -0
  28. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/move_feature_on.png +0 -0
  29. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/navigation_history.png +0 -0
  30. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/none_button.png +0 -0
  31. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/overview_replacement.gif +0 -0
  32. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan-panel-NOALPHA.png +0 -0
  33. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan-panel.png +0 -0
  34. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan-panel_active.png +0 -0
  35. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan_off.png +0 -0
  36. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan_on.png +0 -0
  37. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/panning-hand-off.png +0 -0
  38. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/panning-hand-on.png +0 -0
  39. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/remove_point_off.png +0 -0
  40. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/remove_point_on.png +0 -0
  41. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/ruler.png +0 -0
  42. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/save_features_off.png +0 -0
  43. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/save_features_on.png +0 -0
  44. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_next_off.png +0 -0
  45. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_next_on.png +0 -0
  46. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_previous_off.png +0 -0
  47. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_previous_on.png +0 -0
  48. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/zoom-panel-NOALPHA.png +0 -0
  49. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/zoom-panel.png +0 -0
  50. data/lib/generators/ropenlayer/install/templates/public/images/ropenlayer/zoom-panel_active.png +0 -0
  51. data/lib/generators/ropenlayer/install/templates/public/stylesheets/ropenlayer.css +430 -0
  52. data/lib/generators/ropenlayer/migration/USAGE +10 -0
  53. data/lib/generators/ropenlayer/migration/migration_generator.rb +22 -0
  54. data/lib/generators/ropenlayer/migration/templates/migration.rb +31 -0
  55. data/lib/ropenlayer/acts_as/mapper.rb +147 -0
  56. data/lib/ropenlayer/acts_as/nodeable.rb +109 -0
  57. data/lib/ropenlayer/acts_as.rb +138 -0
  58. data/lib/ropenlayer/category.rb +14 -0
  59. data/lib/ropenlayer/form_builder.rb +69 -0
  60. data/lib/ropenlayer/icon.rb +12 -0
  61. data/lib/ropenlayer/js_helper/jquery.rb +63 -0
  62. data/lib/ropenlayer/js_helper/prototype.rb +51 -0
  63. data/lib/ropenlayer/localization.rb +6 -0
  64. data/lib/ropenlayer/node.rb +38 -0
  65. data/lib/ropenlayer/openlayer/box_control/base.rb +57 -0
  66. data/lib/ropenlayer/openlayer/box_control/edit_map.rb +85 -0
  67. data/lib/ropenlayer/openlayer/box_control/layers_select.rb +17 -0
  68. data/lib/ropenlayer/openlayer/control.rb +42 -0
  69. data/lib/ropenlayer/openlayer/feature.rb +119 -0
  70. data/lib/ropenlayer/openlayer/js.rb +63 -0
  71. data/lib/ropenlayer/openlayer/layer/base.rb +88 -0
  72. data/lib/ropenlayer/openlayer/layer/elements_marker.rb +20 -0
  73. data/lib/ropenlayer/openlayer/layer/elements_vector.rb +35 -0
  74. data/lib/ropenlayer/openlayer/map.rb +192 -0
  75. data/lib/ropenlayer.rb +59 -14
  76. data/ropenlayer.gemspec +11 -8
  77. metadata +94 -17
  78. data/lib/ropenlayer/box_control/base.rb +0 -47
  79. data/lib/ropenlayer/box_control/edit_map.rb +0 -79
  80. data/lib/ropenlayer/box_control/layers_select.rb +0 -16
  81. data/lib/ropenlayer/control.rb +0 -40
  82. data/lib/ropenlayer/js.rb +0 -62
  83. data/lib/ropenlayer/layer/base.rb +0 -87
  84. data/lib/ropenlayer/layer/elements_marker.rb +0 -18
  85. data/lib/ropenlayer/layer/elements_vector.rb +0 -33
  86. data/lib/ropenlayer/map.rb +0 -176
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ropenlayer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 3
8
9
  - 0
9
- - 1
10
- version: 0.0.1
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gnoxys
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-11 00:00:00 +01:00
18
+ date: 2011-03-07 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,9 +35,25 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: rspec
38
+ name: rails
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 1
46
+ segments:
47
+ - 3
48
+ - 0
49
+ - 3
50
+ version: 3.0.3
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
59
  - - ~>
@@ -49,11 +65,11 @@ dependencies:
49
65
  - 0
50
66
  version: 2.3.0
51
67
  type: :development
52
- version_requirements: *id002
68
+ version_requirements: *id003
53
69
  - !ruby/object:Gem::Dependency
54
70
  name: ruby-debug
55
71
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ~>
@@ -65,7 +81,7 @@ dependencies:
65
81
  - 3
66
82
  version: 0.10.3
67
83
  type: :development
68
- version_requirements: *id003
84
+ version_requirements: *id004
69
85
  description: Ropenlayer is a wrapper constructor for openlayer javascript library written in ruby. It aims to provide an easy way to build maps and display it on webs.
70
86
  email:
71
87
  - development@gnoxys.net
@@ -83,16 +99,77 @@ files:
83
99
  - PostInstall.txt
84
100
  - README.rdoc
85
101
  - Rakefile
102
+ - lib/generators/ropenlayer/install/INSTALL
103
+ - lib/generators/ropenlayer/install/USAGE
104
+ - lib/generators/ropenlayer/install/install_generator.rb
105
+ - lib/generators/ropenlayer/install/templates/config/initializers/ropenlayer.rb
106
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/add_point_off.png
107
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/add_point_on.png
108
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/blank.gif
109
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/close.gif
110
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/default_marker.png
111
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/drag-rectangle-off.png
112
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/drag-rectangle-on.png
113
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_line_off.png
114
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_line_on.png
115
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_point_off.png
116
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_point_on.png
117
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_polygon_off.png
118
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/draw_polygon_on.png
119
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/edit_map.png
120
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/edit_map_active.png
121
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/editing_tool_bar.png
122
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/layers_switch.png
123
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/layers_switch_active.png
124
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/move_feature_off.png
125
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/move_feature_on.png
126
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/navigation_history.png
127
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/none_button.png
128
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/overview_replacement.gif
129
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan-panel-NOALPHA.png
130
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan-panel.png
131
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan-panel_active.png
132
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan_off.png
133
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/pan_on.png
134
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/panning-hand-off.png
135
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/panning-hand-on.png
136
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/remove_point_off.png
137
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/remove_point_on.png
138
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/ruler.png
139
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/save_features_off.png
140
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/save_features_on.png
141
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_next_off.png
142
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_next_on.png
143
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_previous_off.png
144
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/view_previous_on.png
145
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/zoom-panel-NOALPHA.png
146
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/zoom-panel.png
147
+ - lib/generators/ropenlayer/install/templates/public/images/ropenlayer/zoom-panel_active.png
148
+ - lib/generators/ropenlayer/install/templates/public/stylesheets/ropenlayer.css
149
+ - lib/generators/ropenlayer/migration/USAGE
150
+ - lib/generators/ropenlayer/migration/migration_generator.rb
151
+ - lib/generators/ropenlayer/migration/templates/migration.rb
86
152
  - lib/ropenlayer.rb
87
- - lib/ropenlayer/box_control/base.rb
88
- - lib/ropenlayer/box_control/edit_map.rb
89
- - lib/ropenlayer/box_control/layers_select.rb
90
- - lib/ropenlayer/control.rb
91
- - lib/ropenlayer/js.rb
92
- - lib/ropenlayer/layer/base.rb
93
- - lib/ropenlayer/layer/elements_marker.rb
94
- - lib/ropenlayer/layer/elements_vector.rb
95
- - lib/ropenlayer/map.rb
153
+ - lib/ropenlayer/acts_as.rb
154
+ - lib/ropenlayer/acts_as/mapper.rb
155
+ - lib/ropenlayer/acts_as/nodeable.rb
156
+ - lib/ropenlayer/category.rb
157
+ - lib/ropenlayer/form_builder.rb
158
+ - lib/ropenlayer/icon.rb
159
+ - lib/ropenlayer/js_helper/jquery.rb
160
+ - lib/ropenlayer/js_helper/prototype.rb
161
+ - lib/ropenlayer/localization.rb
162
+ - lib/ropenlayer/node.rb
163
+ - lib/ropenlayer/openlayer/box_control/base.rb
164
+ - lib/ropenlayer/openlayer/box_control/edit_map.rb
165
+ - lib/ropenlayer/openlayer/box_control/layers_select.rb
166
+ - lib/ropenlayer/openlayer/control.rb
167
+ - lib/ropenlayer/openlayer/feature.rb
168
+ - lib/ropenlayer/openlayer/js.rb
169
+ - lib/ropenlayer/openlayer/layer/base.rb
170
+ - lib/ropenlayer/openlayer/layer/elements_marker.rb
171
+ - lib/ropenlayer/openlayer/layer/elements_vector.rb
172
+ - lib/ropenlayer/openlayer/map.rb
96
173
  - ropenlayer.gemspec
97
174
  - script/console
98
175
  - script/destroy
@@ -1,47 +0,0 @@
1
- module Ropenlayer
2
- module BoxControl
3
- class Base
4
-
5
- attr_reader :map
6
- attr_reader :name
7
- attr_reader :js_links_id
8
-
9
- attr_accessor :links
10
-
11
-
12
- def initialize(name, map, options = {})
13
- @name = name
14
- @map = map
15
- @links = []
16
-
17
- @js_id = "#{ map.js_id }_#{ name }"
18
- @js_control_id = "#{ @js_id }_control"
19
- @js_links_id = "#{ @js_id }_links"
20
- @js_panel_id = "#{ @js_id }_panel"
21
-
22
- @css_class = options[:css_class] || "olCustomControl#{ @name.camelize }"
23
- end
24
-
25
-
26
- def to_js
27
- %( // Adding #{ @name } box control
28
- #{ Ropenlayer::Js.new_var("#{ @js_links_id }", "#{ Ropenlayer::Js.new_method("Element", :args => [ "'div'" ], :propierties => { :class => "'#{ @css_class }Links'",
29
- :style => "'display: none;'",
30
- :id => "'#{ @js_links_id }'" })}").to_js }
31
- #{ Ropenlayer::Js.new_var("#{ @js_control_id }", "#{ Ropenlayer::Js.new_method("OpenLayers.Control.Button", :propierties => { :displayClass => "'#{ @css_class }'",
32
- :trigger => "function() { $('#{ @js_links_id }').toggle(); }" }) }").to_js }
33
- #{ Ropenlayer::Js.new_var("#{ @js_panel_id }", "#{ Ropenlayer::Js.new_method("OpenLayers.Control.Panel", :propierties => { :displayClass => "'#{ @css_class }Panel'",
34
- :defaultControl => "#{ @js_control_id }" }) }").to_js }
35
- #{ Ropenlayer::Js.new("#{ @js_panel_id }.addControls([#{ @js_control_id }])").to_js }
36
- #{ links.inject('') do |links_string, link_config|
37
- link_text = link_config.delete(:text)
38
- links_string << "#{ Ropenlayer::Js.new("#{ @js_links_id }.insert(#{ Ropenlayer::Js.new_method("Element", :args => ["'a'"], :propierties => link_config ) }.update('#{ link_text }'))").to_js }\n"
39
- links_string
40
- end }
41
- #{ Ropenlayer::Js.new("#{ @map.js_id }.addControls([#{ @js_panel_id }])").to_js }
42
- #{ Ropenlayer::Js.new("#{ @js_control_id }.div.insert(#{ @js_links_id })").to_js }
43
- )
44
- end
45
- end
46
- end
47
- end
@@ -1,79 +0,0 @@
1
- module Ropenlayer
2
- module BoxControl
3
- class EditMap < Base
4
- def initialize(map)
5
- super('edit_map', map, :css_class => 'olControlEditMapControl')
6
- Ropenlayer::BoxControl::EditMap.controls.each do |control_name, control_options|
7
-
8
- @links << { :id => "'link_to_edit_map_control_#{ control_name }'",
9
- :class => "'olControlEditMapControlLink with_icon action_#{ control_name }'",
10
- :text => "#{ control_options[:description] }",
11
- :title => "'#{ control_options[:description] }'",
12
- :onclick => %( "#{ map.js_notification_area }.update('#{ control_options[:help]}'); new Effect.BlindDown(#{ map.js_notification_area });#{ @js_links_id }.hide(); #{ map.js_id }ActivateEditControl('#{ control_name }');return false;" ) }
13
- end
14
- @links << { :id => "'link_to_edit_map_control_cancel'",
15
- :class => "'olControlEditMapControlLink with_icon action_cancel'",
16
- :text => "Cancelar",
17
- :onclick => %( "#{ @js_links_id }.hide(); return false;") }
18
- end
19
-
20
- def to_js
21
- %(
22
- var #{ map.js_id }EditMapControls = {};
23
- function #{ map.js_id }ActivateEditControl(selectedControl) {
24
- for(key in #{ map.js_id }EditMapControls) {
25
- var control = #{ map.js_id }EditMapControls[key];
26
- if(selectedControl == key) {
27
- control.activate();
28
- } else {
29
- control.deactivate();
30
- }
31
- }
32
- }
33
- #{ new_elements_layer = Ropenlayer::Layer::Base.new(:new_elements, @map)
34
- new_elements_layer.to_js }
35
-
36
- #{ Ropenlayer::BoxControl::EditMap.controls.inject('') do |edit_controls_js, control_array|
37
- control_name = control_array.first
38
- control_options = control_array.last
39
- control_options[:args] = [ new_elements_layer.js_id, control_options[:args]].flatten
40
- control_options[:propierties][:featureAdded] = map.options[:new_feature_callback] || 'false' # FIXME
41
-
42
- edit_controls_js << %( #{ Ropenlayer::Js.new_var("#{ map.js_id }_#{ control_name }",
43
- "#{ Ropenlayer::Js.new_method(control_options[:method], control_options) }").to_js }
44
- #{ Ropenlayer::Js.new("#{ map.js_id }.addControl(#{ map.js_id }_#{ control_name })").to_js }
45
- #{ Ropenlayer::Js.new("#{ map.js_id }EditMapControls['#{ control_name }'] = #{ map.js_id }_#{ control_name }").to_js }
46
- )
47
- edit_controls_js
48
- end }
49
-
50
- #{ super }
51
- )
52
- end
53
-
54
- private
55
- def self.controls
56
- { :add_point => {:method => "OpenLayers.Control.DrawFeature",
57
- :args => [ "OpenLayers.Handler.Point" ],
58
- :propierties => { },
59
- :description => 'Crear un punto',
60
- :help => 'Para crear un punto en el mapa, haga click en la posición deseada'
61
- },
62
- :add_line => { :method => "OpenLayers.Control.DrawFeature",
63
- :args => [ "OpenLayers.Handler.Path" ],
64
- :propierties => { },
65
- :description => 'Crear una línea',
66
- :help => 'Para crear un punto en el mapa, haga click en la posición deseada'
67
-
68
- },
69
- :add_polygon => { :method => "OpenLayers.Control.DrawFeature",
70
- :args => [ "OpenLayers.Handler.Polygon" ],
71
- :propierties => { },
72
- :description => 'Crear un polígono',
73
- :help => 'Para crear un punto en el mapa, haga click en la posición deseada'
74
- }
75
- }
76
- end
77
- end
78
- end
79
- end
@@ -1,16 +0,0 @@
1
- module Ropenlayer
2
- module BoxControl
3
- class LayersSelect < Base
4
- def initialize(map)
5
- super('layers_select', map, :css_class => 'olControlLayersBoxControl')
6
- map.layers.each do |layer|
7
- @links << { :id => "'link_to_base_layer_#{ layer.name }'",
8
- :class => "'olControlLayersBoxControl'",
9
- :text => " » Usar Mapa #{ layer.config[:description] }",
10
- :onclick => "'#{ map.js_id }.setBaseLayer(#{ layer.js_id }); #{ @js_links_id }.hide(); return false;'" }
11
- end
12
- end
13
- end
14
- end
15
- end
16
-
@@ -1,40 +0,0 @@
1
- module Ropenlayer
2
- class Control
3
-
4
- attr_reader :config
5
- attr_reader :name
6
- attr_reader :js_id
7
- attr_reader :map
8
-
9
- def self.build_collection(map)
10
- map.control_names.inject([]) do |controls, control_name|
11
- controls << new(control_name, map)
12
- controls
13
- end
14
- end
15
-
16
- def initialize(name, map)
17
- @name = name
18
- @map = map
19
- @js_id = "#{ map.js_id }_#{ name }"
20
- @config = Ropenlayer::Control.configs[name]
21
- end
22
-
23
- def to_js
24
- %(// Adding #{ @name } control
25
- #{ Ropenlayer::Js.new_var(@js_id, "#{ Ropenlayer::Js.new_method(@config[:method], @config) }").to_js }
26
- #{ Ropenlayer::Js.new("#{ map.js_id }.addControl(#{ @js_id })").to_js }
27
- )
28
- end
29
-
30
- private
31
- def self.configs
32
- { :layers_switcher => { :method => "OpenLayers.Control.LayerSwitcher", :args => "" },
33
- :mouse_position => { :method => "OpenLayers.Control.MousePosition", :args => "" },
34
- :pan_panel => { :method => "OpenLayers.Control.PanPanel", :args => "" },
35
- :navigation => { :method => "OpenLayers.Control.Navigation", :args => "" },
36
- :zoom_panel => { :method => "OpenLayers.Control.ZoomPanel", :args => "" },
37
- :scale_line => { :method => "OpenLayers.Control.ScaleLine", :args => "" }}
38
- end
39
- end
40
- end
data/lib/ropenlayer/js.rb DELETED
@@ -1,62 +0,0 @@
1
- module Ropenlayer
2
-
3
- class Js
4
-
5
- attr_accessor :body
6
-
7
- # == Ropenlayer::Js
8
- #
9
- # Just a simple JS constructor for objects methods calls and variable setting
10
- def initialize(initialize_string = '')
11
- @body = initialize_string
12
- end
13
-
14
- # create a new js method
15
- #
16
- # Ropenlayer::Js.new_method("Element.create", "div", { :class => 'eyecandy', :id => 'my_id'}).to_s
17
- # #=> new Element.create("div", { "class":"eyecandy","id":"my_id"});
18
- #
19
- def self.new_method(method, options = {})
20
- js_object = new
21
- args = options[:args] || []
22
- propierties = options[:propierties] || {}
23
-
24
- js_object.body = "new #{ method }("
25
- js_object.body << "#{ args.join(', ') }" if args.any?
26
-
27
- if propierties.keys.any?
28
-
29
- js_object.body << ", " if args.any?
30
-
31
- js_object.body << propierties.keys.inject("{") do |propierties_string, propierty|
32
- propierties_string << "'#{ propierty }': #{ propierties[propierty] }"
33
- propierties_string << ", " unless propierties.keys.last == propierty
34
- propierties_string
35
- end
36
- js_object.body << "}"
37
-
38
- end
39
- js_object.body << ")"
40
- js_object
41
- end
42
-
43
- # create a new js global variable:
44
- #
45
- # Ropenlayer::Js.new_var("test", "1").to_s
46
- # #=> var test = "1"
47
- #
48
- def self.new_var(name, value)
49
- new("var #{ name } = #{ value }")
50
- end
51
-
52
-
53
- def to_s
54
- @body
55
- end
56
-
57
- def to_js
58
- "#{ @body };"
59
- end
60
-
61
- end
62
- end
@@ -1,87 +0,0 @@
1
- module Ropenlayer
2
- module Layer
3
- class Base
4
-
5
- attr_reader :config
6
- attr_reader :name
7
- attr_reader :js_id
8
- attr_reader :map
9
-
10
- def self.build_collection(map)
11
- map.layer_names.inject([]) do |layers, layer_name|
12
- layers << new(layer_name, map)
13
- layers
14
- end
15
- end
16
-
17
- def initialize(name, map)
18
- @name = name
19
- @map = map
20
- @js_id = "#{ map.js_id }_#{ name }"
21
- @config = self.class.layers_config[name]
22
- end
23
-
24
- def to_js
25
- %( // Adding #{ @name } layer
26
- #{ Ropenlayer::Js.new_var(@js_id, "#{ Ropenlayer::Js.new_method(@config[:method], @config) }").to_js }
27
- #{ Ropenlayer::Js.new("#{ map.js_id }.addLayer(#{ @js_id })").to_js } )
28
- end
29
-
30
- private
31
- # return a hash with config options for Ropenlayer layers.
32
- # U can override this method as ur wish to get config from other places, for example, AR.
33
- def self.layers_config
34
- { :osm => { :method => "OpenLayers.Layer.OSM",
35
- :args => [ "'Usar Mapa OSM'" ],
36
- :propierties => { },
37
- :description => 'Mapa Libre OSM' },
38
-
39
- :wms => { :method => "OpenLayers.Layer.WMS",
40
- :args => [ "'OpenLayers WMS'", "'http://vmap0.tiles.osgeo.org/wms/vmap0'" ],
41
- :propierties => { :layers => "'basic'" },
42
- :description => 'Mapa Libre WMS'},
43
-
44
- :wms => { :method => "OpenLayers.Layer.WMS",
45
- :args => [ "'OpenLayers WMS'", "'http://vmap0.tiles.osgeo.org/wms/vmap0'" ],
46
- :propierties => { :layers => "'basic'" },
47
- :description => 'Mapa Libre WMS' },
48
-
49
- :google_streets => { :method => "OpenLayers.Layer.Google",
50
- :args => [ "'Google Streets'" ],
51
- :propierties => { :numZoomLevels => "20" },
52
- :description => 'Mapa StreetsGoogle' },
53
-
54
- :google_satellite => { :method => "OpenLayers.Layer.Google",
55
- :args => [ "'Google Satellite'" ],
56
- :propierties => { :type => "google.maps.MapTypeId.SATELLITE", :numZoomLevels => "22" },
57
- :description => 'Mapa Satélite de Google' },
58
-
59
- :google_physical => { :method => "OpenLayers.Layer.Google",
60
- :args => [ "'Google Physical'" ],
61
- :propierties => { :type => "google.maps.MapTypeId.TERRAIN" },
62
- :description => 'Mapa Físico de Google' },
63
-
64
- :google_hybrid => { :method => "OpenLayers.Layer.Google",
65
- :args => [ "'Google Hybrid'" ],
66
- :propierties => { :type => "google.maps.MapTypeId.HYBRID", :numZoomLevels => "22" },
67
- :description => 'Mapa Híbrido de Google' },
68
-
69
- :yahoo => { :method => "OpenLayers.Layer.Yahoo",
70
- :args => [ ],
71
- :propierties => { },
72
- :description => 'Mapa Yahoo' },
73
- :new_elements => { :method => "OpenLayers.Layer.Vector",
74
- :args => [ "'Vector Layer for create elements'" ],
75
- :propierties => { },
76
- :description => 'New Vectors Layer' },
77
-
78
- :vector_elements => { :method => "OpenLayers.Layer.Vector",
79
- :args => [ "'Capa de Marcadores''" ],
80
- :propierties => { },
81
- :description => 'Capa para marcadores de elements' }
82
- }
83
- end
84
- end
85
- end
86
- end
87
-
@@ -1,18 +0,0 @@
1
- module Ropenlayer
2
- module Layer
3
- class ElementsMarker < Base
4
-
5
- def initialize(map)
6
- super(:marker_elements, map)
7
- end
8
-
9
- private
10
- def self.layers_config
11
- { :marker_elements => { :method => "OpenLayers.Layer.Markers",
12
- :args => [ "'Capa de Marcadores'" ],
13
- :propierties => { },
14
- :description => 'Capa para marcadores de elements' } }
15
- end
16
- end
17
- end
18
- end
@@ -1,33 +0,0 @@
1
- module Ropenlayer
2
- module Layer
3
- class ElementsVector < Base
4
-
5
- def initialize(map)
6
- super(:vector_elements, map)
7
- end
8
-
9
- private
10
- def self.layers_config
11
- { :vector_elements => { :method => "OpenLayers.Layer.Vector",
12
- :args => [ "'Capa de Elementos'" ],
13
- :propierties => { :styleMap => "#{ Ropenlayer::Js.new_method("OpenLayers.StyleMap", :propierties => { :default => default_vector_style_parameters.to_json }) }" },
14
- :description => 'Capa para marcadores de elements' } }
15
- end
16
-
17
- def self.default_vector_style_parameters
18
- { :cursor => 'normal',
19
- :graphicWidth => 48,
20
- :graphicHeight => 48,
21
- :strokeColor => '${fillColor}',
22
- :strokeOpacity => 0.8,
23
- :strokeWidth => 5,
24
- :fillColor => '${fillColor}',
25
- :fillOpacity => 0.8,
26
- :pointRadius => 30,
27
- :pointerEvents => 'visiblePainted',
28
- :fontSize => '12px',
29
- :fontWeight => 'bold' }
30
- end
31
- end
32
- end
33
- end