UNPKG

@mint-ui/map

Version:

- React map library - Control various map with one interface - Google, Naver, Kakao map supported now - Typescript supported - Canvas marker supported

165 lines (128 loc) 3.57 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var polygon = require('../core/util/polygon.js'); /** * 좌표값 * @description 위도/경도, DOM 상의 X/Y 좌표 */ var Position = /** @class */ function () { function Position(lat, lng) { /** * 위도 * @description 위도(latitude) */ this.lat = 0; /** * 경도 * @description 경도(longitude) */ this.lng = 0; this.lat = lat; this.lng = lng; } Position.equals = function (pos1, pos2) { return pos1.lat === pos2.lat && pos1.lng === pos2.lng; }; return Position; }(); var Bounds = /** @class */ function () { function Bounds(nw, se, ne, sw) { if (!(nw && se || ne && sw)) { throw new Error('nw/se or ne/sw needed'); } //@ts-ignore this.nw = nw; this.se = se; this.ne = ne; this.sw = sw; if (nw && se) { this.covertNWSEtoNESW(nw, se); } else if (ne && sw) { this.covertNESWtoNWSE(ne, sw); } } Bounds.fromNWSE = function (nw, se) { return new Bounds(nw, se, undefined, undefined); }; Bounds.fromNESW = function (ne, sw) { return new Bounds(undefined, undefined, ne, sw); }; Bounds.prototype.covertNWSEtoNESW = function (nw, se) { this.ne = new Position(nw.lat, se.lng); this.sw = new Position(se.lat, nw.lng); }; Bounds.prototype.covertNESWtoNWSE = function (ne, sw) { this.nw = new Position(ne.lat, sw.lng); this.se = new Position(sw.lat, ne.lng); }; Bounds.prototype.getCenter = function () { return new Position(this.se.lat + (this.nw.lat - this.se.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2); }; Bounds.prototype.includesPosition = function (pos) { return this.nw.lng < pos.lng && this.se.lng > pos.lng && this.se.lat < pos.lat && this.nw.lat > pos.lat; }; Bounds.prototype.getIncludedPositions = function (positions) { var result = []; for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) { var pos = positions_1[_i]; if (this.includesPosition(pos)) { result.push(pos); } } return result; }; Bounds.prototype.includes = function (positions) { positions = Array.isArray(positions) ? positions : [positions]; for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) { var pos = positions_2[_i]; if (!this.includesPosition(pos)) { return false; } } return true; }; Bounds.prototype.includesOnlyOnePoint = function (positions) { for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) { var pos = positions_3[_i]; if (this.includesPosition(pos)) { return true; } } return false; }; Bounds.prototype.intersects = function (positions) { return polygon.PolygonCalculator.intersects([this.nw, this.sw, this.se, this.ne, this.nw], positions); }; return Bounds; }(); /** * DOM 상에서의 좌표를 표현 (픽셀을 나타내는 숫자) */ var Offset = /** @class */ function () { /** * DOM 상에서의 좌표를 표현 (픽셀을 나타내는 숫자) */ function Offset(x, y) { this.x = x; this.y = y; } Offset.prototype.equals = function (other) { return other && this.x === other.x && this.y === other.y; }; return Offset; }(); var Spacing = /** @class */ function () { function Spacing() {} return Spacing; }(); exports.Bounds = Bounds; exports.Offset = Offset; exports.Position = Position; exports.Spacing = Spacing;