javascript - Font Size in openlayers 3 cluster -


i using new openlayers 3 api showing large amount of markers. extended cluster example (http://openlayers.org/en/v3.0.0/examples/cluster.html).

everything works fine except 1 thing: attribute fontsize in style of text ignored. size of text inside cluster marker same.

is bug in openlayers 3 or doing wrong? tested in 3.0.0 release version , in current development version of ol3.

    var clusters = new $wnd.ol.layer.vector({         source: clustersource,         style: function (feature, resolution) {             var size = feature.get('features').length;              var style = stylecache[size];             var radius = size + 10;             if (radius > 25) {                 radius = 25;             }              if (!style) {                 style = [new $wnd.ol.style.style({                     image: new $wnd.ol.style.circle({                         radius: radius,                         stroke: new $wnd.ol.style.stroke({                             color: '#fff'                         }),                         fill: new $wnd.ol.style.fill({                             color: color                         })                     }),                     text: new $wnd.ol.style.text({                         text: size == 1 ? "●" : size.tostring(),                         fontsize: radius * 2 - 5,                         fill: new $wnd.ol.style.fill({                             color: textcolor                         })                     })                 })];                 stylecache[size] = style;             }              return style;         }     }); 

there's no fontsize option ol.style.text. there's font option though.

the font option string, has same syntax canvas context font attribute. default '10px sans-serif'.see https://developer.mozilla.org/en-us/docs/web/api/canvas_api/tutorial/drawing_text.

so in case you'll use this:

var textstyle = new ol.style.text({   font: (radius * 2 - 5) + 'px sans-serif',   // … }); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -