staticmaps
Version:
A Node.js library for creating map images with markers, polylines, polygons and text.
54 lines (52 loc) • 2.07 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _default = exports["default"] = /*#__PURE__*/function () {
function _default() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2["default"])(this, _default);
this.options = options;
this.coord = this.options.coord;
this.img = this.options.img;
this.height = Number.isFinite(this.options.height) ? Number(this.options.height) : null;
this.width = Number.isFinite(this.options.width) ? Number(this.options.width) : null;
this.drawWidth = Number(this.options.drawWidth || this.options.width);
this.drawHeight = Number(this.options.drawHeight || this.options.height);
this.resizeMode = this.options.resizeMode || 'cover';
this.offsetX = Number.isFinite(this.options.offsetX) ? Number(this.options.offsetX) : this.drawWidth / 2;
this.offsetY = Number.isFinite(this.options.offsetY) ? Number(this.options.offsetY) : this.drawHeight;
this.offset = [this.offsetX, this.offsetY];
}
(0, _createClass2["default"])(_default, [{
key: "setSize",
value: function setSize(width, height) {
this.width = Number(width);
this.height = Number(height);
if (Number.isNaN(this.drawWidth)) {
this.drawWidth = this.width;
}
if (Number.isNaN(this.drawHeight)) {
this.drawHeight = this.height;
}
}
/**
* Set icon data
*/
}, {
key: "set",
value: function set(img) {
this.imgData = img;
}
}, {
key: "extentPx",
value: function extentPx() {
return [this.offset[0], this.height - this.offset[1], this.width - this.offset[0], this.offset[1]];
}
}]);
return _default;
}();