New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

maplibre-gl

Package Overview
Dependencies
Maintainers
6
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maplibre-gl

BSD licensed community fork of mapbox-gl, a WebGL interactive maps library

5.2.0
latest
Source
npm
Version published
Weekly downloads
541K
16.41%
Maintainers
6
Weekly downloads
 
Created

What is maplibre-gl?

MapLibre GL is a JavaScript library for interactive, customizable vector maps on the web. It is a community-driven fork of Mapbox GL JS, providing similar functionalities for rendering maps and handling user interactions.

What are maplibre-gl's main functionalities?

Display a Map

This code initializes a basic map using MapLibre GL. It sets the container, style, center, and zoom level for the map.

const map = new maplibregl.Map({
  container: 'map', // container ID
  style: 'https://demotiles.maplibre.org/style.json', // style URL
  center: [0, 0], // starting position [lng, lat]
  zoom: 2 // starting zoom
});

Add a Marker

This code adds a marker to the map at the specified longitude and latitude.

const marker = new maplibregl.Marker()
  .setLngLat([0, 0])
  .addTo(map);

Add a Popup

This code adds a popup to the map at the specified longitude and latitude with custom HTML content.

const popup = new maplibregl.Popup({ closeOnClick: false })
  .setLngLat([0, 0])
  .setHTML('<h1>Hello World!</h1>')
  .addTo(map);

Draw a Line

This code draws a line on the map using GeoJSON data. It adds a source and a layer to the map to render the line.

map.on('load', function () {
  map.addSource('line', {
    'type': 'geojson',
    'data': {
      'type': 'Feature',
      'geometry': {
        'type': 'LineString',
        'coordinates': [
          [0, 0],
          [10, 10]
        ]
      }
    }
  });
  map.addLayer({
    'id': 'line',
    'type': 'line',
    'source': 'line',
    'layout': {},
    'paint': {
      'line-color': '#888',
      'line-width': 8
    }
  });
});

Other packages similar to maplibre-gl

FAQs

Package last updated on 03 Mar 2025

Did you know?

Socket

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.

Install

Related posts