mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-22 14:32:15 +00:00
website
This commit is contained in:
22
website_astro/src/content/how_to_use/maplibre.md
Normal file
22
website_astro/src/content/how_to_use/maplibre.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## How to load MapLibre?
|
||||
|
||||
Include [MapLibre GL JS](https://maplibre.org/maplibre-gl-js/docs/) in the `<head>`. If you are using npm, you can install the `maplibre-gl` package. Make sure to import the CSS as well.
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
|
||||
<link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" />
|
||||
```
|
||||
|
||||
Initialize it to a div like this:
|
||||
|
||||
```html
|
||||
<div id="map" style="width: 100%; height: 500px"></div>
|
||||
<script>
|
||||
const map = new maplibregl.Map({
|
||||
style: 'https://tiles.openfreemap.org/styles/liberty',
|
||||
center: [-0.114, 51.506],
|
||||
zoom: 14.2,
|
||||
container: 'map',
|
||||
})
|
||||
</script>
|
||||
```
|
||||
Reference in New Issue
Block a user