UNPKG

@orca-fe/x-map

Version:
61 lines (60 loc) 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const BaseInstance_1 = tslib_1.__importDefault(require("./BaseInstance")); const WebViewport_1 = require("../utils/WebViewport"); class EmptyInstance extends BaseInstance_1.default { constructor() { super(...arguments); this.viewport = { lat: 0, pitch: 0, lng: 0, zoom: 11, rotate: 0, }; } init(id, options) { const { viewport } = options; this.viewport = Object.assign(Object.assign({}, this.viewport), viewport); this.map = {}; this.dom = typeof id === 'string' ? document.getElementById(id) : id; this.emit('load'); } destroy() { this.emit('unloaded'); } lnglatToPixel(point) { const wmvp = (0, WebViewport_1.getMapViewport)(this.getViewport()); return wmvp.project(point); } pixelToLnglat(pixel) { const wmvp = (0, WebViewport_1.getMapViewport)(this.getViewport()); return wmvp.unproject(pixel); } getCenter() { return [this.viewport.lng, this.viewport.lat]; } setCenter(point) { [this.viewport.lng, this.viewport.lat] = point; } getZoom() { return this.viewport.zoom; } setZoom(zoom) { this.viewport.zoom = zoom; } getPitch() { return this.viewport.pitch; } setPitch(pitch) { this.viewport.pitch = pitch; } getRotate() { return this.viewport.rotate; } setRotate(deg) { this.viewport.rotate = deg; } } exports.default = EmptyInstance;