1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <title>OpenLayers Cluster Strategy Example</title>
4 <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
5 <link rel="stylesheet" href="style.css" type="text/css" />
6 <style type="text/css">
16 background-color: #fefefe;
64 <script src="../lib/OpenLayers.js"></script>
65 <script src="Jugl.js"></script>
66 <script src="animator.js"></script>
67 <script type="text/javascript">
69 var Jugl = window["http://jugl.tschaub.net/trunk/lib/Jugl.js"];
70 OpenLayers.ProxyHost = (window.location.host == "localhost") ?
71 "/cgi-bin/proxy.cgi?url=" : "proxy.cgi?url=";
74 map = new OpenLayers.Map('map', {
75 restrictedExtent: new OpenLayers.Bounds(-180, -90, 180, 90)
77 var base = new OpenLayers.Layer.WMS("Imagery",
78 ["http://t1.hypercube.telascience.org/tiles?",
79 "http://t2.hypercube.telascience.org/tiles?",
80 "http://t3.hypercube.telascience.org/tiles?",
81 "http://t4.hypercube.telascience.org/tiles?"],
85 var style = new OpenLayers.Style({
86 pointRadius: "${radius}",
89 strokeColor: "#cc6633",
94 radius: function(feature) {
95 return Math.min(feature.attributes.count, 7) + 3;
100 var photos = new OpenLayers.Layer.Vector("Photos", {
102 new OpenLayers.Strategy.Fixed(),
103 new OpenLayers.Strategy.Cluster()
105 protocol: new OpenLayers.Protocol.HTTP({
106 url: "http://labs.metacarta.com/flickrbrowse/flickr.py/flickr",
109 sort: "interestingness-desc",
111 request: "GetFeatures",
114 bbox: [-180, -90, 180, 90]
116 format: new OpenLayers.Format.GML()
118 styleMap: new OpenLayers.StyleMap({
121 fillColor: "#8aeeef",
122 strokeColor: "#32a8a9"
127 var select = new OpenLayers.Control.SelectFeature(
128 photos, {hover: true}
130 map.addControl(select);
132 photos.events.on({"featureselected": display});
134 map.addLayers([base, photos]);
135 map.setCenter(new OpenLayers.LonLat(0, 0), 1);
138 template = new Jugl.Template("template");
142 function display(event) {
143 // clear previous photo list and create new one
144 $("photos").innerHTML = "";
145 var node = template.process({
146 context: {features: event.feature.cluster},
150 // set up forward/rewind
151 var forward = Animator.apply($("list"), ["start", "end"], {duration: 1500});
152 $("scroll-end").onmouseover = function() {forward.seekTo(1)};
153 $("scroll-end").onmouseout = function() {forward.seekTo(forward.state)};
154 $("scroll-start").onmouseover = function() {forward.seekTo(0)};
155 $("scroll-start").onmouseout = function() {forward.seekTo(forward.state)};
157 for(var i=0; i<event.feature.cluster.length; ++i) {
158 listen($("link-" + i), Animator.apply($("photo-" + i), ["thumb", "big"]));
162 function listen(el, anim) {
163 el.onmouseover = function() {anim.seekTo(1)};
164 el.onmouseout = function() {anim.seekTo(0)};
169 <body onload="init()">
170 <h1 id="title">Cluster Strategy Example</h1>
172 Uses a cluster strategy to render points representing clusters of features.
174 <div id="map" class="smallmap"></div>
176 <p>The Cluster strategy lets you display points representing clusters
177 of features within some pixel distance.</p>
179 <div id="photos"></div>
180 <p>Hover over a cluster on the map to see the photos it includes.</p>
181 <div style="display: none;">
183 <div class="shift" id="scroll-start"><<</div>
185 <ul id="list" class="start">
186 <li jugl:repeat="feature features">
187 <a jugl:attributes="href feature.attributes.img_url;
188 id 'link-' + repeat.feature.index"
190 <img jugl:attributes="src feature.attributes.img_url;
191 title feature.attributes.title;
192 id 'photo-' + repeat.feature.index"
198 <div class="shift" id="scroll-end">>></div>