
Product
Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.
@2gis/mapgl
Advanced tools
Async loader for 2gis MapGL API with typings.
Browser usage only!
$ npm install @2gis/mapgl
import { load } from '@2gis/mapgl';
// or const { load } = require('@2gis/mapgl');
async function start() {
const mapglAPI = await load();
// container — id of the div element in your html
const map = new mapglAPI.Map('container', {
center: [55.31878, 25.23584],
zoom: 13,
key: 'Your API access key',
});
const marker = new mapglAPI.Marker(map, {
coordinates: [55.31878, 25.23584],
});
}
start();
Without await/async:
load().then((mapglAPI) => {
const map = new mapglAPI.Map('container', {
center: [55.31878, 25.23584],
zoom: 13,
key: 'Your API access key',
});
});
By default, latest version of MapGL API will be loaded (https://mapgl.2gis.com/api/js). But you can specify certain version of MapGL API to load:
load('https://mapgl.2gis.com/api/js/v1.4.2').then((mapglAPI) => {});
Checkout our release notes for MapGL API. Important to note, mapgl loader version is not equal to MapGL API version, cause it has its own features.
@2gis/mapgl exports load function and global.d.ts file which you can reference to have access to mapgl typings.
To use types from mapgl namespace you need:
load function is imported/// <reference path="node_modules/@2gis/mapgl/global.d.ts" />
You can use typings for MapGL from mapgl namespace like this:
let marker: mapgl.Marker
Checkout example for more information.
FAQs
MapGL API script loader with typings
The npm package @2gis/mapgl receives a total of 3,456 weekly downloads. As such, @2gis/mapgl popularity was classified as popular.
We found that @2gis/mapgl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.

Research
/Security News
A new npm package tests AI malware scanners with prompt injection, safety-triggering comments, context flooding, and obfuscated JavaScript.