From a71727538f65ab4f10f5239550be82590f9d47d1 Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Sat, 24 Oct 2026 12:29:24 +0900 Subject: parks: 公園一覧と地図、公共施設の情報を更新 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 近隣公園のクリックを市内公園と同じ挙動にし、Googleマップを公園名で開く - 公共施設のトイレを○にし、ルネこだいらを追加 - 未取得だった施設の座標を追加し、再ジオコーディング時の上書きを防止 - 手入力ポリゴン、近隣公園、PWA、ライセンス表示を追加 --- public/icons/icon-192.png | Bin 0 -> 3897 bytes public/icons/icon-512.png | Bin 0 -> 14112 bytes public/icons/icon.svg | 6 +++ public/kodaira-data/parks/LICENSE.txt | 10 +++++ public/manifest.webmanifest | 32 ++++++++++++++++ public/sw.js | 70 ++++++++++++++++++++++++++++++++++ 6 files changed, 118 insertions(+) create mode 100644 public/icons/icon-192.png create mode 100644 public/icons/icon-512.png create mode 100644 public/icons/icon.svg create mode 100644 public/kodaira-data/parks/LICENSE.txt create mode 100644 public/manifest.webmanifest create mode 100644 public/sw.js (limited to 'public') diff --git a/public/icons/icon-192.png b/public/icons/icon-192.png new file mode 100644 index 0000000..1ba1e59 Binary files /dev/null and b/public/icons/icon-192.png differ diff --git a/public/icons/icon-512.png b/public/icons/icon-512.png new file mode 100644 index 0000000..cb56518 Binary files /dev/null and b/public/icons/icon-512.png differ diff --git a/public/icons/icon.svg b/public/icons/icon.svg new file mode 100644 index 0000000..9b105c1 --- /dev/null +++ b/public/icons/icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/public/kodaira-data/parks/LICENSE.txt b/public/kodaira-data/parks/LICENSE.txt new file mode 100644 index 0000000..6149587 --- /dev/null +++ b/public/kodaira-data/parks/LICENSE.txt @@ -0,0 +1,10 @@ +小平市の公園一覧 手入力ポリゴン + +作成: 安竹洋平(https://yasutakeyohei.com/) +ライセンス: Creative Commons Attribution 4.0 International (CC BY 4.0) +https://creativecommons.org/licenses/by/4.0/deed.ja + +注記: +このポリゴンは正確な境界座標ではありません。参考としてご利用ください。 +出典として「安竹洋平(https://yasutakeyohei.com/)」を明示すれば、自由に利用できます。 +OSM由来のデータはOpenStreetMapのODbLライセンスです。 diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest new file mode 100644 index 0000000..91af084 --- /dev/null +++ b/public/manifest.webmanifest @@ -0,0 +1,32 @@ +{ + "id": "/kodaira-data/parks/", + "name": "小平市の公園一覧", + "short_name": "小平市公園", + "description": "小平市内の公園・公共施設・近隣公園を検索できる一覧", + "lang": "ja", + "start_url": "/kodaira-data/parks/", + "scope": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#1b5e20", + "icons": [ + { + "src": "/icons/icon-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "/icons/icon-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any" + }, + { + "src": "/icons/icon-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..99af941 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,70 @@ +const CACHE = "kodaira-parks-v1"; +const APP_SHELL = [ + "/kodaira-data/parks/", + "/manifest.webmanifest", + "/icons/icon-192.png", + "/icons/icon-512.png", +]; + +self.addEventListener("install", (event) => { + event.waitUntil( + caches + .open(CACHE) + .then((cache) => cache.addAll(APP_SHELL)) + .then(() => self.skipWaiting()), + ); +}); + +self.addEventListener("activate", (event) => { + event.waitUntil( + caches + .keys() + .then((keys) => + Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key))), + ) + .then(() => self.clients.claim()), + ); +}); + +self.addEventListener("fetch", (event) => { + const request = event.request; + if (request.method !== "GET") return; + + const url = new URL(request.url); + // OSMのタイルなど外部オリジンのものはキャッシュしない。 + if (url.origin !== self.location.origin) return; + + // ページ遷移はネットワーク優先。オフライン時はキャッシュ→公園ページ。 + if (request.mode === "navigate") { + event.respondWith( + fetch(request) + .then((response) => { + const copy = response.clone(); + caches.open(CACHE).then((cache) => cache.put(request, copy)); + return response; + }) + .catch(() => + caches + .match(request) + .then((cached) => cached || caches.match("/kodaira-data/parks/")), + ), + ); + return; + } + + // それ以外はキャッシュ優先。取得できたらキャッシュを更新する。 + event.respondWith( + caches.match(request).then((cached) => { + const network = fetch(request) + .then((response) => { + if (response.ok) { + const copy = response.clone(); + caches.open(CACHE).then((cache) => cache.put(request, copy)); + } + return response; + }) + .catch(() => cached); + return cached || network; + }), + ); +}); -- cgit v1.3.1