ngx-gaia-gis
Version:
GaiaGisService is an Angular library that simplifies the integration of interactive maps using OpenLayers. It allows for visualizing raster maps, adding custom points, and adjusting views easily, making it ideal for developers who need to implement geospa
208 lines (200 loc) • 7.68 kB
TypeScript
import * as _angular_core from '@angular/core';
import { OnInit } from '@angular/core';
declare enum MapsDesign {
CARTOCDN = "https://{1-4}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}.png",
GNOSIS_EARTH = "https://maps.gnosis.earth/ogcapi/collections/NaturalEarth:raster:HYP_HR_SR_OB_DR/map/tiles/WebMercatorQuad",
OSM = "OSM"
}
interface Option {
center?: [number, number];
zoom?: number;
design?: MapsDesign;
maxZoom?: number;
minZoom?: number;
}
interface PolygonGaia {
coordinates: [number, number][];
properties?: Record<string, any>;
}
declare class GaiaGisComponent implements OnInit {
options?: Option;
polygonDrawn: _angular_core.OutputEmitterRef<PolygonGaia>;
private readonly gaiaGisService;
private readonly platformId;
readonly isDrawingPolygon: _angular_core.WritableSignal<boolean>;
readonly drawingStatus: _angular_core.Signal<"Ready to draw" | "Click to add vertices. Press Enter or click start point to complete." | "Polygon completed!" | "Drawing cancelled">;
readonly polygonCount: _angular_core.Signal<number>;
readonly completedPolygons: _angular_core.WritableSignal<PolygonGaia[]>;
readonly currentPolygon: _angular_core.WritableSignal<PolygonGaia | null>;
readonly drawingState: _angular_core.WritableSignal<"idle" | "drawing" | "completing" | "cancelled">;
readonly canStartDrawing: _angular_core.Signal<boolean>;
readonly showCancelButton: _angular_core.Signal<boolean>;
private readonly polygonEmitter;
ngOnInit(): void;
initializeMap(): void;
/**
* 🔥 Starts polygon drawing mode using the service signals.
*/
startPolygonDraw(): void;
/**
* 🔥 Cancels polygon drawing using the service signals.
*/
cancelPolygonDraw(): void;
/**
* 🔥 Clears all drawn polygons using the service signals.
*/
clearPolygons(): void;
/**
* 🔥 Gets the latest polygon using signals
*/
getLatestPolygon(): PolygonGaia | null;
/**
* 🔥 Removes a polygon by ID using signals
*/
removePolygonById(id: number): void;
static ɵfac: _angular_core.ɵɵFactoryDeclaration<GaiaGisComponent, never>;
static ɵcmp: _angular_core.ɵɵComponentDeclaration<GaiaGisComponent, "gaia-gis", never, { "options": { "alias": "options"; "required": false; }; }, { "polygonDrawn": "polygonDrawn"; }, never, never, true, never>;
}
interface PointGaia {
coords: [number, number];
info?: string;
}
declare class GaiaGisService {
private readonly platform;
private map;
private labels;
private rasterLayers;
private pointLayer;
private popup;
private polygonLayer;
private drawInteraction;
private keyListener;
private highlightLayer;
private startPointFeature;
/**
* Signal to track if polygon drawing is active
*/
readonly isDrawingPolygon: _angular_core.WritableSignal<boolean>;
/**
* Signal to store the current polygon being drawn
*/
readonly currentPolygon: _angular_core.WritableSignal<PolygonGaia | null>;
/**
* Signal to store all completed polygons
*/
readonly completedPolygons: _angular_core.WritableSignal<PolygonGaia[]>;
/**
* Signal to track drawing mode state
*/
readonly drawingState: _angular_core.WritableSignal<"idle" | "drawing" | "completing" | "cancelled">;
/**
* Computed signal for drawing status message
*/
readonly drawingStatus: _angular_core.Signal<"Ready to draw" | "Click to add vertices. Press Enter or click start point to complete." | "Polygon completed!" | "Drawing cancelled">;
/**
* Computed signal for polygon count
*/
readonly polygonCount: _angular_core.Signal<number>;
private readonly autoResetState;
private readonly polygonLogger;
readonly stateStatus: _angular_core.Signal<string>;
readonly polygonLogger$: _angular_core.Signal<number>;
constructor();
/**
* Initializes the map with the specified target, center, zoom level, and design.
* @param {string} target - The target element ID for the map.
* @param {Object} options - Options for configuring the map.
* @param {[number, number]} [options.center=[0, 0]] - The initial center of the map.
* @param {number} [options.zoom=2] - The initial zoom level of the map.
* @param {string} [options.design=MapsDesign.CARTOCDN] - The design of the map.
*/
initializeMap(target: string, options?: Option): void;
/**
* Initializes the popup overlay for the map.
*/
private initializePopup;
/**
* Highlights the starting point of the polygon being drawn
* @param {[number, number]} coordinate - The coordinate to highlight
*/
private highlightStartPoint;
/**
* Animates the starting point with a pulsing effect
*/
private animateStartPoint;
/**
* Clears the starting point highlight
*/
private clearStartPointHighlight;
/**
* 🔥 Starts polygon drawing mode using signals for state management.
* Users can click to add vertices and complete the polygon by clicking the first point again or pressing Enter.
*/
startPolygonDraw(): void;
/**
* 🔥 Cancels the current polygon drawing operation using signals.
*/
cancelPolygonDraw(): void;
/**
* Stops polygon drawing mode and cleans up resources.
*/
private stopPolygonDraw;
/**
* 🔥 Clears all drawn polygons from the map using signals.
*/
clearPolygons(): void;
/**
* 🔥 Get the latest completed polygon using signals
*/
getLatestPolygon(): PolygonGaia | null;
/**
* 🔥 Remove a specific polygon by ID using signals
*/
removePolygonById(id: number): void;
/**
* 🔥 Rebuilds map features from polygon data
*/
private rebuildMapFeatures;
/**
* Adds a raster layer to the map using a given URL.
* @param {string} url - The URL of the GeoTIFF file.
* @returns {Promise<void>}
*/
addRasterLayer(url: string): Promise<void>;
/**
* Creates a tiles URL for the given encoded URL.
* @param {string} url - The encoded URL of the GeoTIFF file.
* @returns {string} - The tiles URL.
*/
private createTilesUrl;
/**
* Removes a raster layer from the map by its index.
* @param {number} index - The index of the raster layer to remove.
*/
removeRasterLayer(index: number): void;
/**
* Sets the view of the map to a given center and zoom level.
* @param {[number, number]} center - The new center of the map.
* @param {number} zoom - The new zoom level of the map.
*/
setView(center: [number, number], zoom: number): void;
/**
* Zooms the map to fit a given extent.
* @param {[number, number, number, number]} extent - The extent to fit the map to.
*/
zoomToExtent(extent: [number, number, number, number]): void;
/**
* Adds a list of points to the map with an optional icon.
* @param {Array<{ coords: [number, number], info?: string }>} points - The list of points to add to the map.
* @param {string} [iconUrl] - The URL of the icon to use for the points.
*/
addPoints(points: PointGaia[], iconUrl?: string): void;
/**
* Exports the current map view to a PDF file.
*/
exportGaiaMapToPdf(): void;
static ɵfac: _angular_core.ɵɵFactoryDeclaration<GaiaGisService, never>;
static ɵprov: _angular_core.ɵɵInjectableDeclaration<GaiaGisService>;
}
export { GaiaGisComponent, GaiaGisService, MapsDesign };
export type { Option, PolygonGaia };