maplibre-gl-js-amplify
Version:
MapLibre Plugin to Support Amplify Geo Integration
38 lines (37 loc) • 2.04 kB
TypeScript
import { AWSCredentials } from '@aws-amplify/core/internals/utils';
import { Map as MaplibreMap, RequestParameters, MapOptions } from 'maplibre-gl';
/**
* The upgrade from maplibre v1 to maplibre v2 changed the `style` property from optional to required.
* We keep the property optional here since we default to the map name for the maplibre style field and
* it maintains backwards compatibility with the upgrade to maplibre v2.
*/
interface CreateMapOptions extends Omit<MapOptions, 'style'>, Partial<Pick<MapOptions, 'style'>> {
region?: string;
mapConstructor?: typeof MaplibreMap;
}
/**
* An object for encapsulating an Amplify Geo transform request and Amplify credentials
* @class AmplifyMapLibreRequest
* @param {ICredentials} currentCredentials Amplify credentials used for signing transformRequests
* @param {String} region AWS region
* @return {AmplifyMapLibreRequest} `this`
*
*/
export default class AmplifyMapLibreRequest {
credentials: AWSCredentials;
region: string;
activeTimeout: number;
constructor(currentCredentials: AWSCredentials, region: string);
static createMapLibreMap: (options: CreateMapOptions) => Promise<MaplibreMap>;
refreshCredentials: () => Promise<void>;
refreshCredentialsWithRetry: () => Promise<void>;
/**
* A callback function that can be passed to a maplibre map object that is run before the map makes a request for an external URL. This transform request is used to sign the request with AWS Sigv4 Auth. [https://maplibre.org/maplibre-gl-js-docs/api/map/](https://maplibre.org/maplibre-gl-js-docs/api/map/)
* @param {string} url
* @param {string} resourceType
* @returns {RequestParameters} [https://maplibre.org/maplibre-gl-js-docs/api/properties/#requestparameters](https://maplibre.org/maplibre-gl-js-docs/api/properties/#requestparameters)
*/
transformRequest: (url: string, resourceType: string) => RequestParameters;
}
export declare const createMap: (options: CreateMapOptions) => Promise<MaplibreMap>;
export {};