import { TrafficControl, PoiControl, MapTypeControl } from "./controls"; import { MapBoxSKDOptionsModel, MapStyleNameType, CornerPositions, ControllerOptionsModel } from "../parameters/parameters"; import { AnyLayer, AnySourceData, Style, Map as customMap } from "mapbox-gl"; export type PoiTrafficTileType = "poi" | "traffic"; export type SetStyleOptionsModel = { diff?: boolean | undefined; localIdeographFontFamily?: string | undefined; }; /** * customized mapboxgl Map class * * @constructor */ export default class SDKMap extends customMap { _user_layers: Map; _user_sources: Map; /** * Object of maptypes with the same key and value */ static mapTypes: Readonly; /** * Constructor options */ static options: Readonly>; /** * Map Html Element */ get container(): HTMLElement; _mounted: boolean; /** * If map is loaded. */ get mounted(): boolean; /** * Array of functions that should run after the map is loaded. */ _onMountedCallbacks: Function[]; _isTouchPlatform: boolean; /** * Is it a touch platform or desktop? */ get isTouchPlatform(): boolean; /** * Updates class and controller shape after device type change. */ set isTouchPlatform(value: boolean); /** * Object of maps with their titles, images and styleNames. */ _mapTypeProperties: import("../parameters/parameters").MapTypesModel; _mapType: MapStyleNameType; /** * Current type of the map. */ get mapType(): MapStyleNameType; /** * Scale of everything on the map. (corresponds to font-size) */ _scale: number; _trafficLayer: boolean; /** * Traffic Layer Display Status */ get trafficLayer(): boolean; _poiLayer: boolean; /** * Poi Layer Display Status */ get poiLayer(): boolean; _poiControllerStatus: ControllerOptionsModel; /** * Poi Controller Display Status */ get poiControllerStatus(): ControllerOptionsModel; _trafficControllerStatus: ControllerOptionsModel; /** * Traffic Controller Display Status */ get trafficControllerStatus(): ControllerOptionsModel; /** * MapType Controller Display Status */ _mapTypeControllerStatus: ControllerOptionsModel; get mapTypeControllerStatus(): ControllerOptionsModel; _trafficControl: TrafficControl; _poiControl: PoiControl; _mapTypeControl: MapTypeControl; /** * Creates the map. * Sets the map type. * Sets the device type and the controllers based on that. * Scales the map if necessary. * Sets api keys to the localStorage. * @param options * @constructor * @extends mapboxgljs.Map */ constructor(options: MapBoxSKDOptionsModel); addSource(id: string, source: AnySourceData): this; removeSource(id: string): this; addLayer(layer: AnyLayer): this; removeLayer(id: string): this; /** * Sets type of displaying map * and handles what UI changes should take place afterward */ setStyle(style: Style | string, options?: SetStyleOptionsModel): this; setMapType(mapType?: MapStyleNameType, options?: SetStyleOptionsModel): void; getScale(): number; setScale(value: number): void; /** * Discover and record whether the device is a touch platform or not * @param {Boolean} value - if a manual value is desired. */ _updateDeviceType(value: boolean): void; /** * @returns Whether the device is a touch platform or not */ _getDeviceType(): boolean; /** * @param {Boolean} isTouch */ _updateMapTouchClass(isTouch: boolean): void; /** * Returns corresponding tile element for the given style * @param { MapStyleNameType } mapType * @returns { HTMLDivElement | null } */ _getStyleTile(mapType: MapStyleNameType): HTMLDivElement | null; /** * Sets "selected" class for selected style tile and removes it from the rest of the tiles. * @param { MapStyleNameType } mapType - Newly selected style */ _updateTilesSelectedClass(mapType?: MapStyleNameType): void; /** * If value is true, sets "selected" class * for traffic or poi tile * @param {PoiTrafficTileType} type * @param {Boolean} value */ _updatePoiTrafficTileSelectedClass(type: PoiTrafficTileType, value?: boolean): void; /** * Adds traffic control * @param {CornerPositions} position - Desired Position to add the control to. */ addTrafficControl(position: CornerPositions): void; /** * Removes the traffic control from map */ removeTrafficControl(): void; /** * Adds poi control * @param {CornerPositions} position - Desired Position to add the control to. */ addPoiControl(position: CornerPositions): void; /** * Removes the poi control from map */ removePoiControl(): void; /** * Adds map types switcher control * @param {CornerPositions} position - Desired Position to add the control to. */ addMapTypeControl(position: CornerPositions): void; /** * Removes the map types switcher control from map */ removeMapTypeControl(): void; /** * Toggles the traffic layer whether it should be displayed or not in case of not sending any value. * Or sets the traffic layer as what the sent value is. * @param {Boolean} value */ toggleTrafficLayer(value?: boolean): void; /** * Toggles the poi layer whether it should be displayed or not in case of not sending any value. * Or sets the poi layer as what the sent value is. * @param {Boolean} value */ togglePoiLayer(value?: boolean): void; /** * Changes map type switcher tile image and text, * based on corresponding style name, * for desktop view. * @param {MapStyleNameType } styleName */ setDesktopLayersTileProps(styleName?: MapStyleNameType): void; /** * handles how and whether map type switcher popup should be displayed or hidden, * based on given value and device type. * @param {Boolean} value */ toggleMapTypeSwitcherPopup(value?: boolean): void; /** * For desktop use purposes, we should know that where the popup should * be displayed to be inside of the map. * If you read the code, you might see a potential bug for some situations * as it does not take the horizontal gap between the tile and * the overlay into account. */ _setOverlayPositioning(): void; /** * Sets api keys to localstorage so then mapbox will use it to load tiles. * @param {string} mapKey - Contains mapKey */ _setApiKeys(mapKey: string): void; /** * Returns all layers with the given source name * @param {string} sourceName * @returns {AnyLayer[]} layers */ _getLayersBySourceName(sourceName: string): AnyLayer[]; /** * On the initialization, based on the given options, it handles which controlles should be displayed. * Poi and Traffic controllers are seperate controllers that the user could handle showing them but right now * implementation of this functionality is paused. * @param {*} options */ _handleInitialControllers(options?: Omit): void; /** * Sets the position and display status of traffic controller * @param {ControllerOptionsModel} trafficControllerOptions */ _handleInitialTrafficControllerOptions(trafficControllerOptions?: ControllerOptionsModel): void; /** * Sets the position and display status of poi controller * @param {ControllerOptionsModel} poiControllerOptions */ _handleInitialPoiControllerOptions(poiControllerOptions?: ControllerOptionsModel): void; /** * Sets the position and display status of map types switcher controller * @param {ControllerOptionsModel} mapTypeControllerOptions */ setMapTypeControlOptions(mapTypeControllerOptions?: ControllerOptionsModel): void; /** * What should happen on map's first load. */ _onMounted(): void; /** * Updates traffic and poi layer on map, usually because map needs it after a change in map style. * @param {Boolean} forceReFetch - whether to consider if the map is mounted so it doesn't lead to errors or ignore it and force re-fetch layers. */ _fetchPoiAndTrafficLayers(forceReFetch?: boolean): void; }