| 4413 | } |
| 4414 | }; |
| 4415 | function 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 | |
| 4449 | function getImage$1(url, callback, fallback) { |
| 4450 | var img = new Image(); |