![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile 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.
Mapbox GL JS is a Javascript & WebGL library that renders interactive maps from vector tiles and Mapbox styles.
It is part of the Mapbox GL ecosystem which includes Mapbox GL Native, a suite of compatible SDKs for native desktop and mobile applications.
<script>
tagTo use the vector tiles and styles hosted on http://mapbox.com, you must create an account and then obtain an access token. You may learn more about access tokens here.
<!DOCTYPE html>
<html>
<head>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.24.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.24.0/mapbox-gl.css' rel='stylesheet' />
</head>
<body>
<div id='map' style='width: 400px; height: 300px;' />
<script>
mapboxgl.accessToken = '<your access token here>';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9'
});
</script>
</body>
</html>
To use the vector tiles and styles hosted on http://mapbox.com, you must create an account and then obtain an access token. You may learn more about access tokens here.
Install the mapbox-gl
npm package
npm install --save mapbox-gl
Instantiate mapboxgl.Map
var mapboxgl = require('mapbox-gl');
mapboxgl.accessToken = '<your access token here>';
var map = new mapboxgl.Map({
container: '<your HTML element id>',
style: 'mapbox://styles/mapbox/streets-v9'
});
To use the vector tiles and styles hosted on http://mapbox.com, you must create an account and then obtain an access token. You may learn more about access tokens here.
Install the mapbox-gl
npm package
and the required loaders.
npm install --save mapbox-gl
npm install --save transform-loader
npm install --save json-loader
npm install --save webworkify-webpack
Add the required additional options from webpack.config.example.js to your webpack configuration.
Instantiate mapboxgl.Map
var mapboxgl = require('mapbox-gl');
mapboxgl.accessToken = '<your access token here>';
var map = new mapboxgl.Map({
container: '<your HTML element id>',
style: 'mapbox://styles/mapbox/streets-v9'
});
If you're using the ES6 module system, you can import mapboxgl
like so:
import mapboxgl from 'mapbox-gl';
These projects are written and maintained by the GL JS community. Feel free to open a PR add your own projects to this list. We :heart: third party projects!
You may use a Content Security Policy to restrict the resources your page has access to, as a way of guarding against Cross-Site Scripting and other types of attacks. If you do, Mapbox GL JS requires the following directives:
child-src blob: ;
img-src data: blob: ;
script-src 'unsafe-eval' ;
Requesting styles from Mapbox or other services will require additional
directives. For Mapbox, you can use this connect-src
setting:
connect-src https://*.tiles.mapbox.com https://api.mapbox.com
See CONTRIBUTING.md.
0.24.0 (September 19 2016)
mapbox://
URLs #3113Worker
script Blob
size #3158package.json
#3174text-field
#3179Map#queryRenderedFeatures
on nonexistent layer #3196Scale
control #3160Map#getBounds
#3081Map#setFilter
and map rotation on iOS 10 #3207FAQs
A WebGL interactive maps library
The npm package mapbox-gl receives a total of 0 weekly downloads. As such, mapbox-gl popularity was classified as not 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 iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.