]> dev.renevier.net Git - syp.git/commitdiff
show number of features on cluster markers
authorarno <arenevier@fdn.fr>
Mon, 5 Oct 2009 22:34:59 +0000 (00:34 +0200)
committerarno <arenevier@fdn.fr>
Mon, 5 Oct 2009 22:34:59 +0000 (00:34 +0200)
js/syp.js

index 8c2e5bca13e910f427d45abab9046c04bf932f86..9bccba64d4e1d6796c7b06049e85cc0fb974e1c8 100644 (file)
--- a/js/syp.js
+++ b/js/syp.js
@@ -127,13 +127,23 @@ var SYP = {
     createDataLayer: function(map) {
         var defaultStyle = new OpenLayers.Style({
             externalGraphic: this.Markers.ICON,
-            graphicHeight: "${height}"
+            graphicHeight: "${height}",
+            label: "${label}",
+            fontColor: "white",
+            fontWeight: "bold"
         }, {
             context: {
                 height: function(feature) {
                     var defaultHeight = SYP.Markers.HEIGHT || 32;
                     var increase = 4 * (feature.attributes.count - 1);
                     return Math.min(defaultHeight + increase, 50);
+                },
+                label: function(feature) {
+                    var renderer = feature.layer.renderer;
+                    if (renderer.CLASS_NAME == "OpenLayers.Renderer.Canvas") {
+                        return ""; // canvas backend cannot draw text above an external Image
+                    }
+                    return (feature.attributes.count > 1) ? feature.attributes.count: "";
                 }
             }
         });