HOSTING

Share a MapLibre map as a link

A MapLibre map draws in the browser, so it fits in one HTML file. Load MapLibre from a CDN, put your GeoJSON in the page, upload the file, and send a link that opens the interactive map.

4 min read·

MapLibre GL JS draws vector maps with pan, zoom, rotation and click popups in the browser. A screenshot drops all of that, and a project folder that loads a separate .geojson file breaks when the recipient opens it from disk, because a request for a local file is blocked on a file:// page.

One HTML file with MapLibre loaded from a CDN and the data inside it, hosted at a link, opens the working map on any device.

Put the map in one file

Create map.html with this structure:

  • ✓<!doctype html>, <meta charset="utf-8"> and <meta name="viewport" content="width=device-width, initial-scale=1"> in the head.
  • ✓<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.css"> and <script src="https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.js"></script>. Version 5 ships a file that works in a plain script tag; version 6 is published as an ES module only. Pinning the version keeps the map from changing when a new release ships.
  • ✓A container with a height, such as <div id="map" style="height:100vh"></div>. A container with no height draws a map zero pixels tall.
  • ✓A <script> block after the container: const map = new maplibregl.Map({ container: "map", style: "https://demotiles.maplibre.org/style.json", center: [10, 50], zoom: 3 });
  • ✓The style URL sets the basemap. The MapLibre demo style is fine for a test; for a map you send to clients, use a style from a tile provider you have an account with, and keep its API key restricted to your link's domain.

Keep the data inside the page

A layer whose source is data: "places.geojson" requests a second file. An uploaded page is hosted on its own, so that request fails and the layer stays empty.

Paste the GeoJSON into the page as a JavaScript object, const places = { type: "FeatureCollection", features: [...] }, and add it once the style has loaded: map.on("load", () => { map.addSource("places", { type: "geojson", data: places }); map.addLayer({ id: "places", type: "circle", source: "places", paint: { "circle-radius": 8, "circle-color": "#e4572e" } }); });

For popups, add map.on("click", "places", (e) => new maplibregl.Popup().setLngLat(e.lngLat).setText(e.features[0].properties.name).addTo(map)); inside the same load handler.

GeoJSON that already lives at a public URL which allows cross-origin requests can stay as a URL in data, written as the full https:// address.

Upload it and send the link

Drag the .html file onto the FileShare Pro dashboard and copy the link. The map draws when the page opens. Pan, zoom and popups work as they did locally, and viewers need no account.

If the page is blank once hosted, open the browser console. "maplibregl is not defined" means the script tag is missing or comes after your map code; a failed request for a .geojson file means data was left outside the page; a map that shows only a background color usually means the style URL or its API key was refused. Why an AI page works in chat but breaks when hosted covers maps an assistant wrote.

Turn on comments and viewers can leave a note on the page after typing a name. When the data changes, upload the new file over the old one and the link stays the same: updating a shared link without changing it.

Other map tools: Folium or Leaflet, kepler.gl.

Frequently asked

How do I share a MapLibre map without a web server?

Put the MapLibre CSS and script tags, a container with a height, your new maplibregl.Map(...) call and the GeoJSON into one HTML file, upload it to a host that serves HTML as a web page, and send the link.

Why is my MapLibre map blank after upload?

Usually the container has no height, the MapLibre script tag is missing or loads after the map code, the GeoJSON comes from a file that was not uploaded, or the style URL refused the request. Check the browser console for the exact error.

Can I use the maplibre-gl version 6 file in a script tag?

No. Version 6 is published as an ES module only. Use version 5 with a plain script tag, or load version 6 with <script type="module"> and an import.

Is it free?

Yes. The free plan hosts up to 50 files of up to 100 MB each, with view counts and comments included. Password-protected links are on Pro.

Got a page to share?

Drop the file, copy the link — live in seconds, free plan included.

Start sharing free