UNPKG

7.41 kBMarkdownView Raw
1![MapLibre Logo](https://maplibre.org/img/maplibre-logo-big.svg)
2
3# MapLibre GL JS
4
5**[MapLibre GL JS](https://maplibre.org/maplibre-gl-js-docs/api/)** is an open-source library for publishing maps on your websites. Fast displaying of maps is possible thanks to GPU-accelerated vector tile rendering.
6
7It originated as an open-source fork of [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js), before their switch to a non-OSS license in December 2020. The library is intended to be a drop-in replacement for the Mapbox’s version with additional functionality.
8
9[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg?style=flat)](LICENSE.txt)[![Version](https://img.shields.io/npm/v/maplibre-gl?style=flat)](https://www.npmjs.com/package/maplibre-gl)[![CI](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml/badge.svg)](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml)[![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://opensource.org/licenses/BSD-3-Clause)
10
11<br />
12
13## Getting Started
14
15Include the JavaScript and CSS files in the <head> of your HTML file.
16
17``` html
18<script src='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.js'></script>
19<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
20```
21
22Include the following code in the <body> of your HTML file.
23
24``` html
25<div id='map' style='width: 400px; height: 300px;'></div>
26<script>
27var map = new maplibregl.Map({
28 container: 'map',
29 style: 'https://demotiles.maplibre.org/style.json', // stylesheet location
30 center: [-74.5, 40], // starting position [lng, lat]
31 zoom: 9 // starting zoom
32});
33</script>
34```
35
36Enjoy the map!
37
38<br />
39
40## Documentation
41
42Full documentation for this library [is available here](https://maplibre.org/maplibre-gl-js-docs/api/).
43
44Check out the features through [examples](https://maplibre.org/maplibre-gl-js-docs/example/).
45
46| Showcases | |
47| ---- | ---- |
48|![Display a map](https://maplibre.org/maplibre-gl-js-docs/assets/simple-map-800-22a3f5b6410f543ab214e14f68fb42ec.png) |![Third party vector tile source](https://maplibre.org/maplibre-gl-js-docs/assets/third-party-800-e047007bba338f6ec7d6cd47abfed279.png) |
49|![Animate a series of images](https://maplibre.org/maplibre-gl-js-docs/assets/animate-images-800-497358611dbe047f300faeb9465aad5f.png) |![Create a heatmap layer](https://maplibre.org/maplibre-gl-js-docs/assets/heatmap-layer-800-05c0f97ddb6b1a10e84b5064564e86ff.png) |
50|![3D buildings](https://maplibre.org/maplibre-gl-js-docs/assets/3d-buildings-800-bd7885f07050dbbfee7a9bb800ff5ce8.png) |![Visualize population density](https://maplibre.org/maplibre-gl-js-docs/assets/visualize-population-density-800-6c65712d9ea94eb6d2bd3348a82b9bdf.png) |
51
52<br />
53
54## Migrating from mapbox-gl
55
56If you depend on mapbox-gl directly, simply replace `mapbox-gl` with `maplibre-gl` in `package.json`:
57
58Use
59
60```diff
61 "dependencies": {
62- "mapbox-gl": "^1.13.0"
63+ "maplibre-gl": ">=1.15.2"
64 }
65```
66
67if it is important to you that the behaviour is similar to `mapbox-gl` version 1.x.
68
69If you are OK with changes that integrate non-backward compatible features, install `maplibre-gl` version 2:
70
71```diff
72 "dependencies": {
73- "mapbox-gl": "^1.13.0"
74+ "maplibre-gl": ">=2.0.0"
75 }
76```
77
78And replace `mapboxgl` with `maplibregl` in your JavaScript and optionally in your HTML/CSS code:
79
80> MapLibre GL JS is distributed via [unpkg.com](https://unpkg.com). For more informations please see [MapLibre GL is on unpkg.com](./docs/README-unpkg.md#maplibre-gl-on-unpkgcom).
81
82```diff
83- <script src="https://api.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js"></script>
84- <link
85- href="https://api.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.css"
86- rel="stylesheet"
87- />
88
89 <!-- Use maplibre-gl version 1.15.2 for backwards compatibility with mapbox-gl version 1.x. -->
90+ <script src="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.js"></script>
91+ <link
92+ href="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.css"
93+ rel="stylesheet"
94+ />
95
96- var map = new mapboxgl.Map({
97+ var map = new maplibregl.Map({
98
99- <button class="mapboxgl-ctrl">
100+ <button class="maplibregl-ctrl">
101```
102
103Want an example? Have a look at the official [MapLibre GL JS Documentation](https://maplibre.org/maplibre-gl-js-docs/example/).
104
105Use MapLibre GL JS bindings for React (https://visgl.github.io/react-map-gl/docs/get-started/get-started#using-with-a-mapbox-gl-fork) and Angular (https://github.com/maplibre/ngx-maplibre-gl). Find more at [awesome-maplibre](https://github.com/maplibre/awesome-maplibre).
106
107<br />
108
109## Contribution
110
111### Getting Involved
112
113Join the #maplibre slack channel at OSMUS: get an invite at https://osmus-slack.herokuapp.com/
114
115### Community Leadership
116
117You can find the official status of the backing community and steering committee in the [COMMUNITY.md](COMMUNITY.md) document.
118
119### Avoid Fragmentation
120
121If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.
122
123### Roadmap
124
125This project's initial plans are outlined in the [Roadmap](https://github.com/maplibre/maplibre-gl-js/projects/2) project. The primary goal is consistency and continued bug fixes and maintenance as we advance.
126
127> **MapLibre GL** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html).
128
129<br />
130
131## Sponsors
132
133We thank everyone who supported us financially in the past and special thanks to the people and organizations who support us with recurring dontations:
134
135[MIERUNE Inc.](https://www.mierune.co.jp/?lang=en) [@MIERUNE](https://github.com/MIERUNE), [@jawg](https://github.com/jawg), [@nekoyasan](https://github.com/nekoyasan), [@atierian](https://github.com/atierian), [@photoprism](https://github.com/photoprism), [@kaplanlior](https://github.com/kaplanlior), [@francois2metz](https://github.com/francois2metz), [@Schneider-Geo](https://github.com/Schneider-Geo), [@serghov](https://github.com/serghov), [@ambientlight](https://github.com/ambientlight), [@joschi77](https://github.com/joschi77), [@geoffhill](https://github.com/geoffhill), [@jasongode](https://github.com/jasongode)
136
137<br />
138
139## Thank you Mapbox 🙏🏽
140
141We'd like to acknowledge the amazing work Mapbox has contributed to open source. The open source community is sad to part ways with them, but we simultaneously feel grateful for everything they already contributed. `mapbox-gl-js` 1.x is an open source achievement which now lives on as `maplibre-gl`. We're proud to develop on the shoulders of giants, thank you Mapbox 🙇🏽‍♀️.
142
143Please keep in mind: Unauthorized backports are the biggest threat to the MapLibre project. It is unacceptable to backport code from mapbox-gl-js, which is not covered by the former BSD-3 license. If you are unsure about this issue, [please ask](https://github.com/maplibre/maplibre-gl-js/discussions)!
144
145<br />
146
147## License
148
149**MapLibre GL** is licensed under the [3-Clause BSD license](./LICENSE.txt).