Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

避難所の数を表示したい #8

Open
ShogoHirasawa opened this issue Jun 14, 2022 · 4 comments
Open

避難所の数を表示したい #8

ShogoHirasawa opened this issue Jun 14, 2022 · 4 comments

Comments

@ShogoHirasawa
Copy link
Member

No description provided.

@ShogoHirasawa
Copy link
Member Author

現状

スクリーンショット 2022-06-14 21 17 50

理想形

スクリーンショット 2022-06-14 21 19 55

https://maplibre.org/maplibre-gl-js-docs/example/cluster/

consoleのエラー

Uncaught (in promise) Error: Style is not done loading.
    at ie._checkLoaded (style.ts:374:19)
    at ie.addLayer (style.ts:652:14)
    at Map.addLayer (map.ts:1973:20)
    at (index):90:13

なぜエラーがおきているのかの予想

非同期処理がうまく行っていないのかもと予想。非同期処理とは何なのかをまずは理解する必要あり

参考になりそうな資料

https://teratail.com/questions/141224

https://qiita.com/cheez921/items/41b744e4e002b966391a

@ShogoHirasawa
Copy link
Member Author

非同期処理の理解ができていなかった。

非同期処理の構造を理解できていなかったためのエラーだった。コードを書き直したところ以下のような表示になった。
スクリーンショット 2022-06-14 23 07 24

openmaptilesの提供するフォントから選ばなきゃいけないっぽい。
以下を参考にすること
https://github.com/openmaptiles/fonts

@ShogoHirasawa
Copy link
Member Author

フォント変更

フォントをOpen Sans Regularに変更したら無事にフェッチできた
スクリーンショット 2022-06-14 23 08 43

@ShogoHirasawa
Copy link
Member Author

ShogoHirasawa commented Jun 14, 2022

フォントエラーの詳細

MapLibre GL JS Style Specificationによると、テキストフォントは設定しなければ自動的にOpen Sans Regular,Arial Unicode MS Regularになる仕様になっている。
スクリーンショット 2022-06-14 23 36 18

MapLibre GL JS が用意しているstyle.jsonを使えば問題ないが、今回の場合は独自でstyle.jsonを作っている。今回使用しているstyle.jsonの中身を見るとフォントはopenmaptilesから取ってきていることがわかった。
style.jsonに以下の記述がある。

 "glyphs": "https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",

以下のフォントファミリーからフォントを指定してあげることで、無事解決した。
スクリーンショット 2022-06-14 23 40 56

  • Arial はMapLibreでは提供していないので注意すること

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant