Repository navigation
fix: vue-mapbox を撤去して maplibre-gl を直接使う (for migration to nuxt-4) - #559
Merged
Merged
Conversation
yuiseki
marked this pull request as draft
July 30, 2026 02:35
NEKOYASAN
marked this pull request as ready for review
July 31, 2026 12:20
vue-mapbox 撤去後に満たすべき12件を先に固定。preserveDrawingBuffer は 印刷でcanvasを読み戻すため必須。地図コンテナはlayersが空だと描画されないため mountedでは生成できない点も契約に含める。次のコミットで実装して緑にする。
vue-mapbox は Vue 2 専用でメンテ停止済み。実質コンテナとしてしか使っておらず 中身は既に raw な maplibre API だった。Vue が描画したマーカーDOMの複製を Marker/Popup に渡すことで pug の装飾ロジックを維持している。
jest.requireActual を使わず bounds を素のスタブで返す。Nuxt 4 移行で jest から vitest に替わるときにこのファイルを触らずに済ませるため。
Collaborator
Author
|
Conflict 修正します! |
yuiseki
force-pushed
the
yuiseki-rm-vue-mapbox
branch
from
July 31, 2026 12:30
7cbeaef to
5ed43b1
Compare
Collaborator
Author
|
Conflict 修正済みです |
Collaborator
|
すいません〜ありがとうございます〜(癖でSquashしてしまい...) |
NEKOYASAN
approved these changes
Jul 31, 2026
NEKOYASAN
left a comment
Collaborator
There was a problem hiding this comment.
LGTM!
手元でも動作確認して変化がないことを確認しました!
Collaborator
Author
|
Approveありがとうございます!マージします |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要 | About
vue-mapbox を撤去して maplibre-gl を直接使うようにします。
Nuxt 4 移行の前提となる変更ですが、単独でも意味があるので分けて出しています。
base は #558(テスト追加)です。
そちらがマージされると base が master に切り替わります。
#558 がマージされるまでは Draft にしておきます。
vue-mapbox は Vue 2 専用で最終公開が 2022年5月です。Vue 3 では動かないため、Nuxt 4 に上げるには撤去が必要です。
撤去できるのは、すでに実質コンテナとしてしか使っていなかったためです。
components/PrintableMap.vueはimport MapLibre from "maplibre-gl"を持っていて、this.map.map.fitBounds()this.map.map.on()this.map.map.addControl()のように.mapで生インスタンスに降りて操作していました。vue-mapbox が担っていたのはMglMap/MglGeolocateControl/MglMarker/MglPopupの4つだけです。実装の方針
remove()します。凡例のカテゴリ選択時だけ複製を作り直します(クリック起点なのでちらつきは問題になりません)MapとMarkerのインスタンスは Vue のリアクティブ data に置かずcreated()で非リアクティブに持ちます。Vue が WebGL 由来のオブジェクトを深く走査してしまうためですmaplibre-glのバージョンは据え置き(1.15.3)です。6系への更新は別PRにします契約テスト12件を先に書いて落ちることを確認してから実装しました。とくに
preserveDrawingBuffer: trueは、落とすと画面では正常に見えるのに印刷結果の地図だけが白くなるため、テストで固定しています。test-unit/components/PrintableMap.markers.spec.js(#558 で追加したもの)に maplibre のモックを足しています。vue-mapbox を撤去するとこのコンポーネントが自分で地図を作るようになり、モックなしでは jsdom で WebGL 初期化に失敗するためです。動作確認方法 | How to check
Vercel preview(fork 側の PR: yuiseki#23)
https://mapprint-git-yuiseki-rm-vue-mapbox-yuiseki-s-team.vercel.app/map/2024-noto-earthquake
こちらで確認済みのこと
スクリーンショット | Screenshot
Before
After
Diff
1920x1925 で比較して 97.5% のピクセルが完全一致、平均絶対差 0.94/255 でした。
赤くなっているのは文字のアンチエイリアスだけです。上部ヘッダは 0.00%、地図領域は 0.66%(マーカー番号の文字)で、マーカーの位置と地図の形状はピクセル単位で一致しています。
印刷結果(PDF)
地図・QRコード・カテゴリ別の一覧が出ていて、
print-excludeの要素(凡例ナビ・シェアボタン・言語選択)は消えています。地図領域は 2,653色・標準偏差 33.0 で、白紙なら1色・標準偏差0になります。