@types/heremaps
Version:
TypeScript definitions for heremaps
1,051 lines (927 loc) • 404 kB
TypeScript
declare namespace H {
/***** Map *****/
/**
* Map class defines map instance in the application. By creating this object you will initialize a visible map object which is attached to the provided dom element.
* Map class is an entry point to all operations related to layers, map objects and geo-screen transformations. By specifying options you can initialize map with predefined view.
*/
class Map extends H.util.EventTarget {
/**
* Constructor
* @param element {Element} - html element into which the map will be rendered
* @param baseLayer {H.map.layer.Layer} - The layer to be used as the base (bottom most) layer.
* @param opt_options {H.Map.Options=} - additional map options
*/
constructor(element: Element, baseLayer: H.map.layer.Layer, opt_options?: H.Map.Options);
/**
* This method returns the map root html element
* @returns {Element}
*/
getElement(): Element;
/**
* This method sets the new center on a map.
* @param center {H.geo.IPoint} - requested center to be set
* @param opt_animate {boolean=} - parameter indicates if animated transition should be applied, default is false
* @returns {H.Map} - the instance itself
*/
setCenter(center: H.geo.IPoint, opt_animate?: boolean): H.Map;
/**
* This method returns currently rendered center of the map.
* @returns {H.geo.Point}
*/
getCenter(): H.geo.Point;
/**
* This method sets the zoom level on the map. Every zoom level represents different scale i.e map at zoom level 2 is twice as large as the map at zoom level 1.
* @param zoom {number} - requested zoom level
* @param opt_animate {boolean=} - parameter indicates if animated transition should be applied, default is false
* @returns {H.Map} - the instance itself
*/
setZoom(zoom: number, opt_animate?: boolean): H.Map;
/**
* This method returns currently rendered zoom level.
* @returns {number}
*/
getZoom(): number;
/**
* This method changes the map zoom while keeping target screen coordinates specified as x,y at the same place where they were before.
* @param zoom {number} - new zoom level
* @param x {number} - map viewport x-axis pixel coordinate
* @param y {number} - map viewport y-axis pixel coordinate
*/
zoomAt(zoom: number, x: number, y: number): void;
/**
* This method returns current map viewport.
* Viewport can be used to modify padding and margin which will reflect the position of the viewport center and the amount of extra data loaded (for margin)
* @returns {H.map.ViewPort}
*/
getViewPort(): H.map.ViewPort;
/**
* This method returns current view model. View model can be used to modify the current view or camera. H.map.ViewModel
* @returns {H.map.ViewModel}
*/
getViewModel(): H.map.ViewModel;
/**
* This method returns the map's current layer collection.
* @returns {H.map.DataModel}
*/
getLayers(): H.map.DataModel;
/**
* This method returns the imprint object for this map.
* @returns {H.map.Imprint}
*/
getImprint(): H.map.Imprint;
/**
* This method captures desired region of the map and objects on it. Result is returned as an HTML5 Canvas element.
* Origin of coordinate system for capturing is in the top left corner of the viewport.
* @param callback {function(HTMLCanvasElement=)} - Callback function to call once result of the capturing is ready
* @param opt_capturables {Array<H.util.ICapturable>=} - Collection of "capturable" element(s) to draw into the resulting canvas
* @param opt_x1 {number=} - The X coordinate of the left edge of the capturing rectangle defaults to 0
* @param opt_y1 {number=} - The Y coordinate of the top edge of the capturing rectangle defaults to 0
* @param opt_x2 {number=} - The X coordinate of the right edge of the capturing rectangle defaults to viewport width
* @param opt_y2 {number=} - The Y coordinate of the bottom edge of the capturing rectangle defaults to viewport height
*/
capture(
callback?: (canvas: HTMLCanvasElement) => void,
opt_capturables?: H.util.ICapturable[],
opt_x1?: number,
opt_y1?: number,
opt_x2?: number,
opt_y2?: number,
): void;
/**
* This method sets the rendering engine type for the map. Rendering engine is responsible for displaying i.e tiles and data on the map.
* @param type {H.Map.EngineType}
* @returns {H.Map} - the map itself
*/
setEngineType(type: H.Map.EngineType): H.Map;
/**
* To persistently store the content of a map layer for a given area and range of zoom levels.
* It can be used to enable map rendering when no internet connection is established and also to reduce the download traffic for frequently visited map areas.
* @param opt_onprogress {function(H.util.Request)=} - A callback which is invoked every time when the progress state of the returned store request changes.
* @param opt_bounds {H.geo.Rect=} - The area to store, default is the current view bounds
* @param opt_min {number=} - The minimum zoom level to store, default is the current zoom level
* @param opt_max {number=} - The maximum zoom level to store, default is the current zoom level
* @param opt_layer {H.map.layer.BaseTileLayer=} - The layer to store, default is the current base layer
* @returns {H.util.Request} - A handle to the created storage request
*/
storeContent(
opt_onprogress?: (req: H.util.Request) => void,
opt_bounds?: H.geo.Rect,
opt_min?: number,
opt_max?: number,
opt_layer?: H.map.layer.BaseTileLayer,
): H.util.Request;
/**
* To clear the entire stored content
* @param opt_onprogress {function(H.util.Request)=} - A callback which is invoked every time when the progress state of the returned clear request changes
* @returns {H.util.Request} - A handle to the created flush request
*/
clearContent(opt_onprogress?: (req: H.util.Request) => void): H.util.Request;
/**
* This method adds a layer to the map.
* @param layer {H.map.layer.Layer} - The map layer to be added
* @param opt_idx {number=} - index at which the new layer should be inserted
* @returns {H.Map} - current map instance
*/
addLayer(layer: H.map.layer.Layer, opt_idx?: number): H.Map;
/**
* This method removes layer from the map.
* @param layer {H.map.layer.Layer} - The map layer to be removed
* @returns {H.Map} - current map instance
*/
removeLayer(layer: H.map.layer.Layer): H.Map;
/**
* This method will set provided layer as base map. The layer will be inserted as the bottom most layer in the map.
* @param layer {H.map.layer.Layer} - The layer to use as base map
* @returns {H.Map} - the instance itself
*/
setBaseLayer(layer: H.map.layer.Layer): H.Map;
/**
* To get the current base map layer.
* @returns {?H.map.layer.Layer}
*/
getBaseLayer(): H.map.layer.Layer;
/**
* Returns the screen coordinates according to the given geographical coordinates. This method returns a screen pixel coordinates for the provided geo point.
* @param geoPoint {H.geo.IPoint} - point on the map
* @returns {?H.math.Point}
*/
geoToScreen(geoPoint: H.geo.IPoint): H.math.Point;
/**
* Returns the geographical coordinates according to the given screen coordinates.
* @param x {number} - map viewport x-axis pixel coordinate
* @param y {number} - map viewport y-axis pixel coordinate
* @returns {?H.geo.Point}
*/
screenToGeo(x: number, y: number): H.geo.Point;
/**
* Returns the camera data according to the given screen coordinates. Method converts screen pixel coordinates to correct camera data object
* @param x {number} - map viewport x-axis pixel coordinate
* @param y {number} - map viewport y-axis pixel coordinate
* @returns {H.map.ViewModel.ILookAtData}
*/
screenToLookAtData(x: number, y: number): H.map.ViewModel.ILookAtData;
/**
* This method adds an map object to the map. Map object can be a marker or a spatial object like polygon or polyline.
* @param mapObject {!H.map.Object} - The map object to add
* @returns {!H.map.Object} - the added map object
*/
addObject(mapObject: H.map.Object): H.map.Object;
/**
* This method removes previously added map object from the map.
* @param mapObject {!H.map.Object} - The map object to remove
* @returns {!H.map.Object} - the removed map object
*/
removeObject(mapObject: H.map.Object): H.map.Object;
/**
* This method retrieves the list of all objects which have been added to the map.
* @returns {Array<H.map.Object>} - the list of all use objects which are currently on the map.
*/
getObjects(): H.map.Object[];
/**
* This method adds an array of objects or an object group to the map.
* @param mapObjects {Array<!H.map.Object>}
* @returns {H.Map} - the map instance
*/
addObjects(mapObjects: H.map.Object[]): H.Map;
/**
* This method removes an array of object or an object group from the map.
* @param mapObjects {(Array<H.map.Object> | H.map.Group)}
* @returns {H.Map} - the map instance
*/
removeObjects(mapObjects: H.map.Object[] | H.map.Group): H.Map;
/**
* Returns the top most z-ordered map object found under the specific screen coordinates. Coordinates are viewport pixel coordinates starting from top left corner as (0, 0) point.
* @param x {number} - map viewport x-axis pixel coordinate
* @param y {number} - map viewport y-axis pixel coordinate
* @param callback {function}
* @returns {?H.map.Object} - the encountered top most map object or null if no object found
*/
getObjectAt(x: number, y: number, callback: (obj: H.map.Object) => any): H.map.Object;
/**
* Returns a list of map objects in descending z-order found under the specific screen coordinates. Coordinates are viewport pixel coordinates starting from top left corner as (0, 0) point.
* @param x {number} - map viewport x-axis pixel coordinate
* @param y {number} - map viewport y-axis pixel coordinate
* @returns {Array<!H.map.Object>}
*/
getObjectsAt(x: number, y: number): H.map.Object[];
/**
* This method will dispatch event on the event target object
* @param evt {(H.util.Event | string)} - event object or event name
*/
dispatchEvent(evt: H.util.Event | string): void;
/**
* Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.
*/
dispose(): void;
/**
* This method adds callback which is triggered when the object is being disposed
* @param callback {Function} - The callback function.
* @param opt_scope {Object=} - An optional scope to call the callback in.
*/
addOnDisposeCallback(callback: () => void, opt_scope?: {}): void;
/**
* This returns the map's render engine
* @return {H.map.render.p2d.RenderEngine} - map render engine
*/
getEngine(): H.map.render.p2d.RenderEngine;
}
namespace Map {
/**
* It defines the number of lower and higher zoom levels, where cached content of the base map is rendered while content of the current zoom level is still loading.
* Example: if range was set to {lower: 3, higher: 2} and current level is 10 then rendering engine will try to display cached tiles from lower zoom levels 7, 8, 9 and higher levels 11 and 12.
* lower {number} - The number of lower zoom levels to take into account, default is 0
* higher {number} - The number of higher zoom levels to take into account, default is 0
*/
interface BackgroundRange {
lower: number;
higher: number;
}
/**
* Types of engines
*/
enum EngineType {
P2D,
PANORAMA,
}
/**
* This type defines options which can be used to initialize the map.
* center {H.geo.IPoint=} - The initial center of the map, default is {lat:0, lng: 0}
* zoom {number=} - The initial zoom level of the map, default is 0 respectively the minimal zoom level of the base map
* bounds {H.geo.Rect=} - The view bounds to be displayed on the map. If provided, it takes precedence over center and zoom. and zoom if provided)
* layers {Array<H.map.layer.Layer>=} - A list of layers to render on top of the base map
* engineType: {H.Map.EngineType=} - The initial engine type to use, default is P2D
* pixelRatio {number} - The pixelRatio to use for over-sampling in cases of high-resolution displays, default is 1
* imprint {H.map.Imprint.Options=} - The imprint options or null to suppress the imprint
* renderBaseBackground {H.Map.BackgroundRange=} - Object describes how many cached zoom levels should be used as a base map background while base map tiles are loading.
* Example: {lower: 3, higher: 2}
* autoColor {boolean=} - Indicates whether the UI's colors should automatically adjusted to the base layer, default is true. Up to now only the copyright style will be adjusted.
* See H.map.layer.Layer.Options#dark
* margin {number=} - The size in pixel of the supplemental area to render for each side of the map
* padding {H.map.ViewPort.Padding=} - The padding in pixels for each side of the map
* fixedCenter {boolean=} - Indicates whether the center of the map should remain unchanged if the viewport's size or padding has been changed, default is true
* noWrap {boolean=} - Indicates whether to wrap the world on longitude axes. When set to true, only one world will be rendered. Default is false, multiple worlds are rendered.
*/
interface Options {
center?: H.geo.IPoint | undefined;
zoom?: number | undefined;
bounds?: H.geo.Rect | undefined;
layers?: H.map.layer.Layer[] | undefined;
engineType?: EngineType | undefined;
pixelRatio?: number | undefined;
imprint?: H.map.Imprint.Options | undefined;
renderBaseBackground?: BackgroundRange | undefined;
autoColor?: boolean | undefined;
margin?: number | undefined;
padding?: H.map.ViewPort.Padding | undefined;
fixedCenter?: boolean | undefined;
noWrap?: boolean | undefined;
}
}
/***** clustering *****/
namespace clustering {
/**
* This class represents the input data structure for data points to be clustered.
* lat {H.geo.Latitude} - The latitude coordinate of the data point's position
* lng {H.geo.Longitude} - The longitude coordinate of the data point's position
* wt {number} - The weight of the data point
* data {*} - Data associated with this data point
*/
class DataPoint implements H.geo.IPoint {
/**
* Constructor
* @param lat {H.geo.Latitude} - The latitude coordinate of the data point's position
* @param lng {H.geo.Longitude} - The longitude coordinate of the data point's position
* @param opt_weight {number=} - The weight of the data point as a positive number > 0. If not specified it , default is 1.
* @param opt_data {*=} - Optional data, which will be associated with this DataPoint
*/
constructor(lat: H.geo.Latitude, lng: H.geo.Longitude, opt_weight?: number, opt_data?: any);
lat: H.geo.Latitude;
lng: H.geo.Longitude;
alt: H.geo.Altitude;
ctx: H.geo.AltitudeContext;
wt: number;
data: any;
}
/**
* This interface describes a cluster of data points, which fulfill the clustering specification (i.e. data points are within the epsilon and there are enough points to form a cluster).
*/
interface ICluster {
/**
* Returns the maximum zoom level where this cluster doesn't fall apart into sub clusters and/or noise poinst
* @returns {number}
*/
getMaxZoom(): number;
/**
* Returns the bounding rectangle of this cluster.
* @returns {H.geo.Rect}
*/
getBounds(): H.geo.Rect;
/**
* Invokes the specified callback for each "entry" of the cluster.
* That "entry" can be either a cluster which implements H.clustering.ICluster interface or a noise point which implements H.clustering.INoisePoint interface.
* @param callback {function(H.clustering.IResult)} - The callback gets the currently traversed entry as an argument, which is cluster or noise point.
*/
forEachEntry(callback: (result: H.clustering.IResult) => void): void;
/**
* Invokes the specified callback for each data point which is part of this cluster, even indirectly.
* @param callback {function(H.clustering.INoisePoint)} - The callback gets the currently traversed noise point as argument.
*/
forEachDataPoint(callback: (noise: H.clustering.INoisePoint) => void): void;
/**
* Returns the geographical position of this cluster result.
* @returns {H.geo.Point}
*/
getPosition(): H.geo.Point;
/**
* Returns the weight of this cluster result.
* @returns {number}
*/
getWeight(): number;
/**
* To indicate whether this cluster result is a cluster or noise point
* @returns {boolean}
*/
isCluster(): boolean;
/**
* Returns the minimum zoom level where this item is not part of another cluster
* @returns {number}
*/
getMinZoom(): number;
}
/**
* This interface represents a data point which does not belong to a cluster.
*/
interface INoisePoint {
/**
* This method returns data which coresponds to this noise point.
* @returns {*}
*/
getData(): any;
/**
* Returns the geographical position of this cluster result.
* @returns {H.geo.Point}
*/
getPosition(): H.geo.Point;
/**
* Returns the weight of this cluster result.
* @returns {number}
*/
getWeight(): number;
/**
* To indicate whether this cluster result is a cluster or noise point
* @returns {boolean}
*/
isCluster(): boolean;
/**
* Returns the minimum zoom level where this item is not part of another cluster
* @returns {number}
*/
getMinZoom(): number;
}
/**
* This interface represents the result item of a clustering operation.
*/
interface IResult {
/**
* Returns the geographical position of this cluster result.
* @returns {H.geo.Point}
*/
getPosition(): H.geo.Point;
/**
* Returns the weight of this cluster result.
* @returns {number}
*/
getWeight(): number;
/**
* To indicate whether this cluster result is a cluster or noise point
* @returns {boolean}
*/
isCluster(): boolean;
/**
* Returns the minimum zoom level where this item is not part of another cluster
* @returns {number}
*/
getMinZoom(): number;
}
/**
* Interface which specifies the methods a theme must implement.
*/
interface ITheme {
/**
* Function returns a cluster presentation as a map object.
* @param cluster {H.clustering.ICluster}
* @returns {H.map.Object}
*/
getClusterPresentation(cluster: H.clustering.ICluster): H.map.Object;
/**
* Function returns noise point presentation as a map object
* @param noisePoint {H.clustering.INoisePoint}
* @returns {H.map.Object}
*/
getNoisePresentation(noisePoint: H.clustering.INoisePoint): H.map.Object;
}
/**
* The clustering provider serves clusters and noise point representation for the map depending on the provided data set.
* Levels for clustering as well as custom cluster representation can be set via Options.
* min {number} - Minimum zoom level at which provider can cluster data
* max {number} - Maximum zoom level at which provider can cluster data
*/
class Provider extends H.util.EventTarget {
/**
* Constructor
* @param dataPoints {Array<H.clustering.DataPoint>}
* @param opt_options {H.clustering.Provider.Options=}
*/
constructor(dataPoints: H.clustering.DataPoint[], opt_options?: H.clustering.Provider.Options);
/**
* This method will dispatch event on the event target object
* @param evt {(H.util.Event | string)} - event object or event name
*/
dispatchEvent(evt: H.util.Event | string): void;
/**
* Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.
*/
dispose(): void;
/**
* This method adds callback which is triggered when the object is being disposed
* @param callback {Function}
* @param opt_scope {Object=}
*/
addOnDisposeCallback(callback: () => void, opt_scope?: {}): void;
/**
* This method sets new data to the provider
* @param dataPoints {Array<H.clustering.DataPoint>}
*/
setDataPoints(dataPoints: H.clustering.DataPoint[]): void;
/**
* This method adds a data point to the provider. Beware that this method provokes reclustering of the whole data set.
* @param dataPoint {H.clustering.DataPoint}
*/
addDataPoint(dataPoint: H.clustering.DataPoint): void;
/**
* This method adds a list of data points to the provider. Beware that this method provokes reclustering of the whole data set.
* @param dataPoints {Array<H.clustering.DataPoint>}
*/
addDataPoints(dataPoints: H.clustering.DataPoint[]): void;
/**
* This method removes a data point from the provider. Beware that this method provokes reclustering of the whole data set.
* @param dataPoint {H.clustering.DataPoint}
*/
removeDataPoint(dataPoint: H.clustering.DataPoint): void;
/**
* This method returns current theme used for creating cluster visualization
* @returns {H.clustering.ITheme}
*/
getTheme(): H.clustering.ITheme;
/**
* This method sets new theme on the provider. Calling this method will change visuals for displayed clusters and noise points.
* @param theme {H.clustering.ITheme}
*/
setTheme(theme: H.clustering.ITheme): void;
/**
* This method always returns true as we don't have information about visual representation until we have the clustering result and apply the theme.
* @returns {boolean}
*/
providesDomMarkers(): boolean;
/**
* Returns all DomMarker cluster and noise point representations which intersect with the provided rectangular area.
* @param bounds {H.geo.Rect} - A rectangular area in geo space to intersect with
* @param zoomLevel {number} - The zoom level for which the objects are requested
* @param visiblesOnly {boolean} - Indicates whether only invisible objects are to be considered
* @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered
* @returns {Array<H.map.DomMarker>} - a list of intersecting objects
*/
requestDomMarkers(
bounds: H.geo.Rect,
zoomLevel: number,
visiblesOnly: boolean,
cacheOnly: boolean,
): H.map.DomMarker[];
/**
* This method always returns true as we don't have information about visual representation until we have the clustering result and apply the theme.
* @returns {boolean}
*/
providesMarkers(): boolean;
/**
* Returns all cluster and noise point markers which intersect with the provided rectangular area.
* @param bounds {H.geo.Rect} - A rectangular area in geo space to intersect with
* @param zoomLevel {number} - The zoom level for which the objects are requested
* @param visiblesOnly {boolean} - Indicates whether only invisible objects are to be considered
* @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered
* @returns {Array<H.map.Marker>} - a list of intersecting objects
*/
requestMarkers(
bounds: H.geo.Rect,
zoomLevel: number,
visiblesOnly: boolean,
cacheOnly: boolean,
): H.map.Marker[];
/**
* This method always returns true as we don't have information about visual representation until we have the clustering result and apply the theme.
* @returns {boolean}
*/
providesSpatials(): boolean;
/**
* Returns all polyline, polygon, circle and rect objects which represent cluster and noise points and intersect with the provided area.
* @param bounds {H.geo.Rect} - A rectangular area in geo space to intersect with
* @param zoomLevel {number} - The zoom level for which the objects are requested
* @param visiblesOnly {boolean} - Indicates whether only invisible objects are to be considered
* @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered
* @returns {Array<H.map.Spatial>} - a list of intersecting objects
*/
requestSpatials(
bounds: H.geo.Rect,
zoomLevel: number,
visiblesOnly: boolean,
cacheOnly: boolean,
): H.map.Spatial[];
/**
* Returns the spatial objects which intersect the given tile
* @param tile {H.map.provider.SpatialTile} - The tile for which the objects are requested
* @param visiblesOnly {boolean} - Indicates whether only invisible objects are to be considered
* @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered
* @returns {Array<H.map.Spatial>} - a list of intersecting objects
*/
requestSpatialsByTile(
tile: H.map.provider.Tile,
visiblesOnly: boolean,
cacheOnly: boolean,
): H.map.Spatial[];
/**
* Returns the accumulate invalidations of this provider's objects that have occurred.
* @returns {H.map.provider.Invalidations} - an invalidations object
*/
getInvalidations(): H.map.provider.Invalidations;
/**
* To signal to this provider that a map object has been changed. The method updates the Invalidations of this provider and the given map object and triggers dispatchUpdate()
* @param mapObject {!H.map.Object} - The map object to be invalidated
* @param changes {H.math.BitMask} - The flags indicating the types of occurred changes
*/
invalidateObject(mapObject: H.map.Object, changes: H.math.BitMask): void;
min: number;
max: number;
}
namespace Provider {
/**
* Options which are used within cluster calculations.
* eps {number=} - epsilon parameter for cluster calculation. For the FASTGRID strategy it must not exceed 256 and must take values that are power of 2.
* For the GRID and DYNAMICGRID strategies it can take values from 10 to 127. Default is 32.
* minWeight {number=} - the minimum points weight sum to form a cluster, default is 2
* projection {H.geo.IProjection=} - projection to use for clustering, default is H.geo.mercator
* strategy {H.clustering.Provider.Strategy=} - clustering stretegy, defaults to H.clustering.Provider.Strategy.FASTGRID
*/
interface ClusteringOptions {
eps?: number | undefined;
minWeight?: number | undefined;
projection?: H.geo.IProjection | undefined;
strategy?: H.clustering.Provider.Strategy | undefined;
}
/**
* Options which are used to initialize the clustering Provider
* min {number=} - The minimal supported zoom level, default is 0
* max {number=} - The maximal supported zoom level, default is 22
* clusteringOptions {H.clustering.Provider.ClusteringOptions=} - options for clustering algorithm
* theme {H.clustering.ITheme=} - cluster and noise point graphical representation
*/
interface Options {
min?: number | undefined;
max?: number | undefined;
clusteringOptions?: H.clustering.Provider.ClusteringOptions | undefined;
theme?: H.clustering.ITheme | undefined;
}
/**
* Enumeration represents possible clustering strategies. FASTGRID clustering is the efficient way to cluster large sets of data points.
* GRID clustering is slower but has greater precision due to the bigger range of epsilon values, this strategy suitable for clustering smaller data sets (up to 1000 data points)
* on desktop devices. DYNAMICGRID clustering uses the same algorithm of clustering as the GRID, but clusters on the viewport basis is meant to be used with data sets that are subject
* to the frequent update operations.
*/
enum Strategy {
FASTGRID,
GRID,
DYNAMICGRID,
}
}
}
/***** data *****/
namespace data {
/**
* An abstract reader class defines interface for data readers and has general functionality related to fetching data and reader events.
*/
class AbstractReader extends H.util.EventTarget {
/**
* Constructor
* @param opt_url {string=}
*/
constructor(opt_url?: string);
/**
* Method returns H.map.layer.ObjectLayer that contains parsed data, and can be added directly to the map. It returns new instance of the class with every invocation.
* If data hasn't been parsed it will return H.map.layer.ObjectLayer that contains partial information, and reader will add new parsed objects to the layer's provider later on.
* @returns {H.map.layer.ObjectLayer}
*/
getLayer(): H.map.layer.ObjectLayer;
/**
* Method returns collection of currently parsed, and converted to H.map.Object data objects. Method returns only currently parsed objects if parsing is ongoing.
* @returns {Array<H.map.Object>}
*/
getParsedObjects(): H.map.Object[];
/**
* Returns URL of the current file, which is either in process of fetching/parsing or file that has been already parsed.
* @returns {(string | undefined)} - url
*/
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
getUrl(): string | void;
/**
* Method sets reader's URL. Method resets current Reader's state to its initial values (clears data about last parsed objects, etc.), and throws
* InvalidState exception if Reader's state is not READY or ERROR.
* @param url {string} - The new URL
* @returns {H.data.AbstractReader}
*/
setUrl(url: string): H.data.AbstractReader;
/**
* Returns the reader's processing state for possible states see H.data.AbstractReader.State
* @returns {H.data.AbstractReader.State}
*/
getState(): H.data.AbstractReader.State;
/**
* Method launches parsing of the data file at the current url (see H.data.AbstractReader#setUrl or H.data.AbstractReader).
* Method uses XHR as a transport therefore same origin policy applies, or server should respond with proper CORS headers.
*/
parse(): void;
}
namespace AbstractReader {
/**
* The event class for state events that are dispatched by AbstractReader
*/
class Event extends H.util.Event {
/**
* Constructor
* @param target {(H.data.AbstractReader | H.map.Object)} - The target that's passed to event listeners
* @param type {string} - The type of the event
* @param state {H.data.AbstractReader.State} - The state of the target firing an event
* @param message {string} - The message associated with an event
*/
constructor(
target: H.data.AbstractReader | H.map.Object,
type: string,
state: H.data.AbstractReader.State,
message: string,
);
}
/**
* The state types of an Reader. Possible states are:
*/
enum State {
ERROR,
LOADING,
VISIT,
READY,
}
}
/**
* This namespace provides GeoJSON functionality.
*/
namespace geojson {
/**
* This class represents a GeoJSON reader responsible for fetching and interpreting GeoJSON data.
* It creates an instance of H.map.Object that can be displayed on the map (for more details see GeoJSON documentation {@link https://geojson.org}).
* Auxiliary data that accompanies geometries (the contents of the field properties) is bound to the map object and
* can be fetched with the method getData() on that object. See H.map.Object#getData.
* Note that you can load a GeoJSON file even from a different domain, if that domain supports Cross-Origin Resource Sharing.
*/
class Reader extends H.data.AbstractReader {
/**
* Constructor
* @param opt_url {string=}
* @param opt_options {H.data.geojson.Reader.Options=}
*/
constructor(opt_url?: string, opt_options?: H.data.geojson.Reader.Options);
/**
* This method launches the parsing process on the provided data.
* @param data {*=} A string or object containing the data to parse
*/
parseData(data: any): void;
}
namespace Reader {
/**
* This type encapsulates configuration (initialization) properties for a H.data.geojson.Reader.
* style {Function=} - The optional URL of the data file.
* disableLegacyMode {boolean=} - An object providing additional reader configuration parameters.
*/
interface Options {
style?: ((mapObject: H.map.Object) => void) | undefined;
disableLegacyMode?: boolean | undefined;
}
}
}
}
/***** geo *****/
namespace geo {
/**
* The base class for all geometry types.
*/
class AbstractGeometry {
/**
* Returns the bounding rectangle of the geometry.
* @return {H.geo.Rect} - the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates)
*/
getBoundingBox(): H.geo.Rect;
/**
* Checks whether the geometry is equal to the geometry supplied by the caller.
* Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.
* @param other {any} - The geometry to check against
* @return {boolean} - true if the two geometries are equal, otherwise false
*/
equals(other: any): boolean;
/**
* To obtain a Well-Known-Text (WKT) representation of the geometry.
* @return {string} - the resulting WKT string
*/
toString(): string;
/**
* To obtain a GeoJSON representation of the given geometry.
* @return {object} - A GeoJSON Geometry object representing the given geometry.
*/
toGeoJSON(): object;
}
/**
* A Geographic coordinate that specifies the height of a point in meters. A value of undefined is treated as 0.
*/
type Altitude = number;
/**
* Contexts for altitudes to specify the contextual origin of an altitude's value
*/
enum AltitudeContext {
/** Ground level */
undefined,
/** Ground level */
GL,
/** Obstruction level */
OL,
/** Mean sea level */
SL,
/** Sea bed level */
SB,
/** WGS84 ellipsoid */
WE,
/** WGS84 geoid */
WG,
}
/**
* An interface to represent a geographic point. Every point in geo space is represented by three coordinates latitude, longitude and optional altitude.
* lat {H.geo.Latitude} - The latitude coordinate.
* lng {H.geo.Longitude} - The longitude coordinate.
* alt {H.geo.Altitude=} - The altitude coordinate.
* ctx {H.geo.AltitudeContext=} - The altitude context.
*/
interface IPoint {
lat: H.geo.Latitude;
lng: Longitude;
alt?: H.geo.Altitude | undefined;
ctx?: H.geo.AltitudeContext | undefined;
}
interface IProjection {
latLngToPoint(lat: number, lng: number, opt_out?: H.math.Point): H.math.Point;
xyToGeo(x: number, y: number, opt_out?: H.geo.Point): H.geo.Point;
pointToGeo(point: H.math.IPoint, opt_out?: H.geo.Point): H.geo.Point;
geoToPoint(geoPoint: H.geo.IPoint, opt_out?: H.math.Point): H.math.Point;
}
/**
* A geographic coordinate that specifies the north-south position of a point on the Earth's surface in the range from -90 to + 90 degrees, inclusive.
*/
type Latitude = number;
/**
* A Geographic coordinate that specifies the east-west position of a point on the Earth's surface in the range from -180 to 180 degrees, inclusive.
*/
type Longitude = number;
class LineString extends H.geo.AbstractGeometry {
/**
* Constructor
* @param opt_latLngAlts {number[]=} - An optional array of latitude, longitude and altitude triples to initialize the LineString with.
* @param opt_ctx {H.geo.AltitudeContext=} - An optional altitude context for all altitudes contained in this LineString.
* @throws {H.lang.InvalidArgumentError} - in case of invalid lat, lng, alt values
*/
constructor(opt_latLngAlts?: number[], opt_ctx?: H.geo.AltitudeContext);
/**
* Decodes the specified Flexible Polyline and converts it to the LineString.
*
* @param encodedPolyline {string}
* @throws {Error} - if the specified data has an invalid encoding.
* @throws {H.lang.InvalidArgumentError} - if the third dimension type is other then ABSENT or ALTITUDE
*/
static fromFlexiblePolyline(encodedPolyline: string): LineString;
/**
* This method pushes a lat, lng, alt to the end of this LineString.
* @param lat {H.geo.Latitude}
* @param lng {H.geo.Longitude}
* @param alt {H.geo.Altitude}
* @throws {H.lang.InvalidArgumentError} - in case of invalid lat, lng, alt value
*/
pushLatLngAlt(lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude): void;
/**
* This method splices the LineString at the provided index, removing the specified number of items at that index and inserting the lat, lng, alt array.
* @param index {number} - The index at which to splice
* @param opt_nRemove {number=} - The number of lat, lng, alt values to remove
* @param opt_latLngAlts {number[]=} - The lat, lng, alt values to add
* @return {number[]} - An array of removed elements
* @throws {H.lang.InvalidArgumentError} - in case of invalid opt_latLngAlts argument
*/
spliceLatLngAlts(index: number, opt_nRemove?: number, opt_latLngAlts?: number[]): number[];
/**
* This method inserts one set of lat, lng, alt values into the LineString at the specified index.
* @param index {number} - the index at which to add the element
* @param lat {H.geo.Latitude} - the latitude to insert
* @param lng {H.geo.Longitude} - the longitude to insert
* @param alt {H.geo.Altitude} - the altitude to insert
*/
insertLatLngAlt(index: number, lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude): void;
/**
* This method removes one set of lat, lng, alt values from the LineString at the specified index
* @param index {number}
*/
removeLatLngAlt(index: number): void;
/**
* This method pushes the lat, lng, alt values of a {H.geo.Point} to the end of this LineString.
* @param geoPoint {H.geo.IPoint}
* @throws {H.lang.InvalidArgumentError} - in case of invalid geoPoint argument
*/
pushPoint(geoPoint: H.geo.IPoint): void;
/**
* This method inserts the lat, lng, alt values of a H.geo.Point into the list at the specified index.
* @param pointIndex {number}
* @param geoPoint {H.geo.IPoint}
*/
insertPoint(pointIndex: number, geoPoint: H.geo.IPoint): void;
/**
* This method removes one set of lat, lng, alt values from this LineString at the virtual point index specified.
* @param pointIndex {number} - the virtual point index
*/
removePoint(pointIndex: number): void;
/**
* This method extracts a H.geo.Point from this LineString at the virtual point index.
* If the extracted point has an alt value, the LineString's altitude context will be supplied to the point.
* @param pointIndex {number} - the virtual point index in the LineString
* @param opt_out {H.geo.Point=} - an optional point object to store the lat, lng, alt values
* @return {H.geo.Point} - Returns either the 'opt_out' point object or a new point object.
*/
extractPoint(pointIndex: number, opt_out?: H.geo.Point): H.geo.Point;
/**
* A utility method to iterate over the points of a line string.
* @param eachFn {function(lat, lng, alt, index)} - The function to invoke for every point. It gets the point's latitude, longitude, altitude and index as arguments.
* @param opt_start {number=} - The point's start index (inclusive) to iterate from, defaults to 0.
* @param opt_end {number=} - The point's end index (exclusive) to iterate to, defaults to Infinity.
*/
eachLatLngAlt(
eachFn: (lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude, index: number) => void,
opt_start?: number,
opt_end?: number,
): void;
/**
* To obtain whether a leg (formed by the given two longitudes) crosses the International Date Line.
* @param lng1 {H.geo.Longitude} - The start longitude of the leg
* @param lng2 {H.geo.Longitude} - The end longitude of the leg
* @return {boolean}
*/
static isDBC(lng1: H.geo.Longitude, lng2: H.geo.Longitude): boolean;
/**
* To obtain the number of times that this LineString cross the International Date Line.
* @param opt_asClosed {boolean=} - Indicates whether the LineString is treated as closed (the LineString's last and first coordinates form the closing leg of a polygon).
* It defaults to false.
* @return {number}
*/
getDBCs(opt_asClosed?: boolean): number;
/**
* This method return the number of points stored in this LineString.
* @return {number} - The number of points in this LineString
*/
getPointCount(): number;
/**
* Returns the vertices of the line segments as an array of alternating latitude, longitude and altitude coordinates.
* The returned array must be treated as read-only to not violate the integrity of the line-string.
* @return {number[]} - Returns the raw lat, lng, alt values of this LineString
*/
getLatLngAltArray(): number[];
/**
* This method returns the bounding box of this LineString.
* Note: The LineString is treated as an open path. If the bounding rectangle for a closed shape is required, the closing leg must be merged in an extra step.
* @return {H.geo.Rect} - This LineString's bounding rectangle
*/
getBounds(): H.geo.Rect;
/**
* This method initializes a new LineString with an array of lat, lng values. Arrays are expected to have an even length with the format [lat, lng, lat, lng, ...].
* @param latLngs {number[]} - the array of lat, lng value.
* @return {H.geo.LineString} - The LineString containing the lat, lng values
* @throws {H.lang.InvalidArgumentError} - throws an error in case the latLngs array has an odd length
*/
static fromLatLngArray(latLngs: number[]): H.geo.LineString;
/**
* Checks whether the geometry is equal to the geometry supplied by the caller.
* Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.
* @param other {any} - The geometry to check against
* @return {boolean} - true if the two geometries are equal, otherwise false
*/
equals(other: any): boolean;
/**
* To obtain a Well-Known-Text (WKT) representation of the geometry.
* @return {string} - the resulting WKT string
*/
toString(): string;