import type { MapSeries } from "./MapSeries"; import type { GeoProjection, GeoPath, GeoRawProjection } from "d3-geo"; import type { IPoint } from "../../core/util/IPoint"; import type { IGeoPoint } from "../../core/util/IGeoPoint"; import type { Time } from "../../core/util/Animation"; import type { ZoomControl } from "./ZoomControl"; import type { Animation } from "../../core/util/Entity"; import type { DataItem } from "../../core/render/Component"; import type { IMapPolygonSeriesDataItem } from "./MapPolygonSeries"; import { SerialChart, ISerialChartPrivate, ISerialChartSettings, ISerialChartEvents } from "../../core/render/SerialChart"; import { Rectangle } from "../../core/render/Rectangle"; import type { IDisposer } from "../../core/util/Disposer"; import type { ISpritePointerEvent } from "../../core/render/Sprite"; /** * Projections that [[MapChart]]'s `projectionName` can name. `am5map` registers * its bundled projections here; add others with `registerProjection()`. */ export declare const projectionRegistry: { [name: string]: () => GeoProjection; }; /** * Wraps a projection factory so the projections it makes carry `name`, which * lets `ChartSerializer` write `projectionName` for a chart that sets * `projection` in code. */ export declare function tagProjection(name: string, factory: () => GeoProjection): () => GeoProjection; /** * Registers a projection factory under `name`, for [[MapChart]]'s * `projectionName`. * * Returns the factory tagged with the name: a chart given `projection: cc()`, * where `const cc = registerProjection("geoConicConformal", geoConicConformal)`, * serializes with its `projectionName`, as the bundled projections do. */ export declare function registerProjection(name: string, factory: () => GeoProjection): () => GeoProjection; export interface IMapChartSettings extends ISerialChartSettings { /** * The projection the map is drawn with, such as `am5map.geoMercator()`. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/#Projections} for more info */ projection?: GeoProjection; /** * The projection by name, such as `"geoOrthographic"`: the chart sets * `projection` to it. Useful in JSON configs, which can't hold a function. * * The names `"geoMercator"`, `"geoOrthographic"`, `"geoEquirectangular"`, * `"geoAlbersUsa"`, `"geoEqualEarth"` and `"geoNaturalEarth1"` work out of * the box. Register any other projection once, before creating the chart: * * ```TypeScript * import { geoConicConformal } from "d3-geo"; * am5map.registerProjection("geoConicConformal", geoConicConformal); * ``` * ```JavaScript * am5map.registerProjection("geoConicConformal", d3.geoConicConformal); * ``` * * @since 5.19.0 */ projectionName?: string; /** * The map's zoom level: `1` shows the whole map fitted to the chart, `2` * shows it twice as large. * * @default 1 */ zoomLevel?: number; /** * Horizontal position of the projection's center, in pixels from the left * of the map's area. Changes as the map is panned. */ translateX?: number; /** * Vertical position of the projection's center, in pixels from the top of * the map's area. Changes as the map is panned. */ translateY?: number; /** * Tilts the map north or south, in degrees: the latitude `-rotationY` * comes to the middle, so `-30` centers latitude 30. Needs a projection * that can rotate. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/#Centering_the_map} for more info * @default 0 */ rotationY?: number; /** * Turns the map around the poles, in degrees: the longitude `-rotationX` * comes to the middle, so `-74` centers longitude 74. Needs a projection * that can rotate. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/#Centering_the_map} for more info * @default 0 */ rotationX?: number; /** * Spins the map around its middle, in degrees. Needs a projection that can * rotate. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/#Centering_the_map} for more info * @default 0 */ rotationZ?: number; /** * The highest zoom level the map can zoom in to. * * @default 32 */ maxZoomLevel?: number; /** * The lowest zoom level the map can zoom out to. * * @default 1 */ minZoomLevel?: number; /** * How many times one zoom step zooms in or out: the zoom level is multiplied * or divided by it. Used by [[ZoomControl]], the wheel, double clicks, * `zoomIn()` and `zoomOut()`. * * @default 2 */ zoomStep?: number; /** * What dragging the map horizontally does: `"translateX"` moves it, * `"rotateX"` turns it around the poles (as on a globe), `"none"` nothing. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Panning} for more info * @default "translateX" */ panX?: "none" | "rotateX" | "translateX"; /** * What dragging the map vertically does: `"translateY"` moves it, * `"rotateY"` tilts it north or south (as on a globe), `"none"` nothing. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Panning} for more info * @default "translateY" */ panY?: "none" | "rotateY" | "translateY"; /** * Lets users zoom the map with a two-finger pinch on touch devices. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Pinch_zoom} for more info * @default true */ pinchZoom?: boolean; /** * What scrolling horizontally (with a tilting wheel or a touchpad) does to * the map. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Mouse_wheel_behavior} for more info * @default "none" */ wheelX?: "none" | "zoom" | "rotateX" | "rotateY"; /** * What turning the mouse wheel does to the map. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Mouse_wheel_behavior} for more info * @default "zoom" */ wheelY?: "none" | "zoom" | "rotateX" | "rotateY"; /** * Multiplies how far the wheel rotates the map. Applies only to the * `"rotateX"` and `"rotateY"` wheel actions. * * @default 1 */ wheelSensitivity?: number; /** * Duration of the rotation a wheel turn makes, in milliseconds. Applies * only to the `"rotateX"` and `"rotateY"` wheel actions. * * @default 0 */ wheelDuration?: number; /** * Easing of the rotation a wheel turn makes. Applies only to the * `"rotateX"` and `"rotateY"` wheel actions. * * @see {@link https://www.amcharts.com/docs/v5/concepts/animations/#Easing_functions} for more info * @default am5.ease.out(am5.ease.cubic) */ wheelEasing?: (t: Time) => Time; /** * Duration of zoom and rotation animations, in milliseconds: zooming with * the wheel, buttons or a double click, and the zoom and rotate methods. */ animationDuration?: number; /** * Easing of zoom and rotation animations. * * @see {@link https://www.amcharts.com/docs/v5/concepts/animations/#Easing_functions} for more info * @default am5.ease.out(am5.ease.cubic) */ animationEasing?: (t: Time) => Time; /** * Zoom buttons to show on the map. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/#Zoom_control} for more info */ zoomControl?: ZoomControl; /** * Zoom level of the home position, which `goHome()` and `autoHome` go to. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Initial_position_and_zoom} for more info * @default 1 */ homeZoomLevel?: number; /** * `rotationX` of the home position, which `goHome()` and `autoHome` go to. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Initial_position_and_zoom} for more info */ homeRotationX?: number; /** * `rotationY` of the home position, which `goHome()` and `autoHome` go to. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Initial_position_and_zoom} for more info */ homeRotationY?: number; /** * The point `goHome()` and `autoHome` center the map on. If not set, the * middle of the map is used. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Initial_position_and_zoom} for more info */ homeGeoPoint?: IGeoPoint; /** * Goes to the home position once the map is loaded, as `goHome()` does: * animated when `animationDuration` is set (as by the Animated theme), at * once otherwise. * * @default false * @since 5.21.0 */ autoHome?: boolean; /** * How far the map can be dragged away from the middle, as a share of its * size: `0.4` lets its center move 40% of the map's width or height. A map * zoomed larger than the chart can always be dragged to its edges. * * @default 0.4 * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Panning_outside_viewport} for more info */ maxPanOut?: number; /** * Centers the map on its home point (`homeGeoPoint`, or the middle of the * map) whenever it zooms to `homeZoomLevel`, such as when fully zoomed out. * Otherwise zooming out keeps the point under the pointer, or the middle of * the view, in place. * * @default true * @since 5.2.1 */ centerMapOnZoomOut?: boolean; /** * Zooms the map in by `zoomStep` on a double click or double tap, and out * on Shift + double click. * * On a map panned by rotating (`panX: "rotateX"` or `panY: "rotateY"`), the * clicked location turns to the middle. Otherwise it stays under the * pointer. * * @default true * @since 5.20.2 */ doubleClickZoom?: boolean; /** * Zooms the map to a box drawn with the pointer, while this key is held: * `"drag"` needs no key. A plain drag pans the map, so use `"drag"` with * `panX` and `panY` set to `"none"`. * * The box is drawn with `boxZoomSelection`. * * @default "none" * @since 5.20.2 */ boxZoom?: "none" | "drag" | "shift" | "ctrl" | "alt"; } export interface IMapChartPrivate extends ISerialChartPrivate { /** * @ignore */ geoPath: GeoPath; /** * @ignore */ mapScale: number; /** * @ignore */ projectionBlend?: number; } export interface IMapChartEvents extends ISerialChartEvents { /** * The geographic bounds of the map's geometries changed, as when series * load their data. */ geoboundschanged: {}; } /** * A map: geographic data drawn in a projection, which can be zoomed, panned * and rotated. Its series draw polygons, lines and points. */ export declare class MapChart extends SerialChart { static className: string; static classNames: Array; _settings: IMapChartSettings; _privateSettings: IMapChartPrivate; _seriesType: MapSeries; _events: IMapChartEvents; protected _downTranslateX: number | undefined; protected _downTranslateY: number | undefined; protected _downRotationX: number | undefined; protected _downRotationY: number | undefined; protected _downRotationZ: number | undefined; protected _pLat: number; protected _pLon: number; protected _movePoints: { [index: number]: IPoint; }; protected _downZoomLevel: number; protected _doubleDownDistance: number; /** * The box drawn while zooming with `boxZoom`. * * @since 5.20.2 */ readonly boxZoomSelection: Rectangle; protected _boxDownPoint: IPoint | undefined; protected _panSuspended: boolean; protected _suspendedPanX: "none" | "rotateX" | "translateX" | undefined; protected _suspendedPanY: "none" | "rotateY" | "translateY" | undefined; protected _dirtyGeometries: boolean; protected _geometryColection: GeoJSON.GeometryCollection; _centerLocation: [number, number] | null; protected _za?: Animation; protected _rxa?: Animation; protected _rya?: Animation; protected _txa?: Animation; protected _tya?: Animation; protected _mapBounds: number[][]; protected _geoCentroid: IGeoPoint; protected _geoBounds: { left: number; right: number; top: number; bottom: number; }; protected _prevGeoBounds: { left: number; right: number; top: number; bottom: number; }; protected _dispatchBounds: boolean; protected _wheelDp: IDisposer | undefined; protected _pw?: number; protected _ph?: number; protected _mapFitted: boolean; protected _fitted: boolean; protected _goHomeOnFit?: { duration?: number; }; protected _homeScheduled: boolean; protected _homeTarget?: { view: Array; animations: Array | undefined>; duration?: number; }; protected _zoomAlert?: IDisposer; protected _silentZoom: boolean; protected _centerX: number; protected _centerY: number; protected _projectionRaw?: GeoRawProjection; protected _appliedProjectionName?: string; protected _projectionBlendAnim?: Animation; protected _projectionBlendData?: { blended: GeoProjection; mutate: Function; sourceScale: number; targetScale: number; sourceTranslateX: number; sourceTranslateY: number; targetTranslateX: number; targetTranslateY: number; target: GeoProjection; targetRaw: GeoRawProjection; }; protected _makeGeoPath(): void; /** * Returns the geographic point in the middle of the view. To come back to * the view later: `chart.zoomToGeoPoint(geoPoint, zoomLevel, true)`. * * @since 5.2.19 */ geoPoint(): IGeoPoint; /** * Returns the geographic center of the map's geometries. */ geoCentroid(): IGeoPoint; /** * Returns the geographic bounds of the map's geometries, in degrees: * longitudes `left` and `right`, latitudes `top` and `bottom`. */ geoBounds(): { left: number; right: number; top: number; bottom: number; }; protected _handleSetWheel(): void; protected _handleDoubleClick(event: ISpritePointerEvent): void; /** * Zooms to a point on the screen, rotating the map so that the point ends up * in the center of it, if the map is panned by rotating. */ protected _zoomToScreenPoint(point: IPoint, level: number): void; protected _isBoxZoomEvent(event: ISpritePointerEvent): boolean; protected _handleBoxDown(event: ISpritePointerEvent): void; protected _handleBoxMove(event: ISpritePointerEvent): void; protected _handleBoxUp(event: ISpritePointerEvent): void; protected _endBoxZoom(): void; protected _drawBoxSelection(point: IPoint): void; _prepareChildren(): void; protected _processSeries(series: this["_seriesType"]): void; protected _focusViewTimeout?: IDisposer; /** * @ignore */ _scheduleFocusView(): void; protected _updateFocusView(): void; protected _applyZoom(): void; protected _fitMap(): void; /** * Returns the point `goHome()` centers on: `homeGeoPoint` if set, otherwise * the middle of the map fitted to the chart at the home rotation, whatever * the current view. */ homeGeoPoint(): IGeoPoint; protected _homeRotation(): [number, number]; protected _view(): Array; protected _isGoingHome(): boolean; protected _scheduleHome(duration?: number): void; /** * Zooms and moves the map to its home position: `homeZoomLevel`, * `homeGeoPoint`, and `homeRotationX` and `homeRotationY` if set. Called * before the map is loaded, it goes there once it is. * * @see {@link https://www.amcharts.com/docs/v5/charts/map-chart/map-pan-zoom/#Resetting_position_level} for more info * @param duration Animation duration in milliseconds; `animationDuration` if not set */ goHome(duration?: number): void; _updateChildren(): void; _afterChanged(): void; protected _setUpTouch(): void; /** * @ignore */ markDirtyGeometries(): void; /** * @ignore */ markDirtyProjection(): void; protected _afterNew(): void; protected _handleChartDown(event: ISpritePointerEvent): void; /** * Converts a point on the map to geographic coordinates. A point with no * location, such as one off a globe, gives longitude and latitude `0`. * * @param point Point in pixels, relative to the map's area (the chart inside its padding) * @return Geographic coordinates */ invert(point: IPoint): IGeoPoint; /** * Converts geographic coordinates to a point on the map. Given one rotation * only, it takes the other, and `rotationZ`, as `0`. * * @param point Geographic coordinates * @param rotationX `rotationX` to convert at instead of the current rotation * @param rotationY `rotationY` to convert at instead of the current rotation * * @return Point in pixels, relative to the map's area (the chart inside its padding) */ convert(point: IGeoPoint, rotationX?: number, rotationY?: number): IPoint; protected _handleChartUp(_event: ISpritePointerEvent): void; protected _handlePinch(): void; protected _handleChartMove(event: ISpritePointerEvent): void; protected _handleWheelRotateY(delta: number, duration: number, easing: (t: Time) => Time): void; protected _handleWheelRotateX(delta: number, duration: number, easing: (t: Time) => Time): void; protected _handleWheelZoom(delta: number, point: IPoint): void; /** * Zooms the map to fit geographic bounds, with a 10% margin. Bounds whose * `right` is less than `left` take all longitudes. * * @param geoBounds Longitudes `left` and `right`, latitudes `top` and `bottom`, in degrees * @param duration Animation duration in milliseconds; `animationDuration` if not set * @param rotationX `rotationX` to end at * @param rotationY `rotationY` to end at * @return Zoom level animation */ zoomToGeoBounds(geoBounds: { left: number; right: number; top: number; bottom: number; }, duration?: number, rotationX?: number, rotationY?: number): Animation | undefined; /** * Zooms the map in or out at a point on it. With `centerMapOnZoomOut`, a * zoom to `homeZoomLevel` centers on the home point instead. * * @param point Point in pixels, relative to the map's area (the chart inside its padding) * @param level Zoom level, kept within `minZoomLevel` and `maxZoomLevel` * @param center Move the point to the middle; otherwise it stays where it is * @param duration Animation duration in milliseconds; `animationDuration` if not set * @return Zoom level animation */ zoomToPoint(point: IPoint, level: number, center?: boolean, duration?: number): Animation | undefined; protected _announceZoom(level: number): void; /** * Zooms the map in or out at a geographic point. * * @param geoPoint Geographic point * @param level Zoom level, kept within `minZoomLevel` and `maxZoomLevel` * @param center Move the point to the middle; otherwise it stays where it is * @param duration Animation duration in milliseconds; `animationDuration` if not set * @param rotationX `rotationX` to end at * @param rotationY `rotationY` to end at * @return Zoom level animation * */ zoomToGeoPoint(geoPoint: IGeoPoint, level: number, center?: boolean, duration?: number, rotationX?: number, rotationY?: number): Animation | undefined; /** * Rotates the map to the given angles, in degrees. Does nothing on a * projection that can't rotate. * * @param rotationX `rotationX` to end at; unchanged if not set * @param rotationY `rotationY` to end at; unchanged if not set * @param duration Animation duration in milliseconds; `animationDuration` if not set */ rotate(rotationX?: number, rotationY?: number, duration?: number): void; /** * Morphs the map from the current projection into `target`. * * d3-geo projections don't expose their raw functions, so pass `targetRaw` * along, and on the first call `sourceRaw` for the current projection; * later calls reuse the previous target's. Without a source raw function, * or with a zero duration, the projection switches at once. * * @param target Target projection (e.g. `geoOrthographic()`) * @param targetRaw Raw projection function (e.g. `geoOrthographicRaw`) * @param duration Duration in milliseconds (default: `animationDuration`) * @param easing Easing function (default: `animationEasing`) * @param sourceRaw Raw function of the current projection (needed on first call) * * @since 5.16.0 */ animateProjection(target: GeoProjection, targetRaw: GeoRawProjection, duration?: number, easing?: (t: Time) => Time, sourceRaw?: GeoRawProjection): void; /** * Zooms the map in by `zoomStep`, at the middle of the view. * * @return Zoom level animation */ zoomIn(): Animation | undefined; /** * Zooms the map out by `zoomStep`, at the middle of the view. * * @return Zoom level animation */ zoomOut(): Animation | undefined; _clearDirty(): void; /** * Returns the area a polygon takes on screen at the current zoom. * * @param dataItem Data item of a [[MapPolygonSeries]] * @return Area in square pixels */ getArea(dataItem: DataItem): number; } //# sourceMappingURL=MapChart.d.ts.map