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
@@ -0,0 +1,430 @@
1
+
2
+ /* Ropenlayer CSS customization */
3
+
4
+ /* Used in map */
5
+
6
+ /* olControlPanPanel: Move by click on move tools */
7
+ .olControlPanPanel { top: 10px; left: 10px; width: 55px; height: 55px; }
8
+ .olControlPanPanel div { background-image: url('../images/ropenlayer/pan-panel.png'); position: absolute; background-color: transparent;
9
+ background-repeat: no-repeat }
10
+ .olControlPanPanel div:hover { background-image: url('../images/ropenlayer/pan-panel_active.png'); }
11
+ .olControlPanPanel .olControlPanNorthItemInactive { top: 0px; left: 0px; height: 23px; width: 55px; background-position: 0px 0px; }
12
+ .olControlPanPanel .olControlPanSouthItemInactive { top: 33px; left: 0px; height: 22px; width: 55px; background-position: 0px -33px; }
13
+ .olControlPanPanel .olControlPanWestItemInactive { top: 23px; left: 0px; height: 10px; width: 28px; background-position: 0px -23px; }
14
+ .olControlPanPanel .olControlPanEastItemInactive { top: 23px; left: 28px; height: 10px; width: 27px; background-position: -28px -25px; }
15
+
16
+ /* olControlLayerBoxPanel: To display toolbar for select base layers */
17
+ .olControlLayersBoxControlPanel { top: 140px; left: 10px; width: 55px; min-height: 55px; position: absolute;
18
+ background: transparent url('../images/ropenlayer/layers_switch.png') no-repeat top left; }
19
+ .olControlLayersBoxControlPanel:hover { background-image: url('../images/ropenlayer/layers_switch_active.png') }
20
+ .olControlLayersBoxControlPanel .olControlLayersBoxControlItemActive { width: 55px; height: 55px; cursor: pointer; }
21
+ .olControlLayersBoxControlLinks { top: 140px; left: 85px; background-color: #16b87d; width: 250px; position: absolute;
22
+ border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; padding: 10px; border: 1px solid #ECECEC; }
23
+ .olControlLayersBoxControlLinks a { display: block; margin: 3px 3px; padding: 2px 2px; color: white; font-size: 1.1em; }
24
+ .olControlLayersBoxControlLinks a:hover { background-color: #03fda1; color: black; }
25
+
26
+
27
+ /* olControlEditMapPanel: To display toolbar for edit map options */
28
+ .olControlEditMapControlPanel { top: 200px; left: 10px; width: 55px; min-height: 55px; position: absolute;
29
+ background: transparent url('../images/ropenlayer/edit_map.png') no-repeat top left; }
30
+ .olControlEditMapControlPanel:hover { background-image: url('../images/ropenlayer/edit_map_active.png') }
31
+ .olControlEditMapControlPanel .olControlEditMapControlItemActive { width: 55px; height: 55px; cursor: pointer; }
32
+ .olControlEditMapControlLinks { top: 200px; left: 85px; background-color: #16b87d; width: 250px; position: absolute;
33
+ border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; padding: 10px; border: 1px solid #ECECEC; }
34
+ .olControlEditMapControlLinks a { display: block; margin: 3px 3px; color: white; font-size: 1.1em; }
35
+ .olControlEditMapControlLinks a:hover { background-color: #03fda1; color: black; }
36
+ .olControlEditMapControlLinks a.activeControl { background-color: white; color: black; }
37
+
38
+
39
+
40
+ /* olControlScaleLine: To display scale line */
41
+ .olControlScaleLine { display: block; position: absolute; left: 47%; bottom: 15px; font-size: x-small; }
42
+ .olControlScaleLineBottom { border: solid 2px #666666; border-bottom: none; border-top-width: 1px; margin-top:0px; text-align: center; }
43
+ .olControlScaleLineTop { border: solid 2px #666666; border-top: none; border-bottom-width: 1px; text-align: center; }
44
+
45
+
46
+ /* olControlMousePosition: To mouse position */
47
+ div.olControlMousePosition { bottom: 15px; right: 3px; display: block; position: absolute; font-family: Arial; font-size: smaller; color: white; }
48
+
49
+ /* olMapNotificationArea */
50
+ div.olMapNotificationArea { position: absolute; font-style: italic; font-size: 1.1em; background-color: #16b87d; top: 175px; margin-left: 120px; width: 400px; height: 20px;
51
+ padding: 5px; text-align: center; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border: 1px solid #ECECEC; }
52
+
53
+ /* olMapNewElementsArea */
54
+ div.olMapNewElementsArea { position: relative; margin-top: 40px; margin-left: 130px; font-size: 1.1em; background-color: white; width: 600px; height: 300px;
55
+ padding: 5px; text-align: center; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border: 1px solid #ECECEC;
56
+ overflow: auto; }
57
+
58
+
59
+ .olPopup, .olPopup span, .olPopop div { background-color: #16b87d !important; color: white !important; }
60
+ .olPopupContent { background-color: white !important; color: #666666 !important; margin-left: 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; }
61
+
62
+
63
+ /* DEFAULT NEED REVIEW */
64
+ .olControlZoomPanel {
65
+ top: 75px;
66
+ left: 10px;
67
+ width: 55px;
68
+ height: 55px;
69
+ }
70
+
71
+ .olControlZoomPanel div {
72
+ background-image: url('../images/ropenlayer/zoom-panel.png');
73
+ position: absolute;
74
+ cursor: pointer;
75
+ width: 55px;
76
+
77
+ }
78
+
79
+ .olControlZoomPanel div:hover {
80
+ background-image: url('../images/ropenlayer/zoom-panel_active.png');
81
+ }
82
+
83
+
84
+ .olControlZoomPanel .olControlZoomInItemInactive {
85
+ top: 0px;
86
+ left: 0px;
87
+ height: 20px;
88
+ background-position: 0px 0px;
89
+ }
90
+
91
+ .olControlZoomPanel .olControlZoomToMaxExtentItemInactive {
92
+ top: 20px;
93
+ left: 0px;
94
+ background-position: 0px -20px;
95
+ height: 15px;
96
+
97
+ }
98
+
99
+ .olControlZoomPanel .olControlZoomOutItemInactive {
100
+ top: 35px;
101
+ left: 0px;
102
+ height: 20px;
103
+ background-position: 0px -35px;
104
+ }
105
+
106
+
107
+
108
+
109
+
110
+ /* No used */
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+ div.olMap {
120
+ z-index: 0;
121
+ padding: 0px!important;
122
+ margin: 0px!important;
123
+ cursor: default;
124
+ }
125
+
126
+ div.olMapViewport {
127
+ text-align: left;
128
+ }
129
+
130
+ div.olLayerDiv {
131
+ -moz-user-select: none;
132
+ }
133
+
134
+ .olLayerGoogleCopyright {
135
+ left: 2px;
136
+ bottom: 2px;
137
+ }
138
+ .olLayerGooglePoweredBy {
139
+ left: 2px;
140
+ bottom: 15px;
141
+ }
142
+ .olControlAttribution {
143
+ font-size: smaller;
144
+ right: 3px;
145
+ bottom: 4.5em;
146
+ position: absolute;
147
+ display: block;
148
+ }
149
+ .olControlScale {
150
+ right: 3px;
151
+ bottom: 3em;
152
+ display: block;
153
+ position: absolute;
154
+ font-size: smaller;
155
+ }
156
+
157
+
158
+ .olControlPermalink {
159
+ right: 3px;
160
+ bottom: 1.5em;
161
+ display: block;
162
+ position: absolute;
163
+ font-size: smaller;
164
+ }
165
+
166
+
167
+ .olControlOverviewMapContainer {
168
+ position: absolute;
169
+ bottom: 0px;
170
+ right: 0px;
171
+ }
172
+
173
+ .olControlOverviewMapElement {
174
+ padding: 10px 18px 10px 10px;
175
+ background-color: #00008B;
176
+ -moz-border-radius: 1em 0 0 0;
177
+ }
178
+
179
+ .olControlOverviewMapMinimizeButton {
180
+ right: 0px;
181
+ bottom: 80px;
182
+ }
183
+
184
+ .olControlOverviewMapMaximizeButton {
185
+ right: 0px;
186
+ bottom: 80px;
187
+ }
188
+
189
+ .olControlOverviewMapExtentRectangle {
190
+ overflow: hidden;
191
+ background-image: url("../images/ropenlayer/blank.gif");
192
+ cursor: move;
193
+ border: 2px dotted red;
194
+ }
195
+ .olControlOverviewMapRectReplacement {
196
+ overflow: hidden;
197
+ cursor: move;
198
+ background-image: url("../images/ropenlayer/overview_replacement.gif");
199
+ background-repeat: no-repeat;
200
+ background-position: center;
201
+ }
202
+
203
+ .olLayerGeoRSSDescription {
204
+ float:left;
205
+ width:100%;
206
+ overflow:auto;
207
+ font-size:1.0em;
208
+ }
209
+ .olLayerGeoRSSClose {
210
+ float:right;
211
+ color:gray;
212
+ font-size:1.2em;
213
+ margin-right:6px;
214
+ font-family:sans-serif;
215
+ }
216
+ .olLayerGeoRSSTitle {
217
+ float:left;font-size:1.2em;
218
+ }
219
+
220
+ .olPopupContent {
221
+ padding:5px;
222
+ overflow: auto;
223
+ }
224
+ .olControlNavToolbar {
225
+ width:0px;
226
+ height:0px;
227
+ }
228
+ .olControlNavToolbar div {
229
+ display:block;
230
+ width: 28px;
231
+ height: 28px;
232
+ top: 300px;
233
+ left: 6px;
234
+ position: relative;
235
+ }
236
+
237
+ .olControlNavigationHistory {
238
+ background-image: url("../images/ropenlayer/navigation_history.png");
239
+ background-repeat: no-repeat;
240
+ width: 24px;
241
+ height: 24px;
242
+
243
+ }
244
+ .olControlNavigationHistoryPreviousItemActive {
245
+ background-position: 0px 0px;
246
+ }
247
+ .olControlNavigationHistoryPreviousItemInactive {
248
+ background-position: 0px -24px;
249
+ }
250
+ .olControlNavigationHistoryNextItemActive {
251
+ background-position: -24px 0px;
252
+ }
253
+ .olControlNavigationHistoryNextItemInactive {
254
+ background-position: -24px -24px;
255
+ }
256
+
257
+ .olControlNavToolbar .olControlNavigationItemActive {
258
+ background-image: url("../images/ropenlayer/panning-hand-on.png");
259
+ background-repeat: no-repeat;
260
+ }
261
+ .olControlNavToolbar .olControlNavigationItemInactive {
262
+ background-image: url("../images/ropenlayer/panning-hand-off.png");
263
+ background-repeat: no-repeat;
264
+ }
265
+ .olControlNavToolbar .olControlZoomBoxItemActive {
266
+ background-image: url("../images/ropenlayer/drag-rectangle-on.png");
267
+ background-color: orange;
268
+ background-repeat: no-repeat;
269
+ }
270
+ .olControlNavToolbar .olControlZoomBoxItemInactive {
271
+ background-image: url("../images/ropenlayer/drag-rectangle-off.png");
272
+ background-repeat: no-repeat;
273
+ }
274
+ .olControlEditingToolbar {
275
+ float:right;
276
+ right: 0px;
277
+ height: 30px;
278
+ width: 200px;
279
+ }
280
+ .olControlEditingToolbar div {
281
+ background-image: url("../images/ropenlayer/editing_tool_bar.png");
282
+ background-repeat: no-repeat;
283
+ float:right;
284
+ width: 24px;
285
+ height: 24px;
286
+ margin: 5px;
287
+ }
288
+ .olControlEditingToolbar .olControlNavigationItemActive {
289
+ background-position: -103px -23px;
290
+ }
291
+ .olControlEditingToolbar .olControlNavigationItemInactive {
292
+ background-position: -103px -0px;
293
+ }
294
+ .olControlEditingToolbar .olControlDrawFeaturePointItemActive {
295
+ background-position: -77px -23px;
296
+ }
297
+ .olControlEditingToolbar .olControlDrawFeaturePointItemInactive {
298
+ background-position: -77px -0px;
299
+ }
300
+ .olControlEditingToolbar .olControlDrawFeaturePathItemInactive {
301
+ background-position: -51px 0px;
302
+ }
303
+ .olControlEditingToolbar .olControlDrawFeaturePathItemActive {
304
+ background-position: -51px -23px;
305
+ }
306
+ .olControlEditingToolbar .olControlDrawFeaturePolygonItemInactive {
307
+ background-position: -26px 0px;
308
+ }
309
+ .olControlEditingToolbar .olControlDrawFeaturePolygonItemActive {
310
+ background-position: -26px -23px ;
311
+ }
312
+ div.olControlSaveFeaturesItemActive {
313
+ background-image: url(../images/ropenlayer/save_features_on.png);
314
+ background-repeat: no-repeat;
315
+ background-position: 0px 1px;
316
+ }
317
+ div.olControlSaveFeaturesItemInactive {
318
+ background-image: url(../images/ropenlayer/save_features_off.png);
319
+ background-repeat: no-repeat;
320
+ background-position: 0px 1px;
321
+ }
322
+
323
+ .olHandlerBoxZoomBox {
324
+ border: 2px solid red;
325
+ position: absolute;
326
+ background-color: white;
327
+ opacity: 0.50;
328
+ font-size: 1px;
329
+ filter: alpha(opacity=50);
330
+ }
331
+ .olHandlerBoxSelectFeature {
332
+ border: 2px solid blue;
333
+ position: absolute;
334
+ background-color: white;
335
+ opacity: 0.50;
336
+ font-size: 1px;
337
+ filter: alpha(opacity=50);
338
+ }
339
+
340
+ .olPopupCloseBox {
341
+ background: url("../images/ropenlayer/close.gif") no-repeat;
342
+ cursor: pointer;
343
+ }
344
+
345
+ .olFramedCloudPopupContent {
346
+ padding: 5px;
347
+ overflow: auto;
348
+ }
349
+
350
+ .olControlNoSelect {
351
+ -moz-user-select: none;
352
+ }
353
+
354
+ .olImageLoadError {
355
+ background-color: pink;
356
+ opacity: 0.5;
357
+ filter: alpha(opacity=50); /* IE */
358
+ }
359
+
360
+ /**
361
+ * Cursor styles
362
+ */
363
+
364
+ .olCursorWait {
365
+ cursor: wait;
366
+ }
367
+ .olDragDown {
368
+ cursor: move;
369
+ }
370
+ .olDrawBox {
371
+ cursor: crosshair;
372
+ }
373
+ .olControlDragFeatureOver {
374
+ cursor: move;
375
+ }
376
+ .olControlDragFeatureActive.olControlDragFeatureOver.olDragDown {
377
+ cursor: -moz-grabbing;
378
+ }
379
+
380
+ /**
381
+ * Layer switcher
382
+ */
383
+
384
+
385
+ .olControlLayerSwitcher {
386
+ position: absolute;
387
+ top: 125px;
388
+ left: 32px;
389
+ width: 25em;
390
+ font-family: sans-serif;
391
+ font-weight: bold;
392
+ margin-left: 3px;
393
+ margin-bottom: 3px;
394
+ font-size: smaller;
395
+ color: white;
396
+ background-color: transparent;
397
+ cursor: pointer;
398
+ }
399
+ .olControlLayerSwitcher span {
400
+ background-color: #83d4b6 !important;
401
+ opacity: 1 !important;
402
+ }
403
+ .olControlLayerSwitcher .layersDiv {
404
+ padding-top: 5px;
405
+ padding-bottom: 5px;
406
+ background-color: #83d4b6;
407
+ width: 100%;
408
+ height: 100%;
409
+ opacity: 1 !important;
410
+
411
+ }
412
+
413
+ .olControlLayerSwitcher .layersDiv .baseLbl,
414
+ .olControlLayerSwitcher .layersDiv .dataLbl {
415
+ margin-top: 3px;
416
+ margin-left: 3px;
417
+ margin-bottom: 3px;
418
+ }
419
+
420
+ .olControlLayerSwitcher .layersDiv .baseLayersDiv,
421
+ .olControlLayerSwitcher .layersDiv .dataLayersDiv {
422
+ padding-left: 10px;
423
+ }
424
+
425
+ .olControlLayerSwitcher .maximizeDiv,
426
+ .olControlLayerSwitcher .minimizeDiv {
427
+ top: 5px;
428
+ right: 0px;
429
+ }
430
+
@@ -0,0 +1,10 @@
1
+ Ropenlayer
2
+ ==========
3
+
4
+ # Generate models to store maps informations
5
+ # It generate four models: Ropenlayer::Map, Ropenlayer::Element, Ropenlayer::Localization, Ropenlayer::Category and Ropenlayer::Icon
6
+ #
7
+ # Backend for icons is paperclip. Atm, no others are supported
8
+
9
+ rails generate ropenlayer:migration
10
+
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Ropenlayer
5
+ class MigrationGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ desc "Generates migration for Ropenlayers models"
9
+ def self.source_root
10
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
11
+ end
12
+
13
+ def self.next_migration_number(dirname)
14
+ Time.now.strftime("%Y%m%d%H%M%S")
15
+ end
16
+
17
+
18
+ def migration
19
+ migration_template "migration.rb", File.join('db/migrate', "create_ropenlayer_structure.rb")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ class CreateRopenlayerStructure < ActiveRecord::Migration
2
+
3
+ def self.up
4
+
5
+ create_table :ropenlayer_nodes do |t|
6
+ t.string :mapper_id
7
+ t.integer :mapper_type
8
+ t.string :geometry
9
+ t.integer :category_id
10
+ t.integer :icon_id
11
+ t.string :nodeable_type
12
+ t.integer :nodeable_id
13
+ t.timestamps
14
+ end
15
+
16
+ create_table :ropenlayer_localizations do |t|
17
+ t.float :longitude
18
+ t.float :latitude
19
+ t.integer :node_id
20
+ t.integer :order
21
+ t.timestamps
22
+ end
23
+
24
+
25
+ end
26
+
27
+ def self.down
28
+ drop_table :ropenlayer_nodes
29
+ drop_table :ropenlayer_localizations
30
+ end
31
+ end
@@ -0,0 +1,147 @@
1
+ module Ropenlayer
2
+ module ActsAs
3
+
4
+ # acts_as_map: give to the model map construiction and build facilities.
5
+ #
6
+ # class Team < ActiveRecord::Base
7
+ # acts_as_map :default_layer => :google_streets
8
+ # end
9
+ #
10
+ # Avalaible options:
11
+ #
12
+ # - :longitude, :latitude, :zoom : Default starting values for map. Can be a float (latitude, longitude) or integer (zoom) object, so values will be parsed as them are.
13
+ # A Symbol, in this case, ropenlayer will send :symbol method to mapper instance, or a valid Proc object
14
+ # - :default_layer: Default layer for visualization. For avalaible layers see Ropenlayer::Openlayer::Map
15
+ # - :nodes: Relations which can be pointed on the map. Relations are expected to have acts_as_localizable_on behaviour in their class
16
+ #
17
+ # Examples
18
+ #
19
+ # Build a Map with static features, just for localization
20
+ #
21
+ # class Team < ActiveRecord::Base
22
+ # acts_as_map :default_layer => :google_streets, :latitude => 40000.23, :longitude => 54555.233, :zoom => 3
23
+ # end
24
+ #
25
+ # Build a Map with Proc calls to perform automatic localization on forms
26
+ #
27
+ # class Team < ActiveRecord
28
+ #
29
+ # has_many :offices
30
+ # has_one :main_office, :conditions => { :main => true }
31
+ #
32
+ # acts_as_map :default_layer => :google_streets, :longitude => :main_office_longitude, :latitude => :main_office_latitude, :zoom => :main_office_zoom
33
+ # :nodes => [ :offices ]
34
+ #
35
+ # def main_office_longitude
36
+ # main_office.longitude
37
+ # end
38
+ #
39
+ # def main_office_longitude=(value)
40
+ # main_office_longitude = value
41
+ # end
42
+ #
43
+ # def main_office_latitude
44
+ # main_office.latitude
45
+ # end
46
+ #
47
+ # def main_office_latitude=(value)
48
+ # main_office.latitude = value
49
+ # end
50
+ #
51
+ # def main_office_longitude
52
+ # main_office.longitude
53
+ # end
54
+ #
55
+ # def main_office_zoom=(value)
56
+ # main_office.zoom = value
57
+ # end
58
+ #
59
+ # end
60
+ #
61
+ module Mapper
62
+
63
+ class << self
64
+ def included(base)
65
+
66
+ base.class_eval do
67
+
68
+ base.send :include, InstanceMethods
69
+
70
+ localizable = [:longitude, :latitude, :zoom ].inject(true) do |all_positions, position|
71
+ all_positions = false unless self.ropenlayer_mapper_config[position].is_a?(Symbol) and self.attribute_method?(self.ropenlayer_mapper_config[position])
72
+ all_positions
73
+ end
74
+
75
+ send("class_variable_set", "@@localizable", true) if localizable
76
+
77
+ end
78
+ end
79
+
80
+ module InstanceMethods
81
+
82
+ # return ropenlayer_map instance or create a new one with the given data
83
+ # options can be override
84
+ def ropenlayer_map(options = {})
85
+ container_id = options.delete(:container_id) || "#{ self.class.name.underscore }_ropenlayer_map"
86
+
87
+ @ropenlayer_map.nil? ? build_map(container_id, options) : @ropenlayer_map
88
+ end
89
+
90
+
91
+ def build_map(container_id, map_config = {})
92
+ config = self.class.ropenlayer_mapper_config.merge(map_config)
93
+ config = set_map_localization(config)
94
+ config = parse_nodes(config)
95
+ @ropenlayer_map = Ropenlayer::Openlayer::Map.new(container_id, config)
96
+ end
97
+
98
+ # Ensure model acts_as_mapper
99
+ def ensure_mapper_model
100
+ error = "Model `#{ self.class }` doesnt acts as map"
101
+ raise error unless self.class.methods.include?("acts_as_mapper") and self.class.acts_as_mapper
102
+ end
103
+
104
+ # Ensure model can be localizable
105
+ def ensure_localizable_model
106
+ error = "Model `#{ self.class }` is not localizable. To use this facility, latitude, longitude and zoom should be mapped to a valid instance methods"
107
+ raise error unless self.class.methods.include?("localizable") and self.class.localizable
108
+ end
109
+
110
+ private
111
+ # Parse nodes from nodes relations
112
+ # It will call node_data method to any record on relation
113
+ def parse_nodes(config)
114
+ node_relations = config[:nodes] || []
115
+ config[:draw_features] = []
116
+ node_relations.each do |relation|
117
+ config[:draw_features].concat(self.send(relation).map(&:node_data).select{ |node| not node.nil? })
118
+ end
119
+ config
120
+ end
121
+
122
+
123
+ # Set default localization if avalaible
124
+ # Longitude and latitude are parsed by default as float if Proc or Symbol are not defined. Zoom, by default, as integer
125
+ def set_map_localization(config)
126
+ defult_localization_values = { :longitude => :to_f, :latitude => :to_f, :zoom => :to_i }
127
+
128
+ defult_localization_values.each do |axis, default_method|
129
+ eval_value = config.delete(axis)
130
+ value = 0
131
+ case eval_value
132
+ when Symbol
133
+ value = self.send(eval_value)
134
+ when Proc
135
+ value = eval_value.call(self)
136
+ else
137
+ value = eval_value.send(default_method)
138
+ end
139
+ config[axis] = value unless value.to_i.zero?
140
+ end
141
+ config
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end