Joey889 commited on
Commit
f93f3ef
·
verified ·
1 Parent(s): 97cfa46

Upload 6 files

Browse files
Files changed (3) hide show
  1. Dockerfile +0 -8
  2. README.md +4 -4
  3. index.html +36 -1
Dockerfile CHANGED
@@ -1,18 +1,10 @@
1
 
2
  FROM python:3.9-slim
3
 
4
- # 建立非 root 使用者
5
  RUN useradd -m appuser
6
-
7
- # 複製所有網站檔案到 app 目錄
8
  COPY . /home/appuser/app
9
  WORKDIR /home/appuser/app
10
-
11
- # 切換到非 root 使用者
12
  USER appuser
13
 
14
- # 開啟 Hugging Face 預設 port
15
  EXPOSE 7860
16
-
17
- # 啟動 HTTP Server
18
  CMD ["python", "-m", "http.server", "7860"]
 
1
 
2
  FROM python:3.9-slim
3
 
 
4
  RUN useradd -m appuser
 
 
5
  COPY . /home/appuser/app
6
  WORKDIR /home/appuser/app
 
 
7
  USER appuser
8
 
 
9
  EXPOSE 7860
 
 
10
  CMD ["python", "-m", "http.server", "7860"]
README.md CHANGED
@@ -1,12 +1,12 @@
1
  ---
2
- title: AR0518Docker
3
- emoji: 🧭
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: docker
7
  pinned: false
8
  ---
9
 
10
- # AR 尋寶遊戲 - Docker 部署最終修正版
11
 
12
- 本專案部署於 Hugging Face Spaces,使用 Python 內建 HTTP server 提供 index.html 為主的 AR 尋寶互動遊戲介面。
 
1
  ---
2
+ title: AR 尋寶地圖版
3
+ emoji: 🗺️
4
  colorFrom: blue
5
  colorTo: indigo
6
  sdk: docker
7
  pinned: false
8
  ---
9
 
10
+ # AR 尋寶遊戲 - 加入 Google Maps 地理定位擴充版
11
 
12
+ 本版本整合了 Google Maps 與瀏覽器定位功能,玩家可在地圖上看到自己位置並進行寶藏探索互動。
index.html CHANGED
@@ -10,5 +10,40 @@
10
  </head>
11
  <body>
12
  <div id="root"></div>
13
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  </html>
 
10
  </head>
11
  <body>
12
  <div id="root"></div>
13
+
14
+ <div id="map" style="height: 300px; width: 100%; margin-top: 20px;"></div>
15
+ <script>
16
+ let map;
17
+ function initMap() {
18
+ map = new google.maps.Map(document.getElementById("map"), {
19
+ center: { lat: 25.033964, lng: 121.564468 },
20
+ zoom: 16,
21
+ });
22
+
23
+ if (navigator.geolocation) {
24
+ navigator.geolocation.getCurrentPosition(
25
+ (position) => {
26
+ const pos = {
27
+ lat: position.coords.latitude,
28
+ lng: position.coords.longitude,
29
+ };
30
+ new google.maps.Marker({
31
+ position: pos,
32
+ map: map,
33
+ title: "你在這裡",
34
+ });
35
+ map.setCenter(pos);
36
+ },
37
+ () => {
38
+ alert("無法取得您的位置");
39
+ }
40
+ );
41
+ }
42
+ }
43
+ </script>
44
+ <script async defer
45
+ src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCbaJdQHiF6SgKES_3NvwPV-Xu9h8ROYZs&callback=initMap">
46
+ </script>
47
+ </body>
48
+
49
  </html>