@jorgenphi/staticmaps
Version:
A Node.js library for creating map images with markers, polylines, polygons and text.
47 lines (39 loc) • 1.56 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 = /*#__PURE__*/function () {
function _default() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2["default"])(this, _default);
this.options = options;
if (!(options.width && options.height)) throw new Error('Please specify width and height of the marker image.');
this.coord = this.options.coord;
this.img = this.options.img;
this.height = Number(this.options.height);
this.width = Number(this.options.width);
this.offsetX = Number.isFinite(this.options.offsetX) ? Number(this.options.offsetX) : this.width / 2;
this.offsetY = Number.isFinite(this.options.offsetY) ? Number(this.options.offsetY) : this.height;
this.offset = [this.offsetX, this.offsetY];
}
/**
* Set icon data
*/
(0, _createClass2["default"])(_default, [{
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;
}();
exports["default"] = _default;