ropenlayer 0.0.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,176 +0,0 @@
1
- module Ropenlayer
2
- class Map
3
-
4
- attr_reader :js_id
5
- attr_reader :div_id
6
- attr_reader :js_propierties
7
- attr_reader :options
8
-
9
- attr_reader :layer_names
10
- attr_reader :layers
11
-
12
- attr_accessor :layers_select
13
-
14
- attr_accessor :control_names
15
- attr_accessor :controls
16
-
17
- attr_accessor :markers_layer
18
- attr_accessor :vectors_layer
19
- attr_accessor :js_notification_area
20
-
21
- # used to scope js variables created with the map. Js name will be created with this prefix + plus dom_id argument
22
- MAP_JS_PREFIX = 'olObject'
23
-
24
- def self.print(map_object, options = {})
25
- new(map_object, options).to_js
26
- end
27
-
28
- # == Initialize
29
- #
30
- # Create a map object with parsed attributes. Ropenlayer manage two ids for each map.
31
- # - js_div, use to scope all the variables names to draw js output.
32
- # - div_id, the dom_id passed as argument to construtor. For example
33
- #
34
- # For example
35
- #
36
- # m = Ropenlayer::Map.new('group_map')
37
- # => <Ropenlayer::Map:0xf7344fe8>
38
- # m.js_id
39
- # => "olObject_group_map"
40
- # n.div_id
41
- # => "group_map"
42
- #
43
- # To draw map, just call to_js method. For example, in a rails 3.x application
44
- #
45
- # <%= raw javascript_tag(Ropenlayer::Map.new('group_map').to_js) %>
46
- #
47
- # Ropenlayer::Map use this options
48
- #
49
- # - layers: Select which layers are used in map. For a list of available layers see <tt>Ropenlayer::Laye::Baser</tt>
50
- # - default_layer: Default layer at render. Default layers.first
51
- # - layer_select: If true, map will render a control for change between differents layers
52
- # - controls: Select which controls are used in map. For a list of available controlse see <tt>Ropenlayer::Control</tt>
53
- # - latitude: Specify default latitude for map. Map will be pointed at this latitude at render.
54
- # - longitude: Specify default longitude for map. Map will be pointed at this longitude at render.
55
- # - zoom: Specify default zoom for map. Map will be render with this zoom enable.
56
- # - edit_map: If true, map will display a custom control what enable edit capabilities with map
57
- #
58
- # Map object accepts other options scoped in :map_js_options key.
59
- #
60
- # - theme: CSS theme used to display. By default none is used
61
- # - projection: Specify projection. Argument must be a valid OpenLayers.Projection JS object. See more on
62
- # - units: Units for measure. By default: "'m'"
63
- # - maxResolution: maxResolution of the map, by default word length: "156543.0339"
64
- # - meaxExtentd: Bound for projection. Must be valid OpenLayers.Bounds object. By default world length bound. See for more info.
65
- #
66
- # After display objects, you can, ofc, call methods from openlayers api to instace js variable. For example
67
- #
68
- # <% map = Ropenlayer::Map.new('group_map') %>
69
- # <%= raw javascript_tag map.to_js %>
70
- # <%= raw javascript_tag "#{ map.js_id }.setCenter(new OpenLayers.LonLat(0,0), 10);" %>
71
- #
72
- # Will call the setCenter OpenLayer.Map JS method to map.js_id js instace object
73
- #
74
- def initialize(dom_id, options = {})
75
- @js_id = "#{ MAP_JS_PREFIX }_#{ dom_id }"
76
- @div_id = "#{ dom_id }"
77
- @options = options
78
-
79
- @js_propierties = map_js_propierties(options[:map_js_options])
80
-
81
- @layer_names = @options[:layers] || self.class.default_layers
82
- @layers = Ropenlayer::Layer::Base.build_collection(self)
83
-
84
- @control_names = @options[:controls] || self.class.default_controls
85
- @controls = Ropenlayer::Control.build_collection(self)
86
-
87
- @latitude = @options[:latitude] || self.class.default_latitude
88
- @longitude = @options[:longitude] || self.class.default_longitude
89
- @zoom = @options[:zoom] || self.class.default_zoom
90
-
91
- @layers_select = @options[:layer_select].nil? or @options[:layer_select]
92
- @edit_map = @options[:edit_map]
93
-
94
- @markers_layer = Ropenlayer::Layer::ElementsMarker.new(self)
95
- @vectors_layer = Ropenlayer::Layer::ElementsVector.new(self)
96
-
97
- @js_notification_area = "#{ @js_id }_notification_area"
98
- end
99
-
100
- def map_js_propierties(map_js_options = {})
101
- map_js_options ||= {}
102
- propierties = {}
103
-
104
- propierties[:div] = "'#{ div_id }'"
105
- propierties[:controls] = "[]"
106
-
107
- propierties[:theme] = map_js_options[:theme] if map_js_options[:theme]
108
- propierties[:projection] = map_js_options[:projection] || "#{ Ropenlayer::Js.new_method("OpenLayers.Projection", :args => ["'EPSG:900913'"]) }"
109
- propierties[:units] = map_js_options[:units] || "'m'"
110
- propierties[:maxResolution] = map_js_options[:units] || "156543.0339"
111
- propierties[:maxExtent] = map_js_options[:maxExtent] || "#{ Ropenlayer::Js.new_method("OpenLayers.Bounds", :args => ["-20037508", "-20037508", "20037508", "20037508.34"]) }"
112
- propierties
113
- end
114
-
115
-
116
- def set_center
117
- %(// Setting center
118
- #{ Ropenlayer::Js.new("#{ @js_id }.setCenter(#{ Ropenlayer::Js.new_method("OpenLayers.LonLat", :args => [ @longitude, @latitude ]) }, #{ @zoom })").to_js } )
119
- end
120
-
121
- def add_notification_area
122
- %(// Notification area
123
- #{ Ropenlayer::Js.new_var(@js_notification_area,
124
- Ropenlayer::Js.new_method('Element', :args => ["'div'"],
125
- :propierties => { :class => "'olMapNotificationArea'",
126
- :style => "'display: none;'",
127
- :id => "'#{ @js_notification_area }'" }).to_s).to_js }
128
- #{ Ropenlayer::Js.new("#{ @js_id }.div.insert(#{ @js_notification_area });").to_js }
129
- )
130
- end
131
-
132
-
133
-
134
- def self.default_layers
135
- [ :google_hybrid, :google_streets, :wms, :google_satellite, :google_physical, :osm ]
136
- end
137
-
138
- def self.default_latitude
139
- 4580313.35287
140
- end
141
-
142
- def self.default_longitude
143
- 263274.20626803
144
- end
145
-
146
- def self.default_zoom
147
- 4
148
- end
149
-
150
- def self.default_controls
151
- [ :scale_line, :mouse_position, :pan_panel, :navigation, :zoom_panel ]
152
- end
153
-
154
- # Map to JS OpenLayer construtor
155
- def to_js
156
- %(// Ropenlayer::Map.to_s OpenLayers Cartographic JS project licensed under BSD~style license. More information can be found at http://openlayers.org/
157
- #{ Ropenlayer::Js.new_var(@js_id, Ropenlayer::Js.new_method("OpenLayers.Map", :propierties => @js_propierties)).to_js }
158
-
159
- #{ add_notification_area }
160
-
161
- #{ @layers.map(&:to_js) }
162
- #{ @controls.map(&:to_js) }
163
-
164
- #{ set_center }
165
-
166
- #{ Ropenlayer::BoxControl::LayersSelect.new(self).to_js if @layers_select }
167
- #{ Ropenlayer::BoxControl::EditMap.new(self).to_js if @edit_map }
168
-
169
- #{ @vectors_layer.to_js }
170
- #{ @markers_layer.to_js }
171
- )
172
- end
173
- end
174
- end
175
-
176
-