added marker-type = rectangle
This commit is contained in:
parent
46aa9fa2f2
commit
d2dcf7b2a1
@ -214,6 +214,15 @@ var _torque_reference_latest = {
|
|||||||
"default-value": "blue",
|
"default-value": "blue",
|
||||||
"doc": "The color of the area of the marker.",
|
"doc": "The color of the area of the marker.",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
|
},
|
||||||
|
"marker-type": {
|
||||||
|
"css": "marker-type",
|
||||||
|
"type": [
|
||||||
|
"rectangle",
|
||||||
|
"ellipse"
|
||||||
|
],
|
||||||
|
"default-value": "ellipse",
|
||||||
|
"doc": "The default marker-type. If a SVG file is not given as the marker-file parameter, the renderer provides either an rectangle or an ellipse (a circle if height is equal to width)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"point": {
|
"point": {
|
||||||
|
@ -39,6 +39,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderRectangle(ctx, st) {
|
||||||
|
ctx.fillStyle = st.fillStyle;
|
||||||
|
ctx.strokStyle = st.strokStyle;
|
||||||
|
var pixel_size = st['point-radius'];
|
||||||
|
|
||||||
|
// fill
|
||||||
|
if (st.fillStyle && st.fillOpacity) {
|
||||||
|
ctx.globalAlpha = st.fillOpacity;
|
||||||
|
}
|
||||||
|
ctx.fillRect(0, 0, pixel_size, pixel_size)
|
||||||
|
|
||||||
|
// stroke
|
||||||
|
ctx.globalAlpha = 1.0;
|
||||||
|
if (st.strokeStyle && st.lineWidth) {
|
||||||
|
if (st.strokeOpacity) {
|
||||||
|
ctx.globalAlpha = st.strokeOpacity;
|
||||||
|
}
|
||||||
|
if (st.lineWidth) {
|
||||||
|
ctx.lineWidth = st.lineWidth;
|
||||||
|
}
|
||||||
|
ctx.strokeStyle = st.strokeStyle;
|
||||||
|
|
||||||
|
// do not render for alpha = 0
|
||||||
|
if (ctx.globalAlpha > 0) {
|
||||||
|
ctx.strokeRect(0, 0, pixel_size, pixel_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function renderSprite(ctx, st) {
|
function renderSprite(ctx, st) {
|
||||||
var img = st['point-file'] || st['marker-file'];
|
var img = st['point-file'] || st['marker-file'];
|
||||||
var ratio = img.height/img.width;
|
var ratio = img.height/img.width;
|
||||||
@ -50,7 +79,8 @@
|
|||||||
exports.torque.cartocss = exports.torque.cartocss || {};
|
exports.torque.cartocss = exports.torque.cartocss || {};
|
||||||
exports.torque.cartocss = {
|
exports.torque.cartocss = {
|
||||||
renderPoint: renderPoint,
|
renderPoint: renderPoint,
|
||||||
renderSprite: renderSprite
|
renderSprite: renderSprite,
|
||||||
|
renderRectangle: renderRectangle
|
||||||
};
|
};
|
||||||
|
|
||||||
})(typeof exports === "undefined" ? this : exports);
|
})(typeof exports === "undefined" ? this : exports);
|
||||||
|
@ -77,9 +77,14 @@
|
|||||||
ctx.translate(canvasSize/2, canvasSize/2);
|
ctx.translate(canvasSize/2, canvasSize/2);
|
||||||
if(st['point-file'] || st['marker-file']) {
|
if(st['point-file'] || st['marker-file']) {
|
||||||
torque.cartocss.renderSprite(ctx, st);
|
torque.cartocss.renderSprite(ctx, st);
|
||||||
|
} else {
|
||||||
|
var mt = st['marker-type'];
|
||||||
|
if (mt && mt === 'rectangle') {
|
||||||
|
torque.cartocss.renderRectangle(ctx, st);
|
||||||
} else {
|
} else {
|
||||||
torque.cartocss.renderPoint(ctx, st);
|
torque.cartocss.renderPoint(ctx, st);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
prof.end();
|
prof.end();
|
||||||
return canvas;
|
return canvas;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user