atlas_on_rails 0.1.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.
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class AtlasOnRailTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,757 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GoogleTest < Test::Unit::TestCase
4
+
5
+ # Setting up a new controller with a series of actions for testing
6
+ # Given the level of interaction required between the rails environment,
7
+ # ActionView and it's helpers I found this the most appropriate way to
8
+ # ensure the plugin will work in production
9
+ class TestingController < ApplicationController
10
+
11
+ def google_get_key
12
+ @map = AtlasMap.new(:api=>'google')
13
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
14
+ end
15
+
16
+ def google_simple_paloalto_javascript
17
+ @map = AtlasMap.new(
18
+ :api=>'google',
19
+ :name=>'map',
20
+ :latitude=>'37.4419',
21
+ :longitude=>'-122.1419',
22
+ :zoom=>13
23
+ )
24
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
25
+ end
26
+
27
+ def google_eventlistener_moveend
28
+ @map = AtlasMap.new(
29
+ :api=>'google',
30
+ :name=>'map',
31
+ :latitude=>'37.4419',
32
+ :longitude=>'-122.1419',
33
+ :zoom=>13
34
+ )
35
+ @map.events << AtlasEvent.new(:name=>'moveend',:function=>'alert()')
36
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
37
+ end
38
+
39
+ def google_add_marker
40
+ @map = AtlasMap.new(
41
+ :api=>'google',
42
+ :name=>'map',
43
+ :latitude=>'37.4419',
44
+ :longitude=>'-122.1419',
45
+ :zoom=>13
46
+ )
47
+ @map.markers << AtlasMarker.new(:latitude=>30, :longitude=>20)
48
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
49
+ end
50
+
51
+ def google_add_window
52
+ @map = AtlasMap.new(
53
+ :api=>'google',
54
+ :name=>'map',
55
+ :latitude=>'37.4419',
56
+ :longitude=>'-122.1419',
57
+ :zoom=>13
58
+ )
59
+ @map.windows << AtlasWindow.new(:latitude=>30,:longitude=>20,:text=>"Hello World!!")
60
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
61
+ end
62
+
63
+ def google_add_tabbed_window
64
+ @map = AtlasMap.new(
65
+ :api=>'google',
66
+ :name=>'map',
67
+ :latitude=>'37.4419',
68
+ :longitude=>'-122.1419',
69
+ :zoom=>13
70
+ )
71
+ @map.windows << AtlasWindow.new(:latitude=>30,:longitude=>20,:text=>[["Hello World!!","Hello world content"],["Goodbye","and goodnight"]])
72
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
73
+ end
74
+
75
+ def google_add_tabbed_window_with_partial
76
+ @map = AtlasMap.new(
77
+ :api=>'google',
78
+ :name=>'map',
79
+ :latitude=>'37.4419',
80
+ :longitude=>'-122.1419',
81
+ :zoom=>13
82
+ )
83
+ @map.windows << AtlasWindow.new(:latitude=>30,:longitude=>20,:text=>[["Hello World!!","Hello world content"],["Goodbye","and goodnight"]])
84
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
85
+ end
86
+
87
+ def google_add_custom_icon
88
+ @map = AtlasMap.new(
89
+ :api=>'google',
90
+ :name=>'map',
91
+ :latitude=>'37.4419',
92
+ :longitude=>'-122.1419',
93
+ :zoom=>13
94
+ )
95
+ @map.icons << AtlasIcon.new(:image=>'images/map_icon.png',:shadow=>'images/map_icon_shadow.png',:width=>20,:height=>30,:shadow_width=>40,:shadow_height=>50,:icon_anchor_x=>1,:icon_anchor_y=>2,:window_anchor_x=>3,:window_anchor_y=>4)
96
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
97
+ end
98
+
99
+ def google_add_marker_with_custom_icon
100
+ @map = AtlasMap.new(
101
+ :api=>'google',
102
+ :name=>'map',
103
+ :latitude=>'37.4419',
104
+ :longitude=>'-122.1419',
105
+ :zoom=>13
106
+ )
107
+ @map.markers << AtlasMarker.new(:latitude=>30,:longitude=>20, :icon=>AtlasIcon.new(:image=>'images/map_icon.png',:shadow=>'images/map_icon_shadow.png',:width=>20,:height=>30,:shadow_width=>40,:shadow_height=>50,:icon_anchor_x=>1,:icon_anchor_y=>2,:window_anchor_x=>3,:window_anchor_y=>4))
108
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
109
+ end
110
+
111
+ def google_add_two_markers_with_custom_icon
112
+ @map = AtlasMap.new(
113
+ :api=>'google',
114
+ :name=>'map',
115
+ :latitude=>'37.4419',
116
+ :longitude=>'-122.1419',
117
+ :zoom=>13
118
+ )
119
+ @my_icon = AtlasIcon.new(:image=>'images/map_icon.png',:shadow=>'images/map_icon_shadow.png',:width=>20,:height=>30,:shadow_width=>40,:shadow_height=>50,:icon_anchor_x=>1,:icon_anchor_y=>2,:window_anchor_x=>3,:window_anchor_y=>4)
120
+ @map.markers << AtlasMarker.new(:latitude=>30,:longitude=>20, :icon=>@my_icon)
121
+ @map.markers << AtlasMarker.new(:latitude=>40,:longitude=>50, :icon=>@my_icon)
122
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
123
+ end
124
+
125
+ def google_add_two_tabbed_windows_with_custom_icons
126
+ @map = AtlasMap.new(
127
+ :api=>'google',
128
+ :name=>'map',
129
+ :latitude=>'37.4419',
130
+ :longitude=>'-122.1419',
131
+ :zoom=>13
132
+ )
133
+ @my_icon = AtlasIcon.new(:image=>'images/map_icon.png',:shadow=>'images/map_icon_shadow.png',:width=>20,:height=>30,:shadow_width=>40,:shadow_height=>50,:icon_anchor_x=>1,:icon_anchor_y=>2,:window_anchor_x=>3,:window_anchor_y=>4)
134
+ @my_icon2 = AtlasIcon.new(:image=>'images/map_icon2.png',:width=>30,:height=>40,:icon_anchor_x=>2,:icon_anchor_y=>3,:window_anchor_x=>4,:window_anchor_y=>5)
135
+ @map.windows << AtlasWindow.new(:latitude=>30,:longitude=>20,:icon=>@my_icon,:text=>[["Hello World!!","Hello world content"],["Goodbye","and goodnight"]])
136
+ @map.windows << AtlasWindow.new(:latitude=>60,:longitude=>70,:icon=>@my_icon2,:text=>[["What's happening?","This is just a test!"],["Did it work?","Definitely!"]])
137
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
138
+ end
139
+
140
+ def google_polyline
141
+ @map = AtlasMap.new(
142
+ :api=>'google',
143
+ :name=>'map',
144
+ :latitude=>'37.4419',
145
+ :longitude=>'-122.1419',
146
+ :zoom=>13
147
+ )
148
+ @points = Array.new()
149
+ @points << [37.4419, -122.1419]
150
+ @points << [37.4519, -122.1519]
151
+ @points << [37.4619, -122.1819]
152
+ @map.polylines << AtlasPolyline.new(:points=>@points,:color=>'#FF0000', :max_zoom=>10)
153
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
154
+ end
155
+
156
+ def google_display_small_controls
157
+ @map = AtlasMap.new(
158
+ :api=>'google',
159
+ :name=>'map',
160
+ :latitude=>'37.4419',
161
+ :longitude=>'-122.1419',
162
+ :zoom=>13,
163
+ :pan_control=>'small'
164
+ )
165
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
166
+ end
167
+
168
+ def google_display_large_controls
169
+ @map = AtlasMap.new(
170
+ :api=>'google',
171
+ :name=>'map',
172
+ :latitude=>'37.4419',
173
+ :longitude=>'-122.1419',
174
+ :zoom=>13,
175
+ :pan_control=>'large'
176
+ )
177
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
178
+ end
179
+
180
+ def google_display_small_zoom
181
+ @map = AtlasMap.new(
182
+ :api=>'google',
183
+ :name=>'map',
184
+ :latitude=>'37.4419',
185
+ :longitude=>'-122.1419',
186
+ :zoom=>13,
187
+ :zoom_control=>'small'
188
+ )
189
+ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
190
+ end
191
+
192
+ #~ def google_add_tabbed_window_with_custom_icon_and_partial
193
+ #~ @map = AtlasMap.new(
194
+ #~ :api=>'google',
195
+ #~ :name=>'map',
196
+ #~ :latitude=>'37.4419',
197
+ #~ :longitude=>'-122.1419',
198
+ #~ :zoom=>13
199
+ #~ )
200
+ #~ @my_icon = AtlasIcon.new(:image=>'images/map_icon.png',:shadow=>'images/map_icon_shadow.png',:width=>20,:height=>30,:shadow_width=>40,:shadow_height=>50,:icon_anchor_x=>1,:icon_anchor_y=>2,:window_anchor_x=>3,:window_anchor_y=>4)
201
+ #~ @map.windows << AtlasWindow.new(:latitude=>30, :longitude=>20, :icon=>@my_icon, :text=>{:partial=>'article', :collection=>@articles, :locals=>{ :somevariable=>'somevalue'}})
202
+ #~ render :file=>File.dirname(__FILE__) + '/../atlas_rails_root/app/views/testing/index.rhtml'
203
+ #~ end
204
+ end
205
+
206
+ # And now we begin the actual tests
207
+ def setup
208
+ @controller = TestingController.new
209
+ @request = ActionController::TestRequest.new
210
+ @response = ActionController::TestResponse.new
211
+ end
212
+
213
+ def test_google_simple_paloalto_javascript
214
+ get :google_simple_paloalto_javascript
215
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
216
+ //<![CDATA[
217
+ atlas_map_load = function() {
218
+ if (GBrowserIsCompatible()) {
219
+ var map = new GMap2(document.getElementById("map"));
220
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
221
+ }
222
+ }
223
+ atlas_unload = function() { GUnload(); }
224
+ function addEvent(obj, evType, fn){
225
+ if (obj.addEventListener){
226
+ obj.addEventListener(evType, fn, false);
227
+ return true;
228
+ } else if (obj.attachEvent){
229
+ var r = obj.attachEvent("on"+evType, fn);
230
+ return r;
231
+ } else {
232
+ return false;
233
+ }
234
+ }
235
+ addEvent(window, \'load\',atlas_map_load);
236
+ addEvent(window, \'unload\',atlas_unload);
237
+ //]]>
238
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
239
+ end
240
+
241
+ def test_google_eventlistener_moveend
242
+ get :google_eventlistener_moveend
243
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
244
+ //<![CDATA[
245
+ atlas_map_load = function() {
246
+ if (GBrowserIsCompatible()) {
247
+ var map = new GMap2(document.getElementById("map"));
248
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
249
+ GEvent.addListener(map, "moveend", alert());
250
+ }
251
+ }
252
+ atlas_unload = function() { GUnload(); }
253
+ function addEvent(obj, evType, fn){
254
+ if (obj.addEventListener){
255
+ obj.addEventListener(evType, fn, false);
256
+ return true;
257
+ } else if (obj.attachEvent){
258
+ var r = obj.attachEvent("on"+evType, fn);
259
+ return r;
260
+ } else {
261
+ return false;
262
+ }
263
+ }
264
+ addEvent(window, \'load\',atlas_map_load);
265
+ addEvent(window, \'unload\',atlas_unload);
266
+ //]]>
267
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
268
+ end
269
+
270
+ def test_google_add_marker
271
+ get :google_add_marker
272
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
273
+ //<![CDATA[
274
+ atlas_map_load = function() {
275
+ if (GBrowserIsCompatible()) {
276
+ var map = new GMap2(document.getElementById("map"));
277
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
278
+ map.addOverlay(new GMarker(new GLatLng(30,20)))
279
+ }
280
+ }
281
+ atlas_unload = function() { GUnload(); }
282
+ function addEvent(obj, evType, fn){
283
+ if (obj.addEventListener){
284
+ obj.addEventListener(evType, fn, false);
285
+ return true;
286
+ } else if (obj.attachEvent){
287
+ var r = obj.attachEvent("on"+evType, fn);
288
+ return r;
289
+ } else {
290
+ return false;
291
+ }
292
+ }
293
+ addEvent(window, \'load\',atlas_map_load);
294
+ addEvent(window, \'unload\',atlas_unload);
295
+ //]]>
296
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
297
+ end
298
+
299
+ def test_google_add_window
300
+ get :google_add_window
301
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
302
+ //<![CDATA[
303
+ atlas_map_load = function() {
304
+ if (GBrowserIsCompatible()) {
305
+ var map = new GMap2(document.getElementById("map"));
306
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
307
+ atlas_text = \'Hello World!!\'
308
+ atlas_marker = atlas_create_windowed_marker(30,20,atlas_text)
309
+ map.addOverlay(atlas_marker)
310
+ }
311
+ }
312
+
313
+ function atlas_create_windowed_marker(atLat, atLng, atText, atIcon) {
314
+ var marker = new GMarker(new GLatLng(atLat, atLng), atIcon);
315
+ GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(atText); });
316
+ return marker
317
+ }
318
+ atlas_unload = function() { GUnload(); }
319
+ function addEvent(obj, evType, fn){
320
+ if (obj.addEventListener){
321
+ obj.addEventListener(evType, fn, false);
322
+ return true;
323
+ } else if (obj.attachEvent){
324
+ var r = obj.attachEvent("on"+evType, fn);
325
+ return r;
326
+ } else {
327
+ return false;
328
+ }
329
+ }
330
+ addEvent(window, \'load\',atlas_map_load);
331
+ addEvent(window, \'unload\',atlas_unload);
332
+ //]]>
333
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
334
+ end
335
+
336
+ def test_google_add_tabbed_window
337
+ get :google_add_tabbed_window
338
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
339
+ //<![CDATA[
340
+ atlas_map_load = function() {
341
+ if (GBrowserIsCompatible()) {
342
+ var map = new GMap2(document.getElementById("map"));
343
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
344
+ atlas_tabs = [new GInfoWindowTab("Hello World!!","Hello world content"), new GInfoWindowTab("Goodbye","and goodnight")]
345
+ atlas_marker = atlas_create_tabwindowed_marker(30,20,atlas_tabs)
346
+ map.addOverlay(atlas_marker)
347
+ }
348
+ }
349
+
350
+ function atlas_create_tabwindowed_marker(atLat, atLng, atTabs, atIcon) {
351
+ var marker = new GMarker(new GLatLng(atLat, atLng), atIcon);
352
+ GEvent.addListener(marker, "click", function() { marker.openInfoWindowTabsHtml(atTabs); });
353
+ return marker
354
+ }
355
+ atlas_unload = function() { GUnload(); }
356
+ function addEvent(obj, evType, fn){
357
+ if (obj.addEventListener){
358
+ obj.addEventListener(evType, fn, false);
359
+ return true;
360
+ } else if (obj.attachEvent){
361
+ var r = obj.attachEvent("on"+evType, fn);
362
+ return r;
363
+ } else {
364
+ return false;
365
+ }
366
+ }
367
+ addEvent(window, \'load\',atlas_map_load);
368
+ addEvent(window, \'unload\',atlas_unload);
369
+ //]]>
370
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
371
+ end
372
+
373
+ def test_google_add_tabbed_window_with_partial
374
+ get :google_add_tabbed_window_with_partial
375
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
376
+ //<![CDATA[
377
+ atlas_map_load = function() {
378
+ if (GBrowserIsCompatible()) {
379
+ var map = new GMap2(document.getElementById("map"));
380
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
381
+ atlas_tabs = [new GInfoWindowTab("Hello World!!","Hello world content"), new GInfoWindowTab("Goodbye","and goodnight")]
382
+ atlas_marker = atlas_create_tabwindowed_marker(30,20,atlas_tabs)
383
+ map.addOverlay(atlas_marker)
384
+ }
385
+ }
386
+
387
+ function atlas_create_tabwindowed_marker(atLat, atLng, atTabs, atIcon) {
388
+ var marker = new GMarker(new GLatLng(atLat, atLng), atIcon);
389
+ GEvent.addListener(marker, "click", function() { marker.openInfoWindowTabsHtml(atTabs); });
390
+ return marker
391
+ }
392
+ atlas_unload = function() { GUnload(); }
393
+ function addEvent(obj, evType, fn){
394
+ if (obj.addEventListener){
395
+ obj.addEventListener(evType, fn, false);
396
+ return true;
397
+ } else if (obj.attachEvent){
398
+ var r = obj.attachEvent("on"+evType, fn);
399
+ return r;
400
+ } else {
401
+ return false;
402
+ }
403
+ }
404
+ addEvent(window, \'load\',atlas_map_load);
405
+ addEvent(window, \'unload\',atlas_unload);
406
+ //]]>
407
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
408
+ end
409
+
410
+ def test_google_add_custom_icon
411
+ get :google_add_custom_icon
412
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
413
+ //<![CDATA[
414
+ atlas_map_load = function() {
415
+ if (GBrowserIsCompatible()) {
416
+ var map = new GMap2(document.getElementById("map"));
417
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
418
+ map_icon = atlas_create_icon(\'images/map_icon.png\',[20,30],[1,2],\'images/map_icon_shadow.png\',[40,50],[3,4])
419
+ }
420
+ }
421
+
422
+ function atlas_create_icon(imagePath, imageDimensions, imageAnchor, shadowPath, shadowDimensions, windowAnchor) {
423
+ var icon = new GIcon();
424
+ icon.image = imagePath;
425
+ if (shadowPath!=undefined) { icon.shadow = shadowPath;}
426
+ icon.iconSize = imageDimensions!=undefined ? new GSize(imageDimensions[0], imageDimensions[1]) : new GSize(10,10);
427
+ icon.shadowSize = shadowDimensions!=undefined ? new GSize(shadowDimensions[0], shadowDimensions[1]) : new GSize(0,0);
428
+ icon.iconAnchor = imageAnchor!=undefined ? new GPoint(imageAnchor[0], imageAnchor[1]) : new GPoint(10,5);
429
+ icon.infoWindowAnchor = windowAnchor!=undefined ? new GPoint(windowAnchor[0], windowAnchor[1]) : new GPoint(10,5);
430
+ return icon
431
+ }
432
+ atlas_unload = function() { GUnload(); }
433
+ function addEvent(obj, evType, fn){
434
+ if (obj.addEventListener){
435
+ obj.addEventListener(evType, fn, false);
436
+ return true;
437
+ } else if (obj.attachEvent){
438
+ var r = obj.attachEvent("on"+evType, fn);
439
+ return r;
440
+ } else {
441
+ return false;
442
+ }
443
+ }
444
+ addEvent(window, \'load\',atlas_map_load);
445
+ addEvent(window, \'unload\',atlas_unload);
446
+ //]]>
447
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
448
+ end
449
+
450
+ def test_google_add_marker_with_custom_icon
451
+ get :google_add_marker_with_custom_icon
452
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
453
+ //<![CDATA[
454
+ atlas_map_load = function() {
455
+ if (GBrowserIsCompatible()) {
456
+ var map = new GMap2(document.getElementById("map"));
457
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
458
+ map_icon = atlas_create_icon(\'images/map_icon.png\',[20,30],[1,2],\'images/map_icon_shadow.png\',[40,50],[3,4])
459
+ map.addOverlay(new GMarker(new GLatLng(30,20),map_icon))
460
+ }
461
+ }
462
+
463
+ function atlas_create_icon(imagePath, imageDimensions, imageAnchor, shadowPath, shadowDimensions, windowAnchor) {
464
+ var icon = new GIcon();
465
+ icon.image = imagePath;
466
+ if (shadowPath!=undefined) { icon.shadow = shadowPath;}
467
+ icon.iconSize = imageDimensions!=undefined ? new GSize(imageDimensions[0], imageDimensions[1]) : new GSize(10,10);
468
+ icon.shadowSize = shadowDimensions!=undefined ? new GSize(shadowDimensions[0], shadowDimensions[1]) : new GSize(0,0);
469
+ icon.iconAnchor = imageAnchor!=undefined ? new GPoint(imageAnchor[0], imageAnchor[1]) : new GPoint(10,5);
470
+ icon.infoWindowAnchor = windowAnchor!=undefined ? new GPoint(windowAnchor[0], windowAnchor[1]) : new GPoint(10,5);
471
+ return icon
472
+ }
473
+ atlas_unload = function() { GUnload(); }
474
+ function addEvent(obj, evType, fn){
475
+ if (obj.addEventListener){
476
+ obj.addEventListener(evType, fn, false);
477
+ return true;
478
+ } else if (obj.attachEvent){
479
+ var r = obj.attachEvent("on"+evType, fn);
480
+ return r;
481
+ } else {
482
+ return false;
483
+ }
484
+ }
485
+ addEvent(window, \'load\',atlas_map_load);
486
+ addEvent(window, \'unload\',atlas_unload);
487
+ //]]>
488
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
489
+ end
490
+
491
+ def test_google_add_two_markers_with_custom_icon
492
+ get :google_add_two_markers_with_custom_icon
493
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
494
+ //<![CDATA[
495
+ atlas_map_load = function() {
496
+ if (GBrowserIsCompatible()) {
497
+ var map = new GMap2(document.getElementById("map"));
498
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
499
+ map_icon = atlas_create_icon(\'images/map_icon.png\',[20,30],[1,2],\'images/map_icon_shadow.png\',[40,50],[3,4])
500
+ map.addOverlay(new GMarker(new GLatLng(30,20),map_icon))
501
+ map.addOverlay(new GMarker(new GLatLng(40,50),map_icon))
502
+ }
503
+ }
504
+
505
+ function atlas_create_icon(imagePath, imageDimensions, imageAnchor, shadowPath, shadowDimensions, windowAnchor) {
506
+ var icon = new GIcon();
507
+ icon.image = imagePath;
508
+ if (shadowPath!=undefined) { icon.shadow = shadowPath;}
509
+ icon.iconSize = imageDimensions!=undefined ? new GSize(imageDimensions[0], imageDimensions[1]) : new GSize(10,10);
510
+ icon.shadowSize = shadowDimensions!=undefined ? new GSize(shadowDimensions[0], shadowDimensions[1]) : new GSize(0,0);
511
+ icon.iconAnchor = imageAnchor!=undefined ? new GPoint(imageAnchor[0], imageAnchor[1]) : new GPoint(10,5);
512
+ icon.infoWindowAnchor = windowAnchor!=undefined ? new GPoint(windowAnchor[0], windowAnchor[1]) : new GPoint(10,5);
513
+ return icon
514
+ }
515
+ atlas_unload = function() { GUnload(); }
516
+ function addEvent(obj, evType, fn){
517
+ if (obj.addEventListener){
518
+ obj.addEventListener(evType, fn, false);
519
+ return true;
520
+ } else if (obj.attachEvent){
521
+ var r = obj.attachEvent("on"+evType, fn);
522
+ return r;
523
+ } else {
524
+ return false;
525
+ }
526
+ }
527
+ addEvent(window, \'load\',atlas_map_load);
528
+ addEvent(window, \'unload\',atlas_unload);
529
+ //]]>
530
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
531
+ end
532
+
533
+ def test_google_add_two_tabbed_windows_with_custom_icons
534
+ get :google_add_two_tabbed_windows_with_custom_icons
535
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
536
+ //<![CDATA[
537
+ atlas_map_load = function() {
538
+ if (GBrowserIsCompatible()) {
539
+ var map = new GMap2(document.getElementById("map"));
540
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
541
+ map_icon = atlas_create_icon(\'images/map_icon.png\',[20,30],[1,2],\'images/map_icon_shadow.png\',[40,50],[3,4])
542
+ map_icon2 = atlas_create_icon(\'images/map_icon2.png\',[30,40],[2,3],undefined,undefined,[4,5])
543
+ atlas_tabs = [new GInfoWindowTab("Hello World!!","Hello world content"), new GInfoWindowTab("Goodbye","and goodnight")]
544
+ atlas_marker = atlas_create_tabwindowed_marker(30,20,atlas_tabs,map_icon)
545
+ map.addOverlay(atlas_marker)
546
+ atlas_tabs = [new GInfoWindowTab("What\'s happening?","This is just a test!"), new GInfoWindowTab("Did it work?","Definitely!")]
547
+ atlas_marker = atlas_create_tabwindowed_marker(60,70,atlas_tabs,map_icon2)
548
+ map.addOverlay(atlas_marker)
549
+ }
550
+ }
551
+
552
+ function atlas_create_icon(imagePath, imageDimensions, imageAnchor, shadowPath, shadowDimensions, windowAnchor) {
553
+ var icon = new GIcon();
554
+ icon.image = imagePath;
555
+ if (shadowPath!=undefined) { icon.shadow = shadowPath;}
556
+ icon.iconSize = imageDimensions!=undefined ? new GSize(imageDimensions[0], imageDimensions[1]) : new GSize(10,10);
557
+ icon.shadowSize = shadowDimensions!=undefined ? new GSize(shadowDimensions[0], shadowDimensions[1]) : new GSize(0,0);
558
+ icon.iconAnchor = imageAnchor!=undefined ? new GPoint(imageAnchor[0], imageAnchor[1]) : new GPoint(10,5);
559
+ icon.infoWindowAnchor = windowAnchor!=undefined ? new GPoint(windowAnchor[0], windowAnchor[1]) : new GPoint(10,5);
560
+ return icon
561
+ }
562
+
563
+ function atlas_create_tabwindowed_marker(atLat, atLng, atTabs, atIcon) {
564
+ var marker = new GMarker(new GLatLng(atLat, atLng), atIcon);
565
+ GEvent.addListener(marker, "click", function() { marker.openInfoWindowTabsHtml(atTabs); });
566
+ return marker
567
+ }
568
+ atlas_unload = function() { GUnload(); }
569
+ function addEvent(obj, evType, fn){
570
+ if (obj.addEventListener){
571
+ obj.addEventListener(evType, fn, false);
572
+ return true;
573
+ } else if (obj.attachEvent){
574
+ var r = obj.attachEvent("on"+evType, fn);
575
+ return r;
576
+ } else {
577
+ return false;
578
+ }
579
+ }
580
+ addEvent(window, \'load\',atlas_map_load);
581
+ addEvent(window, \'unload\',atlas_unload);
582
+ //]]>
583
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
584
+ end
585
+
586
+ def test_google_polyline
587
+ get :google_polyline
588
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
589
+ //<![CDATA[
590
+ atlas_map_load = function() {
591
+ if (GBrowserIsCompatible()) {
592
+ var map = new GMap2(document.getElementById("map"));
593
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
594
+ var polyline = new GPolyline([
595
+ new GLatLng(37.4419, -122.1419),
596
+ new GLatLng(37.4519, -122.1519),
597
+ new GLatLng(37.4619, -122.1819)
598
+ ], "#FF0000", 10);
599
+ map.addOverlay(polyline);
600
+ }
601
+ }
602
+ atlas_unload = function() { GUnload(); }
603
+ function addEvent(obj, evType, fn){
604
+ if (obj.addEventListener){
605
+ obj.addEventListener(evType, fn, false);
606
+ return true;
607
+ } else if (obj.attachEvent){
608
+ var r = obj.attachEvent("on"+evType, fn);
609
+ return r;
610
+ } else {
611
+ return false;
612
+ }
613
+ }
614
+ addEvent(window, \'load\',atlas_map_load);
615
+ addEvent(window, \'unload\',atlas_unload);
616
+ //]]>
617
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
618
+ end
619
+
620
+ def test_google_display_small_controls
621
+ get :google_display_small_controls
622
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
623
+ //<![CDATA[
624
+ atlas_map_load = function() {
625
+ if (GBrowserIsCompatible()) {
626
+ var map = new GMap2(document.getElementById("map"));
627
+ map.addControl(new GSmallMapControl());
628
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
629
+ }
630
+ }
631
+ atlas_unload = function() { GUnload(); }
632
+ function addEvent(obj, evType, fn){
633
+ if (obj.addEventListener){
634
+ obj.addEventListener(evType, fn, false);
635
+ return true;
636
+ } else if (obj.attachEvent){
637
+ var r = obj.attachEvent("on"+evType, fn);
638
+ return r;
639
+ } else {
640
+ return false;
641
+ }
642
+ }
643
+ addEvent(window, \'load\',atlas_map_load);
644
+ addEvent(window, \'unload\',atlas_unload);
645
+ //]]>
646
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
647
+ end
648
+
649
+ def test_google_display_large_controls
650
+ get :google_display_large_controls
651
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
652
+ //<![CDATA[
653
+ atlas_map_load = function() {
654
+ if (GBrowserIsCompatible()) {
655
+ var map = new GMap2(document.getElementById("map"));
656
+ map.addControl(new GLargeMapControl());
657
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
658
+ }
659
+ }
660
+ atlas_unload = function() { GUnload(); }
661
+ function addEvent(obj, evType, fn){
662
+ if (obj.addEventListener){
663
+ obj.addEventListener(evType, fn, false);
664
+ return true;
665
+ } else if (obj.attachEvent){
666
+ var r = obj.attachEvent("on"+evType, fn);
667
+ return r;
668
+ } else {
669
+ return false;
670
+ }
671
+ }
672
+ addEvent(window, \'load\',atlas_map_load);
673
+ addEvent(window, \'unload\',atlas_unload);
674
+ //]]>
675
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
676
+ end
677
+
678
+ def test_google_display_small_zoom
679
+ get :google_display_small_zoom
680
+ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
681
+ //<![CDATA[
682
+ atlas_map_load = function() {
683
+ if (GBrowserIsCompatible()) {
684
+ var map = new GMap2(document.getElementById("map"));
685
+ map.addControl(new GSmallZoomControl());
686
+ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
687
+ }
688
+ }
689
+ atlas_unload = function() { GUnload(); }
690
+ function addEvent(obj, evType, fn){
691
+ if (obj.addEventListener){
692
+ obj.addEventListener(evType, fn, false);
693
+ return true;
694
+ } else if (obj.attachEvent){
695
+ var r = obj.attachEvent("on"+evType, fn);
696
+ return r;
697
+ } else {
698
+ return false;
699
+ }
700
+ }
701
+ addEvent(window, \'load\',atlas_map_load);
702
+ addEvent(window, \'unload\',atlas_unload);
703
+ //]]>
704
+ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
705
+ end
706
+
707
+ #~ def test_google_add_tabbed_window_with_custom_icon_and_partial
708
+ #~ get :google_add_tabbed_window_with_custom_icon_and_partial
709
+ #~ assert_equal('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ" type="text/javascript"></script><script type="text/javascript">
710
+ #~ //<![CDATA[
711
+ #~ atlas_map_load = function() {
712
+ #~ if (GBrowserIsCompatible()) {
713
+ #~ var map = new GMap2(document.getElementById("map"));
714
+ #~ map.setCenter(new GLatLng(37.4419, -122.1419), 13);
715
+ #~ map_icon = atlas_create_icon(\'images/map_icon.png\',[20,30],[1,2],\'images/map_icon_shadow.png\',[40,50],[3,4])
716
+ #~ map_icon2 = atlas_create_icon(\'images/map_icon2.png\',[30,40],[2,3],undefined,undefined,[4,5])
717
+ #~ atlas_tabs = [new GInfoWindowTab("Hello World!!","Hello world content"), new GInfoWindowTab("Goodbye","and goodnight")]
718
+ #~ atlas_marker = atlas_create_tabwindowed_marker(30,20,atlas_tabs,map_icon)
719
+ #~ map.addOverlay(atlas_marker)
720
+ #~ }
721
+ #~ }
722
+
723
+ #~ function atlas_create_icon(imagePath, imageDimensions, imageAnchor, shadowPath, shadowDimensions, windowAnchor) {
724
+ #~ var icon = new GIcon();
725
+ #~ icon.image = imagePath;
726
+ #~ if (shadowPath!=undefined) { icon.shadow = shadowPath;}
727
+ #~ icon.iconSize = imageDimensions!=undefined ? new GSize(imageDimensions[0], imageDimensions[1]) : new GSize(10,10);
728
+ #~ icon.shadowSize = shadowDimensions!=undefined ? new GSize(shadowDimensions[0], shadowDimensions[1]) : new GSize(0,0);
729
+ #~ icon.iconAnchor = imageAnchor!=undefined ? new GPoint(imageAnchor[0], imageAnchor[1]) : new GPoint(10,5);
730
+ #~ icon.infoWindowAnchor = windowAnchor!=undefined ? new GPoint(windowAnchor[0], windowAnchor[1]) : new GPoint(10,5);
731
+ #~ return icon
732
+ #~ }
733
+
734
+ #~ function atlas_create_tabwindowed_marker(atLat, atLng, atTabs, atIcon) {
735
+ #~ var marker = new GMarker(new GLatLng(atLat, atLng), atIcon);
736
+ #~ GEvent.addListener(marker, "click", function() { marker.openInfoWindowTabsHtml(atTabs); });
737
+ #~ return marker
738
+ #~ }
739
+ #~ atlas_unload = function() { GUnload(); }
740
+ #~ function addEvent(obj, evType, fn){
741
+ #~ if (obj.addEventListener){
742
+ #~ obj.addEventListener(evType, fn, false);
743
+ #~ return true;
744
+ #~ } else if (obj.attachEvent){
745
+ #~ var r = obj.attachEvent("on"+evType, fn);
746
+ #~ return r;
747
+ #~ } else {
748
+ #~ return false;
749
+ #~ }
750
+ #~ }
751
+ #~ addEvent(window, \'load\',atlas_map_load);
752
+ #~ addEvent(window, \'unload\',atlas_unload);
753
+ #~ //]]>
754
+ #~ </script><div id="map" style="width: 500px; height: 300px"></div>', @response.body)
755
+ #~ end
756
+
757
+ end