From da81af8d23f289dfa50b980b2da18c53894d7799 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 30 May 2007 14:13:32 +0000 Subject: [PATCH] Add patch from penyaskito for #705, along with tests, a new example, and a new example georss file (grabbed from the new mapufacture, which is pretty). Thanks, penyaskito! git-svn-id: http://svn.openlayers.org/trunk/openlayers@3208 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- examples/georss-markers.html | 36 ++++++++ examples/yelp-georss.xml | 147 +++++++++++++++++++++++++++++++++ lib/OpenLayers/Layer/GeoRSS.js | 11 ++- tests/Layer/test_GeoRSS.html | 20 +++++ 4 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 examples/georss-markers.html create mode 100644 examples/yelp-georss.xml diff --git a/examples/georss-markers.html b/examples/georss-markers.html new file mode 100644 index 0000000000..cfdd83b671 --- /dev/null +++ b/examples/georss-markers.html @@ -0,0 +1,36 @@ + + + + + + + +

GeoRSS in OpenLayers

+
+ + diff --git a/examples/yelp-georss.xml b/examples/yelp-georss.xml new file mode 100644 index 0000000000..7ecb1cf4ef --- /dev/null +++ b/examples/yelp-georss.xml @@ -0,0 +1,147 @@ + + + + Copyright 2007 Yelp, Inc. All rights reserved. + Yelp - Recent Reviews Near Ann Arbor, MI + + 2007-05-29T22:58:24-08:00 + + Recent Reviews Near Ann Arbor, MI + + + + Sam S.'s Review Of State Theatre - Ann Arbor (4/5) + + http://www.yelp.com/biz/r-dZCCNtld2ik0QRoTwuUQ?hrid=pve0e49KrVsvgX_wXpZHYA + 2007-05-29T22:58:24-08:00 + I gotta give this place props for hosting independent movies. Man, I really tire of that Hollywood bullshit; I actually feel retarded afterwards.<br /><br />My main gripe is that the seats are not ergonomic at&#8230; + -83.7406005859 + 42.2790985107 + + + Sean M.'s Review Of Maize N Blue Deli - Ann Arbor (5/5) + + http://www.yelp.com/biz/GqqBWV8ysYB48_jLPMl2bA?hrid=ZZIVErEJIo-FMsxOBVX1GQ + 2007-05-29T16:04:19-08:00 + Maize N Blue is synonymous with huge sandwiches (lunch+dinner sized) and good but not showy ingredients. It's a much better value than certain other Ann Arbor delis, and eschews the boutique feel that&#8230; + -83.7255020142 + 42.266998291 + + + Coco C.'s Review Of Tom Thompson Flowers - Ann Arbor (5/5) + + http://www.yelp.com/biz/B_lu4c0HgyHlxOjdKxTW7w?hrid=KNa-bOGA0xltz6bHEu3-AQ + 2007-05-29T10:49:06-08:00 + This place isn't much to look at - you go in and there are buckets upon buckets of loose flowers laying around, and there isn't much room to walk around. However, they make kick-ass arrangements! And&#8230; + -83.7490005493 + 42.2747993469 + + + Sam S.'s Review Of Mitch's Place - Ann Arbor (3/5) + + http://www.yelp.com/biz/zlJ37GVxuy-9wfvWqpPm1Q?hrid=qK6d7BOgLoK3gLf2u2OXAQ + 2007-05-28T21:28:33-08:00 + Another generic sports bar with the generic stripe-o crowd. Cheap pitchers, but constant covers.<br /><br />This is where I met Dave, a.k.a. Future Guy. He's skinny, has tall, straggly hair, and wears these&#8230; + -83.7329025269 + 42.275100708 + + + Jane S.'s Review Of Special Moments Photography - Plymouth (1/5) + + http://www.yelp.com/biz/IEsTnmfhN7vFfzt724qojw?hrid=ZvALNYOlSodoOciFsmeLZA + 2007-05-28T10:18:35-08:00 + I was very unsatisfied for several reasons. First, the photographer did not have the lighting for family portraits right at all! Two faces are almost completely obscured by shadows. Also, the backdrop&#8230; + -83.4609985352 + 42.3588981628 + + + Jacqueline D.'s Review Of Embassy Hotel - Ann Arbor (4/5) + + http://www.yelp.com/biz/Vz0hW6UhF6w4JuvgsqDmMQ?hrid=eMKcIyREDk-pFGdH0EC6jg + 2007-05-27T09:23:06-08:00 + The Embassy Hotel does what it does well: It is VERY cheap ($40-50/night) and located in the heart of downtown. It is relatively clean. What to expect: Your bed won't be made, your sheets won't be&#8230; + -83.7469024658 + 42.2812004089 + + + Tony C.'s Review Of Cafe Zola - Ann Arbor (5/5) + + http://www.yelp.com/biz/BlUEgCOGzDwpOWnkQn3odw?hrid=X3rR29JnKIqAjEzo9nC2VQ + 2007-05-26T07:48:01-08:00 + Zola...this is easily one of the best experiences to be had in Ann Arbor. I'll get the negatives for this place right out in the open. It's popular, really popular. It's expensive, but not break&#8230; + -83.7489013672 + 42.2806015015 + + + Tony C.'s Review Of Melange - Ann Arbor (4/5) + + http://www.yelp.com/biz/aPdz29vOWj4fBlLlCBM7UQ?hrid=ETs0aMnHTjSLy1VTsGxCBg + 2007-05-26T07:30:59-08:00 + Melange has an excellent menu. I've tried the scallops, the perch, and the seabass. All were excellent. The two dishes I'd steer clear of are the rock beef thing and the squid appetizers.<br /><br />The rock&#8230; + -83.7481918335 + 42.283493042 + + + Tony C.'s Review Of Bennett Optometry - Ann Arbor (4/5) + + http://www.yelp.com/biz/Oa5c1Zzr6RlkGjx-0KYr1A?hrid=vUiuwPLri6D5LTPrC76UlA + 2007-05-26T07:09:43-08:00 + I just got my eyes checked out here about two months ago and overall, I was satisfied with my experience. The optometrist I got was young, but very knowledgeable and didn't seem to be in a hurry to&#8230; + -83.6924972534 + 42.3031005859 + + + Nedra B.'s Review Of Star's Cafe - Ann Arbor (4/5) + + http://www.yelp.com/biz/aNeaXyQWZ0LGH3FoNnYzmA?hrid=XUd-5ehybDuujOTinekhWA + 2007-05-26T02:53:51-08:00 + As you walk in, you hear arabic music playing the background, and about 4 or 5 tables in front of the main window. You walk up to the menu, choose from many middle eastern foods, give your order, and&#8230; + -83.782539 + 42.281079 + + + Nedra B.'s Review Of Vinology - Ann Arbor (3/5) + + http://www.yelp.com/biz/qkw4xWWgTufvBs1NcxsFnw?hrid=lFMHzQ0GwJ93Ns0kCoPWPQ + 2007-05-26T02:45:15-08:00 + I knew to expect a pricey "high class" restaurant... but in my opinion they went over the top. I went with my sister and some friends, and she ordered the little "mini burgers" and I ordered the only&#8230; + -83.7487030029 + 42.2812004089 + + + Coco C.'s Review Of Eastern Accents - Ann Arbor (4/5) + + http://www.yelp.com/biz/AztY39QdGAkoKrLy9Di2yw?hrid=HL2_XnWdZP1FO95e1q-Xjw + 2007-05-25T15:43:30-08:00 + Oooh baby, this is my dream food come to life - sweet buns with tasty meat inside of them. I'm already a big fan of WowBao in Chicago, so to find this place in Ann Arbor makes me living here a&#8230; + -83.7472991943 + 42.2803001404 + + + Liam C.'s Review Of The Dartmoor - Plymouth (1/5) + + http://www.yelp.com/biz/Q32V2uxVKKv8_fp-hGxyZQ?hrid=7zFDEW0THJGYTUPPHLZucQ + 2007-05-24T14:36:00-08:00 + Okay, so here is how fawked up it is in Plymouth.<br /><br />This place was a hotel, back in the day. Dude converts it to offices and retail, and leases the bar and restaurant out to someone else.<br /><br />the tenant gets&#8230; + -83.4705963135 + 42.3686981201 + + + Liam C.'s Review Of Omelette & Waffle Cafe - Plymouth (2/5) + + http://www.yelp.com/biz/a09i0TiPG4_yhl-fnzPzDA?hrid=I4ENTNhbAK8pLP_qJmivTQ + 2007-05-24T14:32:05-08:00 + Who does this guy pay off? Every year, he wins the Chii cook off but when you order the chili here in the restaurant, it's Hormel right out of a can!<br /><br />tired and uninspired boring diner egg dishes,&#8230; + -83.4709014893 + 42.3681983948 + + + Liam C.'s Review Of Zack's of Plymouth - Plymouth (2/5) + + http://www.yelp.com/biz/F0iuCrXUd_fEJ-LZh8wMFw?hrid=2VLIUcC_oI8b_aLTMjYx8w + 2007-05-24T14:30:12-08:00 + If you like greasy diners with vaguely ethnic workers yelling in orgy-borgy talk back int he kitchen... you're gonna love this place.<br /><br />It's cleaner than it's competitors....gotta give them props on&#8230; + -83.4692993164 + 42.3581008911 + + \ No newline at end of file diff --git a/lib/OpenLayers/Layer/GeoRSS.js b/lib/OpenLayers/Layer/GeoRSS.js index 082ccb1059..7ef9ac8f04 100644 --- a/lib/OpenLayers/Layer/GeoRSS.js +++ b/lib/OpenLayers/Layer/GeoRSS.js @@ -23,14 +23,17 @@ OpenLayers.Layer.GeoRSS.prototype = /** @type OpenLayers.Feature */ selectedFeature: null, + /**@type OpenLayers.Icon */ + icon: null, + /** * @constructor * * @param {String} name * @param {String} location */ - initialize: function(name, location) { - OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name]); + initialize: function(name, location, options) { + OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name, options]); this.location = location; this.features = new Array(); OpenLayers.loadURL(location, null, this, this.parseData); @@ -143,7 +146,9 @@ OpenLayers.Layer.GeoRSS.prototype = catch (e) {} } - data.icon = OpenLayers.Marker.defaultIcon(); + data.icon = this.icon == null ? + OpenLayers.Marker.defaultIcon() : + this.icon.clone(); data.popupSize = new OpenLayers.Size(250, 120); if ((title != null) && (description != null)) { contentHTML = '
[x]
'; diff --git a/tests/Layer/test_GeoRSS.html b/tests/Layer/test_GeoRSS.html index e5dae3179b..3b1747e1fe 100644 --- a/tests/Layer/test_GeoRSS.html +++ b/tests/Layer/test_GeoRSS.html @@ -82,6 +82,26 @@ }); } + function test_04_Layer_GeoRSS_icon(t) { + t.plan( 3 ); + layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt); + var the_icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png'); + var otherLayer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt,{icon:the_icon}); + var map = new OpenLayers.Map('map'); + var baseLayer = new OpenLayers.Layer.WMS("Test Layer", + "http://octo.metacarta.com/cgi-bin/mapserv?", + {map: "/mapdata/vmap_wms.map", layers: "basic"}); + map.addLayer(baseLayer); + map.addLayers([layer,otherLayer]); + map.setCenter(new OpenLayers.LonLat(0,0),0); + var defaultIcon = OpenLayers.Marker.defaultIcon(); + t.delay_call( 1, function() { + t.ok(layer.markers[0].icon, "The layer has a icon"); + t.eq(layer.markers[0].icon.url, defaultIcon.url, "The layer without icon has the default icon."); + t.eq(otherLayer.markers[0].icon.url, the_icon.url,"The layer with an icon has that icon."); + }); + } + function test_99_Layer_GeoRSS_destroy (t) { t.plan( 1 ); layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);