Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
mapbox-gl
Advanced tools
The mapbox-gl npm package is a powerful library for interactive, customizable maps and geospatial data visualization. It leverages WebGL to render maps from vector tiles and allows for dynamic styling and interactivity.
Display a Map
This code initializes a basic map using Mapbox GL JS. It sets the map container, style, center coordinates, and zoom level.
const mapboxgl = require('mapbox-gl');
mapboxgl.accessToken = 'your-access-token';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
center: [-74.5, 40],
zoom: 9
});
Add a Marker
This code adds a marker to the map at the specified longitude and latitude coordinates.
const marker = new mapboxgl.Marker()
.setLngLat([-74.5, 40])
.addTo(map);
Add a Popup
This code creates a popup with a text message and attaches it to a specific location on the map.
const popup = new mapboxgl.Popup({ offset: 25 })
.setText('Hello, World!')
.setLngLat([-74.5, 40])
.addTo(map);
Draw a Polygon
This code draws a polygon on the map by defining its coordinates and adding it as a layer when the map loads.
const polygon = {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [
[
[-74.5, 40],
[-74.5, 41],
[-73.5, 41],
[-73.5, 40],
[-74.5, 40]
]
]
}
};
map.on('load', function () {
map.addLayer({
'id': 'polygon',
'type': 'fill',
'source': {
'type': 'geojson',
'data': polygon
},
'layout': {},
'paint': {
'fill-color': '#088',
'fill-opacity': 0.8
}
});
});
Leaflet is a widely used open-source JavaScript library for mobile-friendly interactive maps. It is lightweight and easy to use, but it does not support vector tiles and WebGL rendering natively like mapbox-gl.
OpenLayers is a high-performance, feature-rich library for displaying map data in web browsers. It supports a wide range of map types and data sources, including vector tiles, but it can be more complex to set up compared to mapbox-gl.
Cesium is a JavaScript library for creating 3D globes and 2D maps. It is highly performant and supports WebGL, making it suitable for complex geospatial visualizations. However, it is more focused on 3D rendering compared to mapbox-gl.
A WebGL JavaScript interactive maps library that can render Mapbox Vector Tiles.
To install dependencies and build the source files:
$ npm install
To serve the debug page:
$ npm start &
$ open http://localhost:3000/debug/?access_token=$MapboxAccessToken
This assumes you have the MapboxAccessToken
environment variable set to a Mapbox API token from https://www.mapbox.com/account/apps/.
It will watch the source files and automatically rebuild the browserify bundle whenever a change is detected.
Tests are written in tape
and can run on Sauce Labs via zuul.
npm test
: local tests run in nodejs - excludes browser testsnpm run cov
: generate test coverage report - excludes browser testsnpm run test-remote
: run all tests on Sauce Labs. requires Sauce Labs credentials
in your environment.npm run test-browser
: run all tests locally in a browser.npm run docs
: generate API docs
npm run build-sprite [outname] [inputdirs]
: generate an image sprite by running this script on one or more directories of PNG images.
0.3.1 (Oct 06 2014)
FAQs
A WebGL interactive maps library
The npm package mapbox-gl receives a total of 816,330 weekly downloads. As such, mapbox-gl popularity was classified as popular.
We found that mapbox-gl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 28 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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.