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

@mapbox/mapbox-gl-draw

Package Overview
Dependencies
Maintainers
28
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/mapbox-gl-draw

A drawing component for Mapbox GL JS

  • 1.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
28
Created

What is @mapbox/mapbox-gl-draw?

@mapbox/mapbox-gl-draw is a plugin for Mapbox GL JS that adds support for drawing and editing features on a map. It allows users to draw points, lines, and polygons, and provides a user-friendly interface for manipulating these shapes.

What are @mapbox/mapbox-gl-draw's main functionalities?

Drawing Points

This feature allows users to draw points on the map. The code initializes the MapboxDraw control and adds it to the map. When a point is created, an event is triggered, and the created point's features are logged to the console.

const draw = new MapboxDraw();
map.addControl(draw);
map.on('draw.create', function(e) {
  const features = e.features;
  console.log('Point created:', features);
});

Drawing Lines

This feature allows users to draw lines on the map. Similar to drawing points, the MapboxDraw control is added to the map, and an event is triggered when a line is created, logging the line's features to the console.

const draw = new MapboxDraw();
map.addControl(draw);
map.on('draw.create', function(e) {
  const features = e.features;
  console.log('Line created:', features);
});

Drawing Polygons

This feature allows users to draw polygons on the map. The MapboxDraw control is added to the map, and an event is triggered when a polygon is created, logging the polygon's features to the console.

const draw = new MapboxDraw();
map.addControl(draw);
map.on('draw.create', function(e) {
  const features = e.features;
  console.log('Polygon created:', features);
});

Editing Features

This feature allows users to edit existing features on the map. The MapboxDraw control is added to the map, and an event is triggered when a feature is updated, logging the updated feature's details to the console.

const draw = new MapboxDraw();
map.addControl(draw);
map.on('draw.update', function(e) {
  const features = e.features;
  console.log('Feature updated:', features);
});

Deleting Features

This feature allows users to delete features from the map. The MapboxDraw control is added to the map, and an event is triggered when a feature is deleted, logging the deleted feature's details to the console.

const draw = new MapboxDraw();
map.addControl(draw);
map.on('draw.delete', function(e) {
  const features = e.features;
  console.log('Feature deleted:', features);
});

Other packages similar to @mapbox/mapbox-gl-draw

Keywords

FAQs

Package last updated on 21 Sep 2023

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