Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

maplibre-gl

Package Overview
Dependencies
Maintainers
7
Versions
113
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

  • 4.7.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
412K
increased by10.19%
Maintainers
7
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 23 Sep 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc