MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / drawItem

Function drawItem

libs/mapv/mapv.js:4415–4447  ·  view source on GitHub ↗
(img, options, context, item)

Source from the content-addressed store, hash-verified

4413 }
4414};
4415function drawItem(img, options, context, item) {
4416 context.save();
4417 var coordinates = item.geometry._coordinates || item.geometry.coordinates;
4418 var x = coordinates[0];
4419 var y = coordinates[1];
4420 var offset = options.offset || { x: 0, y: 0 };
4421 var width = item.width || options._width || options.width;
4422 var height = item.height || options._height || options.height;
4423 x = x - ~~width / 2 + offset.x;
4424 y = y - ~~height / 2 + offset.y;
4425 if (typeof img === 'string') {
4426 context.beginPath();
4427 context.arc(x, y, options.size || 5, 0, Math.PI * 2);
4428 context.fillStyle = options.fillStyle || 'red';
4429 context.fill();
4430 return;
4431 }
4432 var deg = item.deg || options.deg;
4433 if (deg) {
4434 context.translate(x, y);
4435 context.rotate(deg * Math.PI / 180);
4436 context.translate(-x, -y);
4437 }
4438
4439 if (options.sx && options.sy && options.swidth && options.sheight && options.width && options.height) {
4440 context.drawImage(img, options.sx, options.sy, options.swidth, options.sheight, x, y, width, height);
4441 } else if (width && height) {
4442 context.drawImage(img, x, y, width, height);
4443 } else {
4444 context.drawImage(img, x, y);
4445 }
4446 context.restore();
4447}
4448
4449function getImage$1(url, callback, fallback) {
4450 var img = new Image();

Callers 1

_loopFunction · 0.85

Calls 5

saveMethod · 0.80
arcMethod · 0.80
translateMethod · 0.80
restoreMethod · 0.80
rotateMethod · 0.45

Tested by

no test coverage detected