[OpenLayers-Commits] r5110 - in sandbox/ahocevar/sldRenderer: examples lib/OpenLayers lib/OpenLayers/Layer
commits at openlayers.org
commits at openlayers.org
Sat Nov 3 18:33:10 EDT 2007
Author: ahocevar
Date: 2007-11-03 18:33:08 -0400 (Sat, 03 Nov 2007)
New Revision: 5110
Added:
sandbox/ahocevar/sldRenderer/examples/georss-category.xml
Modified:
sandbox/ahocevar/sldRenderer/examples/georss.html
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Feature.js
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Layer/GeoRSS.js
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Marker.js
Log:
made markers styleable and modified GeoRSS layer to use this functionality. This is a solution for the feature requested in #1073.
Added: sandbox/ahocevar/sldRenderer/examples/georss-category.xml
===================================================================
--- sandbox/ahocevar/sldRenderer/examples/georss-category.xml (rev 0)
+++ sandbox/ahocevar/sldRenderer/examples/georss-category.xml 2007-11-03 22:33:08 UTC (rev 5110)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/css" href="/css/rss.css" ?>
+
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns="http://purl.org/rss/1.0/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:georss="http://www.georss.org/georss">
+<docs>This is an RSS file. Copy the URL into your aggregator of choice. If you don't know what this means and want to learn more, please see: <span>http://platial.typepad.com/news/2006/04/really_simple_t.html</span> for more info.</docs><channel rdf:about="http://platial.com">
+<link>http://platial.com</link>
+<title>Crschmidt's Places At Platial</title>
+<description></description>
+</channel>
+<item rdf:about="http://platial.com/place/67230">
+<link>http://platial.com/place/67230</link>
+<title>Knitting Room</title>
+<description><![CDATA[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/67230">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/67230">Grab this on Platial</a> ]]></description>
+<category>sight</category>
+<georss:point>42.405524 -71.142273</georss:point>
+<dc:creator>crschmidt</dc:creator>
+<dc:date>2006-04-24T11:35:26.733857+00:00</dc:date>
+</item>
+<item rdf:about="http://platial.com/place/62200">
+<link>http://platial.com/place/62200</link>
+<title>Allen Hall</title>
+<description><![CDATA[My dorm at UIUC.<br/>Address: 1301 W Gregory Dr, Urbana, IL<br/>Tags: dorm, uiuc, college<br/><a href="http://platial.com/place/62200"><img src="http://platial.comhttp://static.flickr.com/4/8576450_0d59cc2531_s.jpg"/></a><br/><br /><br /><a href="http://platial.com/place/62200">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/62200">Grab this on Platial</a> ]]></description>
+<georss:point>40.104172 -88.220623</georss:point>
+<dc:creator>crschmidt</dc:creator>
+<dc:date>2006-04-14T08:01:01.872873+00:00</dc:date>
+</item>
+<item rdf:about="http://platial.com/place/28232">
+<link>http://platial.com/place/28232</link>
+<title>Bagby Hot Springs, OR</title>
+<description><![CDATA[Hot spring, temperature: 136 degress F, 58 degress C. However, the area around the springs are not exactly well looked upon by people who know the place.
+
+<br/>Tags: 20s, rosalie, romance, childhood, hike, camping, soak, relax, beautiful, hot springs, bathhouse, favorite, popular, crowded, organized, honeymoon tub, plumbing made from hollowed out trees, hot springs, mt hood, notorious car break in spot, rash, bacteria<br /><br /><a href="http://platial.com/place/28232">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/28232">Grab this on Platial</a> ]]></description>
+<category>recreation</category>
+<georss:point>44.936000 -122.173000</georss:point>
+<dc:creator>crschmidt</dc:creator>
+<dc:date>2006-01-03T23:10:18.553063+00:00</dc:date>
+</item>
+<item rdf:about="http://platial.com/place/43666">
+<link>http://platial.com/place/43666</link>
+<title>Shooting Location for "The Field of Dreams" Film</title>
+<description><![CDATA[1989's Field of Dreams was a Best Picture Academy Award nominee, and the baseball field in the cornfield still stands today, and has become quite a tourist destination. Games are occasionally played at the field, re-enacting professional baseball at the turn of the 20th Century.<br/>Address: Dyersville, Iowa<br/>Tags: iowa, baseball, movie locations, field of dreams, kevin costner, costner, dyersville, kinsella, james earl jones, chicago black sox, shoeless joe, joe jackson, famous farms, film, movie, cinema, shooting location<br /><br /><a href="http://platial.com/place/43666">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/43666">Grab this on Platial</a> ]]></description>
+<category>sight</category>
+<georss:point>42.481213 -91.111679</georss:point>
+<dc:creator>echinodermata</dc:creator>
+<dc:date>2006-03-23T11:40:17.654061+00:00</dc:date>
+</item>
+<item rdf:about="http://platial.com/place/28394">
+<link>http://platial.com/place/28394</link>
+<title>Moffetts (Bonneville) Hot Springs, WA</title>
+<description><![CDATA[Hot spring, temperature: 97 degress F, 36 degress C<br/>Tags: soak, hot springs, relax, nature<br /><br /><a href="http://platial.com/place/28394">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/28394">Grab this on Platial</a> ]]></description>
+<category>recreation</category>
+<georss:point>45.658000 -121.962000</georss:point>
+<dc:creator>crschmidt</dc:creator>
+<dc:date>2006-01-03T23:16:27.329816+00:00</dc:date>
+</item>
+<item rdf:about="http://platial.com/place/28251">
+<link>http://platial.com/place/28251</link>
+<title>Austin Hot Springs, OR</title>
+<description><![CDATA[Hot spring, temperature: 186 degress F, 86 degress C<br/>Tags: soak, hot springs, relax, nature, popular, crowded<br /><br /><a href="http://platial.com/place/28251">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/28251">Grab this on Platial</a> ]]></description>
+<category>recreation</category>
+<georss:point>45.021000 -122.009000</georss:point>
+<dc:creator>crschmidt</dc:creator>
+<dc:date>2006-01-03T23:11:04.489886+00:00</dc:date>
+</item>
+</rdf:RDF>
\ No newline at end of file
Property changes on: sandbox/ahocevar/sldRenderer/examples/georss-category.xml
___________________________________________________________________
Name: svn:keywords
+ Id Author Date Revision
Name: svn:eol-style
+ native
Modified: sandbox/ahocevar/sldRenderer/examples/georss.html
===================================================================
--- sandbox/ahocevar/sldRenderer/examples/georss.html 2007-11-03 22:04:09 UTC (rev 5109)
+++ sandbox/ahocevar/sldRenderer/examples/georss.html 2007-11-03 22:33:08 UTC (rev 5110)
@@ -11,6 +11,17 @@
<script type="text/javascript">
var map, layer;
+ var style = new OpenLayers.Style();
+ var rule = new OpenLayers.Rule.Comparison({
+ type: OpenLayers.Rule.Comparison.Type.EQUAL_TO,
+ property: 'category'});
+ style.rules.push(OpenLayers.Util.extend(OpenLayers.Util.extend({}, rule), {
+ value: 'sight',
+ symbolizer: {'Point': {externalGraphic: '../img/marker-blue.png'}}}));
+ style.rules.push(OpenLayers.Util.extend(OpenLayers.Util.extend({}, rule), {
+ value: 'recreation',
+ symbolizer: {'Point': {externalGraphic: '../img/marker-green.png'}}}));
+
OpenLayers.ProxyHost = "/proxy/?url=";
function init(){
map = new OpenLayers.Map('map', {maxResolution:'auto'});
@@ -24,7 +35,7 @@
var urlObj = OpenLayers.Util.getElement('url');
var value = urlObj.value;
var parts = value.split("/");
- var newl = new OpenLayers.Layer.GeoRSS( parts[parts.length-1], value);
+ var newl = new OpenLayers.Layer.GeoRSS( parts[parts.length-1], value, {style: style});
map.addLayer(newl);
urlObj.value = "";
}
@@ -37,6 +48,7 @@
GeoRSS URL: <input type="text" id="url" size="50" /><input type="submit" onclick="addUrl(); return false;" value="Load Feed" onsubmit="addUrl(); return false;" />
</form>
<p>The above input box allows the input of a URL to a GeoRSS feed. This feed can be local to the HTML page -- for example, entering 'georss.xml' will work by default, because there is a local file in the directory called georss.xml -- or, with a properly set up ProxyHost variable (as is used here), it will be able to load any HTTP URL which contains GeoRSS and display it. Anything else will simply have no effect.</p>
+ <p>Entering 'georss-category.xml' in the above input box will load a feed with a 'category' property for some items. The example is configured with style objects to render the items with different icons, depending on the category.</p>
<div id="map"></div>
</body>
</html>
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Feature.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Feature.js 2007-11-03 22:04:09 UTC (rev 5109)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Feature.js 2007-11-03 22:33:08 UTC (rev 5110)
@@ -137,6 +137,7 @@
if (this.lonlat != null) {
this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);
+ this.marker.feature = this;
}
return this.marker;
},
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Layer/GeoRSS.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Layer/GeoRSS.js 2007-11-03 22:04:09 UTC (rev 5109)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Layer/GeoRSS.js 2007-11-03 22:33:08 UTC (rev 5110)
@@ -40,6 +40,13 @@
* for this GeoRSS layer.
*/
icon: null,
+
+ /**
+ * APIProperty: style
+ * {OpenLayers.Style}. If more complex styling than just a global icon for
+ * the whole layer is needed, a style can be used.
+ */
+ style: null,
/**
* APIProperty: popupSize
@@ -186,6 +193,11 @@
}
catch (e) {}
}
+
+ try {
+ data.category = OpenLayers.Util.getNodes(itemlist[i], "category")[0].firstChild.nodeValue;
+ }
+ catch (e) {}
data.icon = this.icon == null ?
OpenLayers.Marker.defaultIcon() :
@@ -211,6 +223,11 @@
var feature = new OpenLayers.Feature(this, location, data);
this.features.push(feature);
var marker = feature.createMarker();
+
+ if (this.style) {
+ marker.style = this.style;
+ }
+
marker.events.register('click', feature, this.markerClick);
this.addMarker(marker);
}
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Marker.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Marker.js 2007-11-03 22:04:09 UTC (rev 5109)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Marker.js 2007-11-03 22:33:08 UTC (rev 5110)
@@ -58,6 +58,18 @@
*/
map: null,
+ /**
+ * Property: feature
+ * {<OpenLayers.Feature>} the feature this marker was derived from, if any
+ */
+ feature: null,
+
+ /**
+ * Property: style
+ * {<OpenLayers.Style>} the style for this marker, if any
+ */
+ style: null,
+
/**
* Constructor: OpenLayers.Marker
* Paraemeters:
@@ -96,6 +108,10 @@
this.icon.destroy();
this.icon = null;
}
+
+ this.feature = null;
+
+ this.style = null;
},
/**
@@ -110,6 +126,12 @@
* location passed-in
*/
draw: function(px) {
+ if (this.style) {
+ var style = this.style.createStyle(this.feature);
+ if (style.externalGraphic) {
+ this.icon.url = style.externalGraphic;
+ }
+ }
return this.icon.draw(px);
},
More information about the Commits
mailing list