mapfish/mapfish-print — pull request #84 by azuledu (2013-09-17 13:56:46+00:00)
Title: Check externalGraphic void string.

Check externalGraphic void string. There is a similar check in LabelRenderer.java
It makes possible to print clusters in vector layers like:

var layer = new OpenLayers.Layer.Vector('MyVectorLayer', {
styleMap: new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
pointRadius: 10,
externalGraphic: "${externalGraphic}",
graphicHeight: "${graphicHeight}",
graphicWidth: "${graphicWidth}",
label: "${count}",
labelAlign: "cm",
labelYOffset: "${labelYOffset}",
fontSize: "13px",
fontFamily: "arial,helvetica,clean,sans-serif",
fontWeight: "bold",
fillColor: "#fff",
strokeColor: "#333",
strokeWidth: 2,
cursor: "pointer",
}, {
context: {
externalGraphic: function(feature) {
if (feature.cluster.length == 1) {
var type = feature.cluster[0].attributes.type;
switch(type) {
case 1:
return OpenLayers.ImgPath + "img/img1.png";
case 2:
return OpenLayers.ImgPath + "img/img2.png";
}
}
return '';
},
count: function(feature) {
return feature.attributes.count > 1 ? feature.attributes.count : '';
},
graphicWidth: function(feature) {
if (feature.cluster.length == 1) {
var type = feature.cluster[0].attributes.type;
if (type == 1 || type == 2 || type == 4) {
return 21;
} else if (type == 3) {
return 15;
}
}
},
graphicHeight: function(feature) {
if (feature.cluster.length == 1) {
var type = feature.cluster[0].attributes.type;
if (type == 1 || type == 2 || type == 3) {
return 17;
} else if (type == 4) {
return 22;
}
}
}
}
}),
}),
strategies: [new OpenLayers.Strategy.Fixed(), cluster],
protocol: new OpenLayers.Protocol.Script({
url: options.wmsURL,
format: new OpenLayers.Format.GeoJSON(),
params: {
service: "WFS",
version: "1.1.0",
request: "GetFeature",
typename: 'feature:' + options.layerName,
outputformat: 'geojsonp',
lang: OpenLayers.Lang.getCode()
}
})
});