staticmaps
Version:
A Node.js library for creating map images with markers, polylines, polygons and text.
43 lines (41 loc) • 1.89 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _lodash = _interopRequireDefault(require("lodash.flatten"));
var MultiPolygon = exports["default"] = /*#__PURE__*/function () {
function MultiPolygon() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck2["default"])(this, MultiPolygon);
this.options = options;
this.coords = this.options.coords;
this.color = this.options.color || '#000000BB';
this.fill = this.options.fill;
this.width = Number.isFinite(this.options.width) ? Number(this.options.width) : 3;
this.simplify = this.options.simplify || false;
}
/**
* calculate the coordinates of the envelope / bounding box: (min_lon, min_lat, max_lon, max_lat)
*/
(0, _createClass2["default"])(MultiPolygon, [{
key: "extent",
value: function extent() {
var allPoints = (0, _lodash["default"])(this.coords);
return [Math.min.apply(Math, (0, _toConsumableArray2["default"])(allPoints.map(function (c) {
return c[0];
}))), Math.min.apply(Math, (0, _toConsumableArray2["default"])(allPoints.map(function (c) {
return c[1];
}))), Math.max.apply(Math, (0, _toConsumableArray2["default"])(allPoints.map(function (c) {
return c[0];
}))), Math.max.apply(Math, (0, _toConsumableArray2["default"])(allPoints.map(function (c) {
return c[1];
})))];
}
}]);
return MultiPolygon;
}();