Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@2gis/mapgl

Package Overview
Dependencies
Maintainers
9
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@2gis/mapgl - npm Package Compare versions

Comparing version
1.73.0
to
1.74.0
+10
-1
dist/index.d.ts
import * as mapgl from '../types';
export declare function load(mapglURL?: string): Promise<typeof mapgl>;
/**
* Loads mapgl script and returns library instance - mapgl
* object. Also emits it on window as `window.mapgl`.
*
* @param mapglURL - MapGL script URL (default is https://mapgl.2gis.com/api/js)
* @param integrity - Optional SRI hash. Use only with fixed versions of mapgl!
* Usage SRI with latest version will break your app.
* @returns Promise<mapgl> - mapgl libary instance
*/
export declare function load(mapglURL?: string, integrity?: string): Promise<typeof mapgl>;
+24
-8
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.load = void 0;
var map;
function load(mapglURL) {
var cachedMapGl;
/**
* Loads mapgl script and returns library instance - mapgl
* object. Also emits it on window as `window.mapgl`.
*
* @param mapglURL - MapGL script URL (default is https://mapgl.2gis.com/api/js)
* @param integrity - Optional SRI hash. Use only with fixed versions of mapgl!
* Usage SRI with latest version will break your app.
* @returns Promise<mapgl> - mapgl libary instance
*/
function load(mapglURL, integrity) {
if (mapglURL === void 0) { mapglURL = 'https://mapgl.2gis.com/api/js'; }

@@ -10,12 +19,16 @@ if (typeof window === 'undefined') {

}
if (map) {
return Promise.resolve(map);
if (cachedMapGl) {
return Promise.resolve(cachedMapGl);
}
return createScriptAndLoad(mapglURL).then(function () {
map = window.mapgl;
return map;
return createScriptAndLoad(mapglURL, integrity).then(function () {
var loadedMapGl = window.mapgl;
if (!loadedMapGl) {
return Promise.reject(new Error('Failed to load MapGl script (window.mapgl not set after script loading)'));
}
cachedMapGl = loadedMapGl;
return cachedMapGl;
});
}
exports.load = load;
function createScriptAndLoad(mapglURL) {
function createScriptAndLoad(mapglURL, integrity) {
return new Promise(function (resolve, reject) {

@@ -27,2 +40,5 @@ // Create script element and set attributes

script.crossOrigin = 'anonymous';
if (integrity) {
script.integrity = integrity;
}
script.src = mapglURL;

@@ -29,0 +45,0 @@ // Append the script to the DOM

{
"name": "@2gis/mapgl",
"version": "1.73.0",
"version": "1.74.0",
"description": "MapGL API script loader with typings",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -106,2 +106,6 @@ import type { Style } from './styles';

/**
* Emitted when the user moves the finger across the map.
*/
touchmove: MapPointerEvent;
/**
* Emitted when the map becomes idle after some interaction (drag, zoom etc).

@@ -209,2 +213,6 @@ * Idle means that the map is not interacting, all tiles are drawn and labeling is finished.

touchend: DynamicObjectPointerEvent<T>;
/**
* Emitted when the user moves the finger across the marker.
*/
touchmove: DynamicObjectPointerEvent<T>;
}

@@ -211,0 +219,0 @@ /**