3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
5 var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
6 var isMSIE = (navigator.userAgent.indexOf("MSIE") > -1);
9 var georss_txt = "./georss.txt";
10 var atom_xml = "./atom-1.0.xml";
12 // if this test is running online, different rules apply
14 georss_txt = "." + georss_txt;
15 atom_xml = "." + atom_xml;
18 function test_Layer_GeoRSS_constructor (t) {
20 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt );
21 t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
22 t.eq( layer.location, georss_txt, "layer.location is correct" );
25 t.delay_call( 1, function() {
26 t.eq( layer.markers.length, 40, "marker length is correct" );
27 var ll = new OpenLayers.LonLat(-71.142197, 42.405696);
28 var theTitle = "Knitting Room";
29 var theDescription = 'This little shop is jammed full. Yarn, yarn everywhere. They make the most of every possible nook and cranny. I like this place also because they have a lot of different kinds of knitting needles in all different sizes. Also, the people who work here are younger and hipper than in the other stores I go to. I reccomend buying supplies here and then knitting your way through a good documentary at the Capitol Theater across the street.<br/>Address: 2 lake St, Arlington, MA <br/>Tags: knitting, yarn, pins and needles, handspun, hand dyed, novelty yarn, fancy, simple, young, hip, friendly, needles, addy, cute hats<br /><br /><a href="http://platial.com/place/90306">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/90306">Grab this on Platial</a> ';
30 t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" );
31 t.eq( layer.name, "Crschmidt's Places At Platial", "Layer name is correct." );
32 t.eq( layer.features[0].data.title, theTitle);
33 t.eq( layer.features[0].data.description, theDescription);
37 function test_Layer_GeoRSS_dontUseFeedTitle (t) {
39 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt, {'useFeedTitle': false} );
40 t.delay_call( 1, function() {
41 t.eq( layer.name, "Test Layer", "Layer name is correct when not used from feed." );
45 function test_Layer_GeoRSS_AtomParsing (t) {
47 layer = new OpenLayers.Layer.GeoRSS('Test Layer', atom_xml );
48 t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
49 t.eq( layer.location, atom_xml, "layer.location is correct" );
52 t.delay_call( 1, function() {
53 t.eq( layer.markers.length, 2, "marker length is correct" );
54 var ll = new OpenLayers.LonLat(29.9805, 36.7702);
55 t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" );
56 t.like( layer.features[0].data['popupContentHTML'], '<a class="link" href="http://pleiades.stoa.org/places/638896" target="_blank">Unnamed Tumulus</a>', "Link is correct.");
57 t.eq( layer.name, "tumulus", "Layer name is correct." );
61 function test_Layer_GeoRSS_draw (t) {
64 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
65 t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
66 var map = new OpenLayers.Map('map');
67 var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
68 "http://octo.metacarta.com/cgi-bin/mapserv?",
69 {map: "/mapdata/vmap_wms.map", layers: "basic"});
70 map.addLayer(baseLayer);
72 t.delay_call( 1, function() {
73 map.setCenter(new OpenLayers.LonLat(0,0),0);
74 t.eq( map.layers[1].name, layer.name, "Layer name is correct" );
78 function test_Layer_GeoRSS_load_events (t) {
80 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
81 var map = new OpenLayers.Map('map');
82 var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
83 "http://octo.metacarta.com/cgi-bin/mapserv?",
84 {map: "/mapdata/vmap_wms.map", layers: "basic"});
85 map.addLayer(baseLayer);
87 layer.events.register("loadstart", t, function() { this.ok(true, "loadstart event triggered once (#1580)") });
88 map.setCenter(new OpenLayers.LonLat(0,0),0);
90 function test_Layer_GeoRSS_events (t) {
92 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
93 var map = new OpenLayers.Map('map');
94 var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
95 "http://octo.metacarta.com/cgi-bin/mapserv?",
96 {map: "/mapdata/vmap_wms.map", layers: "basic"});
97 map.addLayer(baseLayer);
99 map.setCenter(new OpenLayers.LonLat(0,0),0);
101 t.delay_call( 2, function() {
102 t.ok(layer.markers[0].events, "First marker has an events object");
103 t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object");
104 layer.markers[0].events.triggerEvent('click', event);
105 t.eq(map.popups.length, 1, "Popup opened correctly");
106 layer.markers[1].events.triggerEvent('click', event);
107 t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
110 function test_Layer_GeoRSS_popups (t) {
112 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
113 var map = new OpenLayers.Map('map');
114 var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
115 "http://octo.metacarta.com/cgi-bin/mapserv?",
116 {map: "/mapdata/vmap_wms.map", layers: "basic"});
117 map.addLayer(baseLayer);
119 map.setCenter(new OpenLayers.LonLat(0,0),0);
121 t.delay_call( 1, function() {
122 t.ok(layer.markers[0].events, "First marker has an events object");
123 t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object");
124 layer.markers[0].events.triggerEvent('click', event);
125 t.eq(map.popups.length, 1, "Popup opened correctly");
126 layer.markers[1].events.triggerEvent('click', event);
127 t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
131 function test_Layer_GeoRSS_resizedPopups(t) {
132 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt, {'popupSize': new OpenLayers.Size(200,100)});
134 var map = new OpenLayers.Map('map');
135 var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
136 "http://octo.metacarta.com/cgi-bin/mapserv?",
137 {map: "/mapdata/vmap_wms.map", layers: "basic"});
138 map.addLayer(baseLayer);
140 map.setCenter(new OpenLayers.LonLat(0,0),0);
142 t.delay_call( 1, function() {
143 t.ok(layer.markers[0].events, "First marker has an events object");
144 t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object");
145 layer.markers[0].events.triggerEvent('click', event);
146 t.eq(map.popups.length, 1, "Popup opened correctly");
147 map.popups[0].size.w=300;
148 layer.markers[1].events.triggerEvent('click', event);
149 t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
153 function test_Layer_GeoRSS_icon(t) {
155 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
156 var the_icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png');
157 var otherLayer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt,{icon:the_icon});
158 var map = new OpenLayers.Map('map');
159 var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
160 "http://octo.metacarta.com/cgi-bin/mapserv?",
161 {map: "/mapdata/vmap_wms.map", layers: "basic"});
162 map.addLayer(baseLayer);
163 map.addLayers([layer,otherLayer]);
164 map.setCenter(new OpenLayers.LonLat(0,0),0);
165 var defaultIcon = OpenLayers.Marker.defaultIcon();
167 otherLayer.loadRSS();
168 t.delay_call( 2, function() {
169 t.ok(layer.markers[0].icon, "The layer has a icon");
170 t.eq(layer.markers[0].icon.url, defaultIcon.url, "The layer without icon has the default icon.");
171 t.eq(otherLayer.markers[0].icon.url, the_icon.url,"The layer with an icon has that icon.");
174 function test_Layer_GeoRSS_loadend_Event(t) {
175 var browserCode = OpenLayers.Util.getBrowserName();
176 if (browserCode == "msie") {
178 t.ok(true, "IE fails the GeoRSS test. This could probably be fixed by someone with enough energy to fix it.");
181 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
182 t.delay_call(2, function() {
183 layer.events.register('loadend', layer, function() {
184 t.ok(true, "Loadend event fired");
187 'responseText': '<xml xmlns="http://example.com"><title> </title></xml>'
189 t.ok(true, "Parsing data didn't fail");
194 function test_Layer_GeoRSS_destroy (t) {
196 layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
197 var map = new OpenLayers.Map('map');
199 t.delay_call( 1, function() {
201 t.eq( layer.map, null, "layer.map is null after destroy" );
208 <div id="map" style="width:500px; height:500px"></div>