@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
45 lines (44 loc) • 1.34 kB
JavaScript
class MapPosition {
center = [];
zoom;
resolution;
scale;
crosshair;
tooltip;
markers = [];
get isValid() {
if (Number.isNaN(this.resolution)) {
return false;
}
if (!this.center[0] || !this.center[1] || Number.isNaN(this.center[0]) || Number.isNaN(this.center[1])) {
return false;
}
return true;
}
clone() {
const position = new MapPosition();
position.center = [...this.center];
position.zoom = this.zoom;
position.resolution = this.resolution;
position.scale = this.scale;
position.crosshair = this.crosshair ? [...this.crosshair] : undefined;
position.tooltip = this.tooltip
? {
title: this.tooltip.title,
content: this.tooltip.content,
position: this.tooltip.position ? [...this.tooltip.position] : undefined
}
: undefined;
for (const marker of this.markers) {
position.markers.push({
imageUrl: marker.imageUrl,
position: marker.position,
size: marker.size,
offset: marker.offset,
tooltip: marker.tooltip
});
}
return position;
}
}
export default MapPosition;