rlayers
Version:
React Components for OpenLayers
65 lines • 3.16 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var Graticule_1 = __importDefault(require("ol/layer/Graticule"));
var RLayer_1 = __importDefault(require("./RLayer"));
var style_1 = require("rlayers/style");
/**
* A layer that renders a static image
*/
var RLayerGraticule = /** @class */ (function (_super) {
__extends(RLayerGraticule, _super);
function RLayerGraticule(props, context) {
var _this = _super.call(this, props, context) || this;
_this.createSource();
return _this;
}
RLayerGraticule.prototype.createSource = function () {
var _a, _b, _c, _d, _e, _f;
var stroke = (_b = (_a = style_1.RStyle.getStyleStatic(this.props.strokeStyle)) === null || _a === void 0 ? void 0 : _a.getStroke) === null || _b === void 0 ? void 0 : _b.call(_a);
var lonText = (_d = (_c = style_1.RStyle.getStyleStatic(this.props.lonLabelStyle)) === null || _c === void 0 ? void 0 : _c.getText) === null || _d === void 0 ? void 0 : _d.call(_c);
var latText = (_f = (_e = style_1.RStyle.getStyleStatic(this.props.latLabelStyle)) === null || _e === void 0 ? void 0 : _e.getText) === null || _f === void 0 ? void 0 : _f.call(_e);
this.ol = new Graticule_1.default(__assign(__assign({}, this.props), { strokeStyle: stroke, lonLabelStyle: lonText, latLabelStyle: latText }));
this.eventSources = [this.ol];
return;
};
RLayerGraticule.prototype.refresh = function (prevProps) {
_super.prototype.refresh.call(this, prevProps);
var old = this.context.map.removeLayer(this.ol);
this.createSource();
this.attachOldEventHandlers(this.ol);
if (old)
this.context.map.addLayer(this.ol);
};
return RLayerGraticule;
}(RLayer_1.default));
exports.default = RLayerGraticule;
//# sourceMappingURL=RLayerGraticule.js.map
;