import Class from '../core/Class'; import Point from '../geo/Point'; import Size from '../geo/Size'; import PointExtent from '../geo/PointExtent'; import Extent, { ExtentLike } from '../geo/Extent'; import Coordinate from '../geo/Coordinate'; import Layer from '../layer/Layer'; import SpatialReference, { type SpatialReferenceType } from './spatial-reference/SpatialReference'; import { AnimationOptionsType, EasingType } from '../core/Animation'; import { Attribution } from '../control'; import { AttributionOptionsType } from '../control/Control.Attribution'; declare const Map_base: { new (...args: any[]): { _handlers?: import("..").Handler[]; addHandler(name: any, handlerClass: any): any; removeHandler(name: any): any; _clearHandlers(): void; }; } & { new (...args: any[]): { _eventMap?: Record; _eventParent?: any; _eventTarget?: any; on(eventsOn: string | import("../core/Eventable").EventRecords, handler: import("../core/Eventable").HandlerFn, context?: any): any; addEventListener(...args: any[]): any; once(eventTypes: string | import("../core/Eventable").EventRecords, handler: import("../core/Eventable").HandlerFn, context?: any): any; off(eventsOff: string | import("../core/Eventable").EventRecords, handler: import("../core/Eventable").HandlerFn, context?: any): any; removeEventListener(...args: any[]): any; listens(eventType: string, handler?: import("../core/Eventable").HandlerFn, context?: any): number; getListeningEvents(): string[]; copyEventListeners(target: any): any; fire(eventType: string, param?: import("../core/Eventable").BaseEventParamsType): any; _wrapOnceHandler(evtType: string, handler: import("../core/Eventable").HandlerFn, context?: any): (...args: any[]) => void; _switch(to: string, eventRecords: import("../core/Eventable").EventRecords, context?: any): any; _clearListeners(eventType: string): void; _clearAllListeners(): void; _setEventParent(parent: any): any; _setEventTarget(target: any): any; _fire(eventType: string, param: import("../core/Eventable").BaseEventParamsType): any; }; } & { new (...args: any[]): {}; registerRenderer(name: string, clazz: T): any & typeof Class; getRendererClass(name: string): Class; } & typeof Class; /** * The central class of the library, to create a map on a container. * * @category map * * @mixes Eventable * @mixes Handlerable * @mixes ui.Menuable * @mixes Renderable * * @example * var map = new maptalks.Map("map",{ * center: [180,0], * zoom: 4, * baseLayer : new maptalks.TileLayer("base",{ * urlTemplate:'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', * subdomains:['a','b','c'] * }), * layers : [ * new maptalks.VectorLayer('v', [new maptalks.Marker([180, 0])]) * ] * }); */ export declare class Map extends Map_base { VERSION: string; isMap: boolean; centerAltitude: number; width: number; height: number; CanvasClass: any; cameraCenterDistance: number; options: MapOptionsType; static VERSION: string; JSON_VERSION: '1.0'; attributionControl?: Attribution; id: number; /** * @param {(string|HTMLElement|object)} container - The container to create the map on, can be:
* 1. A HTMLElement container.
* 2. ID of a HTMLElement container.
* 3. Any canvas compatible container * @param {Object} options - construct options * @param {(Number[]|Coordinate)} options.center - initial center of the map. * @param {Number} options.zoom - initial zoom of the map. * @param {Object} [options.spatialReference=null] - map's spatial reference, default is using projection EPSG:3857 with resolutions used by google map/osm. * @param {Layer} [options.baseLayer=null] - base layer that will be set to map initially. * @param {Layer[]} [options.layers=null] - layers that will be added to map initially. * @param {*} options.* - any other option defined in [Map.options]{@link Map#options} [description] */ constructor(container: MapContainerType, options: MapCreateOptionsType); /** * Add hooks for additional codes when map's loading complete, useful for plugin developping. * Note that it can only be called before the map is created. * @param {Function | any} fn * @returns {Map} */ static addOnLoadHook(fn: string | ((...args: any[]) => void), ...args: any[]): typeof Map; /** * Whether the map is loaded or not. * @return {Boolean} */ isLoaded(): boolean; /** * Get map's container * @returns {HTMLElement} */ getContainer(): HTMLCanvasElement | HTMLDivElement; /** * Get the spatial reference of the Map. * @return {SpatialReference} map's spatial reference */ getSpatialReference(): SpatialReference; /** * Change the spatial reference of the map.
* A SpatialReference is a series of settings to decide the map presentation:
* 1. the projection.
* 2. zoom levels and resolutions.
* 3. full extent.
* There are some [predefined spatial references]{@link http://www.foo.com}, and surely you can [define a custom one.]{@link http://www.foo.com}.
* SpatialReference can also be updated by map.config('spatialReference', spatialReference); * @param {SpatialReference} spatialReference - spatial reference * @returns {Map} this * @fires Map#spatialreferencechange * @example * map.setSpatialReference({ projection:'EPSG:4326', resolutions: (function() { const resolutions = []; for (let i=0; i < 19; i++) { resolutions[i] = 180/(Math.pow(2, i)*128); } return resolutions; })() * }); @example * map.config('spatialReference', { projection:'EPSG:4326', resolutions: (function() { const resolutions = []; for (let i=0; i < 19; i++) { resolutions[i] = 180/(Math.pow(2, i)*128); } return resolutions; })() }); */ setSpatialReference(ref: SpatialReferenceType): this; /** * Callback when any option is updated * @param {Object} conf - options to update * @return {Map} this */ onConfig(conf: { [key: string]: any; }): this; /** * Get the projection of the map.
* Projection is an algorithm for map projection, e.g. well-known [Mercator Projection]{@link https://en.wikipedia.org/wiki/Mercator_projection}
* A projection must have 2 methods:
* 1. project(coordinate) - project the input coordinate
* 2. unproject(coordinate) - unproject the input coordinate
* Projection also contains measuring method usually extended from a measurer:
* 1. measureLength(coord1, coord2) - compute length between 2 coordinates.
* 2. measureArea(coords[]) - compute area of the input coordinates.
* 3. locate(coord, distx, disty) - compute the coordinate from the coord with xdist on axis x and ydist on axis y. * @return {Object} */ getProjection(): import("../geo/projection").ProjectionType; /** * Get map's full extent, which is defined in map's spatial reference.
* eg: {'left': -180, 'right' : 180, 'top' : 90, 'bottom' : -90} * @return {Extent} */ getFullExtent(): Extent; /** * Set map's cursor style, cursor style is same with CSS. * @param {String} cursor - cursor style * @returns {Map} this * @example * map.setCursor('url(cursor.png) 4 12, auto'); */ setCursor(cursor: string): this; /** * Reset map's cursor style. * @return {Map} this * @example * map.resetCursor(); */ resetCursor(): this; /** * Get center of the map. * @return {Coordinate} */ getCenter(): Coordinate; /** * Set a new center to the map. * @param {Coordinate} center * @param {Object} [padding] * @param {Number} [padding.paddingLeft] - Sets the amount of padding in the left of a map container * @param {Number} [padding.paddingTop] - Sets the amount of padding in the top of a map container * @param {Number} [padding.paddingRight] - Sets the amount of padding in the right of a map container * @param {Number} [padding.paddingBottom] - Sets the amount of padding in the bottom of a map container * @return {Map} this */ setCenter(center: Coordinate, padding?: MapPaddingType): this; /** * Get map's size (width and height) in pixel. * @return {Size} */ getSize(): Size; /** * Get container extent of the map * @return {PointExtent} */ getContainerExtent(): PointExtent; /** * get Ground Extent for sky ,line ,polygon 2d render clip etc * @return {PointExtent} */ getGroundExtent(): PointExtent; /** * Get the geographical extent of map's current view extent. * * @return {Extent} */ getExtent(): Extent; /** * Get the projected geographical extent of map's current view extent. * * @return {Extent} */ getProjExtent(): Extent; /** * Alias for getProjExtent * * @return {Extent} */ getPrjExtent(): Extent; /** * Get the max extent that the map is restricted to. * @return {Extent} */ getMaxExtent(): Extent; /** * Sets the max extent that the map is restricted to. * @param {Extent} * @return {Map} this * @example * map.setMaxExtent(map.getExtent()); */ setMaxExtent(extent: Extent): this; /** * Get map's current zoom. * @return {Number} */ getZoom(): number; /** * Caculate the target zoom if scaling from "fromZoom" by "scale" * @param {Number} scale * @param {Number} fromZoom * @param {Boolean} isFraction - can return fractional zoom * @return {Number} zoom fit for scale starting from fromZoom */ getZoomForScale(scale: number, fromZoom?: number, isFraction?: boolean): number; getZoomFromRes(res: number): number; /** * Sets zoom of the map * @param {Number} zoom * @param {Object} [options=null] options * @param {Boolean} [options.animation=true] whether zoom is animation, true by default * @returns {Map} this */ setZoom(zoom: number, options?: { animation: boolean; }): this; /** * Get the max zoom that the map can be zoom to. * @return {Number} */ getMaxZoom(): number; /** * Sets the max zoom that the map can be zoom to. * @param {Number} maxZoom * @returns {Map} this */ setMaxZoom(maxZoom: number): this; /** * Get the min zoom that the map can be zoom to. * @return {Number} */ getMinZoom(): number; /** * Sets the min zoom that the map can be zoom to. * @param {Number} minZoom * @return {Map} this */ setMinZoom(minZoom: number): this; /** * Maximum zoom the map has * @return {Number} */ getMaxNativeZoom(): number; /** * Resolution for world point in WebGL context * @returns {Number} */ getGLRes(): number; /** * Caculate scale from gl zoom to given zoom (default by current zoom) * @param {Number} [zoom=undefined] target zoom, current zoom by default * @returns {Number} * @examples * const point = map.coordToPoint(map.getCenter()); * // convert to point in gl zoom * const glPoint = point.multi(this.getGLScale()); */ getGLScale(zoom?: number): number; /** * zoom in * @return {Map} this */ zoomIn(): this; /** * zoom out * @return {Map} this */ zoomOut(): this; /** * Whether the map is zooming * @return {Boolean} */ isZooming(): boolean; /** * Whether the map is being interacted * @return {Boolean} */ isInteracting(): boolean; /** * Sets the center and zoom at the same time. * @param {Coordinate} center * @param {Number} zoom * @return {Map} this */ setCenterAndZoom(center: Coordinate, zoom?: number): this; /** * Caculate the zoom level that contains the given extent with the maximum zoom level possible. * @param {Extent} extent * @param {Boolean} [isFraction] - can return fractional zoom * @param {Object} [padding] [padding] - padding * @param {Object} [padding.paddingLeft] - Sets the amount of padding in the left of a map container * @param {Object} [padding.paddingTop] - Sets the amount of padding in the top of a map container * @param {Object} [padding.paddingRight] - Sets the amount of padding in the right of a map container * @param {Object} [padding.paddingBottom] - Sets the amount of padding in the bottom of a map container * @return {Number} zoom fit for scale starting from fromZoom */ getFitZoom(extent: Extent, isFraction?: boolean, padding?: MapPaddingType): number; /** * Get map's current view (center/zoom/pitch/bearing) * @return {Object} { center : *, zoom : *, pitch : *, bearing : * } */ getView(): MapViewType; stringifyView(): string; /** * Set map's center/zoom/pitch/bearing at one time * @param {Object} view - a object containing center/zoom/pitch/bearing * return {Map} this */ setView(view: MapViewType): this; /** * Get map's resolution * @param {Number} zoom - zoom or current zoom if not given * @return {Number} resolution */ getResolution(zoom?: number): number; /** * Get scale of resolutions from zoom to max zoom * @param {Number} zoom - zoom or current zoom if not given * @return {Number} scale */ getScale(zoom?: number): number; /** * Set the map to be fit for the given extent with the max zoom level possible. * @param {ExtentLike} extent - extent * @param {Number} zoomOffset - zoom offset * @param {Object} [options={}] - options * @param {Object} [options.animation] * @param {Object} [options.duration] * @param {Object} [options.zoomAnimationDuration] * @param {Object} [options.easing='out'] * @param {Number} [options.paddingLeft] - Sets the amount of padding in the left of a map container * @param {Number} [options.paddingTop] - Sets the amount of padding in the top of a map container * @param {Number} [options.paddingRight] - Sets the amount of padding in the right of a map container * @param {Number} [options.paddingBottom] - Sets the amount of padding in the bottom of a map container * @param {Boolean} [options.isFraction=false] - can locate to fractional zoom * @param {Function} step - step function for animation * @return {Map | player} - this */ fitExtent(extent: ExtentLike, zoomOffset?: number, options?: MapFitType, step?: (frame: any) => void): this | import("../core/Animation").Player; /** * Get the base layer of the map. * @return {Layer} */ getBaseLayer(): Layer; /** * Sets a new base layer to the map.
* Some events will be thrown such as baselayerchangestart, baselayerload, baselayerchangeend. * @param {Layer} baseLayer - new base layer * @return {Map} this * @fires Map#setbaselayer * @fires Map#baselayerchangestart * @fires Map#baselayerchangeend */ setBaseLayer(baseLayer: Layer): this; /** * Remove the base layer from the map * @return {Map} this * @fires Map#baselayerremove */ removeBaseLayer(): this; /** * Get the layers of the map, except base layer (which should be by getBaseLayer).
* A filter function can be given to filter layers, e.g. exclude all the VectorLayers. * @param {Function} [filter=undefined] - a filter function of layers, return false to exclude the given layer. * @return {Layer[]} * @example * var vectorLayers = map.getLayers(function (layer) { * return (layer instanceof VectorLayer); * }); */ getLayers(filter?: (layer: Layer) => boolean): Array; /** * Get the layer with the given id. * @param {String} id - layer id * @return {Layer} */ getLayer(id: string): Layer | null; /** * Add a new layer on the top of the map. * @param {Layer|Layer[]} layer - one or more layers to add * @return {Map} this * @fires Map#addlayer */ addLayer(layers: Layer | Array, ...otherLayers: Array): this; /** * Remove a layer from the map * @param {String|String[]|Layer|Layer[]} layer - one or more layers or layer ids * @return {Map} this * @fires Map#removelayer */ removeLayer(layers: Layer | Array): this; /** * Sort layers according to the order provided, the last will be on the top. * @param {string[]|Layer[]} layers - layers or layer ids to sort * @return {Map} this * @example * map.addLayer([layer1, layer2, layer3]); * map.sortLayers([layer2, layer3, layer1]); * map.sortLayers(['3', '2', '1']); // sort by layer ids. */ sortLayers(layers: Array): this; /** * Exports image from the map's canvas. * @param {Object} [options=undefined] - options * @param {String} [options.mimeType=image/png] - mime type of the image: image/png, image/jpeg, image/webp * @param {String} [options.quality=0.92] - A Number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp. * @param {Boolean} [options.save=false] - whether pop a file save dialog to save the export image. * @param {String} [options.fileName=export] - specify the file name, if options.save is true. * @return {String} image of base64 format. */ toDataURL(options?: MapDataURLType): string | null; /** * shorter alias for coordinateToPoint */ coordToPoint(coordinate: Coordinate, zoom?: number, out?: Point): Point; /** * shorter alias for coordinateToPointAtRes */ coordToPointAtRes(coordinate: Coordinate, res?: number, out?: Point): Point; /** * shorter alias for pointToCoordinate */ pointToCoord(point: Point, zoom?: number, out?: Coordinate): Coordinate; /** * shorter alias for pointAtResToCoordinate */ pointAtResToCoord(point: Point, res?: number, out?: Coordinate): Coordinate; /** * shorter alias for coordinateToViewPoint */ coordToViewPoint(coordinate: Coordinate, out?: Point, altitude?: number): Point; /** * shorter alias for viewPointToCoordinate */ viewPointToCoord(viewPoint: Point, out?: Coordinate): Coordinate; /** * shorter alias for coordinateToContainerPoint */ coordToContainerPoint(coordinate: Coordinate, zoom?: number, out?: Point): Point; /** * shorter alias for containerPointToCoordinate */ containerPointToCoord(containerPoint: Point, out?: Coordinate): Coordinate; /** * Converts a container point to the view point. * Usually used in plugin development. * @param {Point} * @param {Point} [out=undefined] - optional point to receive result * @returns {Point} */ containerPointToViewPoint(containerPoint: Point, out?: Point): Point; /** * Converts a view point to the container point. * Usually used in plugin development. * @param {Point} * @param {Point} [out=undefined] - optional point to receive result * @returns {Point} */ viewPointToContainerPoint(viewPoint: Point, out?: Point): Point; /** * Checks if the map container size changed and updates the map if so. * @return {Map} this * @fires Map#resize */ checkSize(force?: boolean): this; /** * Computes the coordinate from the given meter distance. * @param {Coordinate} coordinate - source coordinate * @param {Number} dx - meter distance on X axis * @param {Number} dy - meter distance on Y axis * @return {Coordinate} Result coordinate */ locate(coordinate: Coordinate, dx: number, dy: number): Coordinate; /** * Return map's main panel * @returns {HTMLElement} */ getMainPanel(): HTMLDivElement | null; /** * Returns map panels. * @return {Object} */ getPanels(): Record; /** * Remove the map * @return {Map} this */ remove(): this; /** * whether the map is removed * @return {Boolean} */ isRemoved(): boolean; /** * Whether the map is moving * @return {Boolean} */ isMoving(): boolean; /** * The callback function when move started * @private * @fires Map#movestart */ onMoveStart(param?: any): void; onMoving(param: any): void; onMoveEnd(param: any): void; onDragRotateStart(param: any): void; onDragRotating(param: any): void; onDragRotateEnd(param: any): void; isDragRotating(): boolean; /** * Test if given box is out of current screen * @param {Number[] | PointExtent} box - [minx, miny, maxx, maxy] * @param {Number} padding - test padding * @returns {Boolean} */ isOffscreen(box: PointExtent | Array, viewportPadding?: number): boolean; getRenderer(): any; /** * Get map's devicePixelRatio, you can override it by setting devicePixelRatio in options. * @returns {Number} */ getDevicePixelRatio(): number; /** * Set map's devicePixelRatio * @param {Number} dpr * @returns {Map} this */ setDevicePixelRatio(dpr: number): this; setContainerDomRect(domRect: DOMRect): void; /** * offset map panels. * * @param {Point} offset - offset in pixel to move * @return {Map} this */ /** * Gets map panel's current view point. * @return {Point} */ offsetPlatform(offset?: Point): Point; /** * Get map's view point, adding in frame offset * @return {Point} map view point */ getViewPoint(): Point; /** * Export the map's json, a snapshot of the map in JSON format.
* It can be used to reproduce the instance by [fromJSON]{@link Map#fromJSON} method * @param {Object} [options=null] - export options * @param {Boolean|Object} [options.baseLayer=null] - whether to export base layer's JSON, if yes, it will be used as layer's toJSON options. * @param {Boolean|Extent} [options.clipExtent=null] - if set with an extent instance, only the geometries intersectes with the extent will be exported. * If set to true, map's current extent will be used. * @param {Boolean|Object|Object[]} [options.layers=null] - whether to export other layers' JSON, if yes, it will be used as layer's toJSON options. * It can also be an array of layer export options with a "id" attribute to filter the layers to export. * @return {Object} layer's JSON */ toJSON(options?: MapOptionsType): { [key: string]: any; }; /** * Reproduce a map from map's profile JSON. * @param {(string|HTMLElement|object)} container - The container to create the map on, can be:
* 1. A HTMLElement container.
* 2. ID of a HTMLElement container.
* 3. A canvas compatible container in node, * e.g. [node-canvas]{@link https://github.com/Automattic/node-canvas}, * [canvas2svg]{@link https://github.com/gliffy/canvas2svg} * @param {Object} mapJSON - map's profile JSON * @param {Object} [options=null] - options * @param {Object} [options.baseLayer=null] - whether to import the baseLayer * @param {Object} [options.layers=null] - whether to import the layers * @return {Map} * @static * @function * @example * var map = Map.fromJSON('map', mapProfile); */ static fromJSON(container: MapContainerType, profile: { [key: string]: any; }, options?: MapOptionsType): Map; } export default Map; export type MapRendererType = 'canvas' | 'gl' | 'gpu'; export type MapOptionsType = { pitch?: number; bearing?: number; baseLayer?: Layer; layers?: Array; draggable?: boolean; dragPan?: boolean; dragPanEasing?: EasingType; dragRotate?: boolean; dragPitch?: boolean; dragRotatePitch?: boolean; touchGesture?: boolean; touchZoom?: boolean; touchRotate?: boolean; touchPitch?: boolean; touchZoomRotate?: boolean; doubleClickZoom?: boolean; scrollWheelZoom?: boolean; geometryEvents?: boolean; control?: boolean; attribution?: boolean | AttributionOptionsType; zoomControl?: boolean; scaleControl?: boolean; overviewControl?: boolean; fog?: boolean; fogColor?: any; devicePixelRatio?: number; heightFactor?: number; originLatitudeForAltitude?: number; viewHistory?: boolean; viewHistoryCount?: number; seamlessZoom?: boolean; maxVisualPitch?: number; maxPitch?: number; centerCross?: boolean; zoomable?: boolean; zoomInCenter?: boolean; zoomOrigin?: Array; zoomAnimation?: boolean; zoomAnimationDuration?: number; tileBackgroundLimitPerFrame?: number; panAnimation?: boolean; panAnimationDuration?: number; rotateAnimation?: boolean; rotateAnimationDuration?: number; enableInfoWindow?: boolean; hitDetect?: boolean; hitDetectLimit?: number; fpsOnInteracting?: number; layerCanvasLimitOnInteracting?: number; maxZoom?: number; minZoom?: number; maxExtent?: Extent; limitExtentOnMaxExtent?: boolean; fixCenterOnResize?: boolean; checkSize?: boolean; checkSizeInterval?: number; renderer?: MapRendererType | MapRendererType[]; cascadePitches?: Array; renderable?: boolean; clickTimeThreshold?: number; stopRenderOnOffscreen?: boolean; preventWheelScroll?: boolean; preventTouch?: boolean; supportPluginEvent?: boolean; switchDragButton?: boolean; mousemoveThrottleTime?: number; mousemoveThrottleEnable?: boolean; maxFPS?: number; debug?: boolean; spatialReference?: SpatialReferenceType; autoPanAtEdge?: boolean; boxZoom?: boolean; boxZoomSymbol?: { 'markerType': string; 'markerLineWidth': number; 'markerLineColor': string; 'markerLineDasharray': Array; 'markerFillOpacity': number; 'markerFill': string; 'markerWidth': number; 'markerHeight': number; }; onlyVisibleGeometryEvents?: boolean; compassControl?: boolean; layerSwitcherControl?: boolean; navControl?: boolean; resetControl?: boolean; cameraFarUndergroundInMeter?: number; onlyWebGL1?: boolean; preserveDrawingBuffer?: boolean; forceRedrawPerFrame?: boolean; extensions?: string[]; optionalExtensions?: string[]; cameraNearScale?: number; }; export type MapCreateOptionsType = { center: Array | Coordinate; zoom: number; } & MapOptionsType; export type MapPaddingType = { paddingLeft: number; paddingRight: number; paddingTop: number; paddingBottom: number; }; export type MapViewType = { center?: Array | Coordinate; zoom?: number; pitch?: number; bearing?: number; height?: number; around?: Point; prjCenter?: Array | Coordinate; }; export type MapFitType = { isFraction?: boolean; animation?: boolean; duration?: number; easing?: EasingType; } & MapPaddingType; export type MapDataURLType = { mimeType?: string; fileName?: string; quality?: number; save?: boolean; }; export type MapAnimationOptionsType = AnimationOptionsType & { counterclockwise?: boolean; continueOnViewChanged?: boolean; wheelZoom?: boolean; }; export type MapIdentifyOptionsType = { tolerance?: number; eventTypes?: Array; layers?: Array; count?: number; includeInvisible?: boolean; includeInternals?: boolean; }; export type MapContainerType = string | HTMLDivElement | HTMLCanvasElement | { [key: string]: any; }; export type PanelDom = (HTMLDivElement | HTMLElement) & { layerDOM: HTMLElement; uiDOM: HTMLElement; }; export declare function mapViewEqual(view1: MapViewType, view2: MapViewType, strict?: boolean): boolean; //# sourceMappingURL=Map.d.ts.map