/ MapLibre から

MapLibre GL JS のコードを 3D の球へ

import を 1 行替える
@ortho-earth/globe/maplibre · Map · Marker · Popup · addProtocol · style.json · コントロール

@ortho-earth/globe/maplibre は、MapLibre GL JS の API を Ortho Earth の地球儀エンジン(WebGPU、無ければ WebGL2)で描くものです。 MapLibre 向けに書いたコードはそのまま動きます。描かれるのは実スケールの地形を持つ丸い地球で、同じ地図に 3D Tiles・I3S・glTF の模型・空も載せられます。

1. 替えるのは 1 行

import * as maplibregl from "@ortho-earth/globe/maplibre";   // 元は from "maplibre-gl"

const map = new maplibregl.Map({
  container: "map",
  style: "https://demotiles.maplibre.org/style.json",
  center: [139.77, 35.68],
  zoom: 4,
});

map.on("load", () => {
  map.addSource("cities", { type: "geojson", data: "cities.geojson" });
  map.addLayer({ id: "cities", type: "circle", source: "cities",
    paint: { "circle-radius": 6, "circle-color": "#e4572e" } });
});

npm i @ortho-earth/globe で入れて Vite で組みます。ズームの段は MapLibre と同じなので、zoom・minzoom/maxzoom・タイルの段はコードのままの意味です。 MapLibre のコントロールを使うなら maplibre-gl.css はそのまま読んでください。 公開物に対して自動の試験で走らせている手順の全文は、Build with Ortho Earth(英語)の A8 にあります。

2. 公式例 139 本

MapLibre GL JS の公式例はすべて、コードを変えずに(import だけ替えて)球の上で動きます。 MapLibre の例の頁 は 1 本ずつ、ソース・Run の釦・MapLibre の絵とどれだけ同じかを載せています。 2026 年 10 月 12 日の検定では、同じ絵が 66 本、問い合わせに同じ答えを返すのが 50 本、違いが見えるが動くのが 21 本、動かないのは 0 本でした(MapLibre の絵が取れず比べられないのが 2 本)。

例ここで見えること
3D terrainraster-dem の source で setTerrain・球の上で
quantized-mesh の地形Cesium の地形の形式をそのまま読む
Buildings in 3D球の上の fill-extrusion
three.js で 3D Tilesthree.js を地図と同じフレームで描く

3. 違う所

違いの全部は、仕事のたびに書き足している台帳 packages/globe/maplibre-compat.md(リポジトリの中)にあります。

@ortho-earth/globe · GPL-3.0 · Kenji Yoshida · 2026