diff --git a/A2teamkadai/map_old.js b/A2teamkadai/map_old.js index 11f7a14..29e4a1e 100644 --- a/A2teamkadai/map_old.js +++ b/A2teamkadai/map_old.js @@ -1,323 +1,142 @@ -//Leafletでの処理 +// Leafletでの処理 function init(){ - //地図を表示するdiv要素のidを設定 - var map = L.map('mapcontainer'); - //座標の指定 + // 地図を表示するdiv要素のidを設定 + var map = L.map('playmap'); + // 座標の指定 var mpoint = [38.5350, 139.8875]; - //マーカーのURL - var markerIcon = "https://esm.sh/leaflet@1.9.2/dist/images/marker-icon.png"; - var markerIcon2x = "https://esm.sh/leaflet@1.9.2/dist/images/marker-icon-2x.png"; - var markerShadow = "https://esm.sh/leaflet@1.9.2/dist/images/marker-shadow.png"; - //マーカーの色の設定 - var skyblueIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-skyblue" - }); - var brownIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-brown" - }); - var purpleIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-purple" - }); - var orangeIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-orange" - }); - var pinkIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-pink" - }); - var whiteIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-white" - }); - var blackIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-black" - }); - var darkgoldIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-darkgold" - }); - var redIcon = L.icon({ - iconUrl: markerIcon, - iconRetinaUrl: markerIcon2x, - shadowUrl: markerShadow, - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41], - className: "icon-red" - }); - //地図の中心とズームレベルを指定 + // 地図の中心とズームレベルを指定 map.setView(mpoint, 10); - //表示するタイルレイヤのURLとAttributionコントロールの記述を設定して、地図に追加する - L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + // 表示するタイルレイヤのURLとAttributionコントロールの記述を設定して、地図に追加する + var osmTile = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors,' - }).addTo(map); - /* - // GeoJSONのレイヤーを設定 - var foodLayer = L.geoJson(asahi, { // asahi変数は asahi.geojson からロードした - style: function (feature) { - return feature.properties; - }, - onEachFeature: function(j, layer) { - let p = j.properties; - if (p) { - let name = p.name, desc = p.description; - let popup = "
" + desc + "
"; - layer.bindPopup(popup); + }); + var gsiTile = L.tileLayer('//cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png', { + attribution: + '国土地理院' + }); + osmTile.addTo(map); + var baseLayers = {'OpenStreetMap': osmTile, '国土地理院': gsiTile}; + L.control.layers(baseLayers, null).addTo(map); + // 編集画面用のマップ + var editmap = L.map('editmap'); + editmap.setView(mpoint, 10); + var osmTile = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors,' + }); + var gsiTile = L.tileLayer('//cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png', { + attribution: + '国土地理院' + }); + var marker = L.marker(mpoint).addTo(editmap); + osmTile.addTo(editmap); + var baseLayers = {'OpenStreetMap': osmTile, '国土地理院': gsiTile}; + L.control.layers(baseLayers, null).addTo(editmap); + var clicklat; + var clicklng; + function moveIcon(e) { + clicklat = e.latlng.lat; + clicklng = e.latlng.lng; + marker.setLatLng(e.latlng).bindPopup( + "緯度:" + clicklat + "" + description + "
" + address + "
" + url + "" + layer.bindPopup(popup) + .addEventListener("click", () => { + clickMarker(image, quiz, choiceA, choiceB, choiceC, answer, stampid, stampsrc); + }); + } } - } - }) - var placeLayer = L.geoJson(asahi, { // asahi変数は asahi.geojson からロードした - style: function (feature) { - return feature.properties; - }, - onEachFeature: function(j, layer) { - let p = j.properties; - if (p) { - let name = p.name, desc = p.description; - let popup = "" + desc + "
"; - layer.bindPopup(popup); - } - } - }) - var natureLayer = L.geoJson(asahi, { // asahi変数は asahi.geojson からロードした - style: function (feature) { - return feature.properties; - }, - onEachFeature: function(j, layer) { - let p = j.properties; - if (p) { - let name = p.name, desc = p.description; - let popup = "" + desc + "
"; - layer.bindPopup(popup); - } - } - }) - foodLayer.addTo(map); - placeLayer.addTo(map); - natureLayer.addTo(map); - // マーカーをオーバーレイレイヤに指定 - var ovlLayers = {'食 ': foodLayer, '場所': placeLayer, '自然': natureLayer}; - // オーバーレイレイヤをマップに追加 - L.control.layers(null, ovlLayers).addTo(map); - */ - //地図に地点を表示する(asahi変数はtsuruoka-asahi.geojsonからロードした) - L.marker([asahi["features"][0]["geometry"]["coordinates"][1], asahi["features"][0]["geometry"]["coordinates"][0]], - {title: asahi["features"][0]["properties"]["name"], icon: skyblueIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][0]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][0]["properties"]["html"], - asahi["features"][0]["properties"]["quiz"], - asahi["features"][0]["properties"]["choiceA"], - asahi["features"][0]["properties"]["choiceB"], - asahi["features"][0]["properties"]["choiceC"], - asahi["features"][0]["properties"]["answer"], - asahi["features"][0]["properties"]["stampid"], - asahi["features"][0]["properties"]["stampsrc"], - asahi["features"][0]["properties"]["name"], - asahi["features"][0]["properties"]["description"]); + }).addTo(map); }); - L.marker([asahi["features"][1]["geometry"]["coordinates"][1], asahi["features"][1]["geometry"]["coordinates"][0]], - {title: asahi["features"][1]["properties"]["name"], icon: brownIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][1]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][1]["properties"]["html"], - asahi["features"][1]["properties"]["quiz"], - asahi["features"][1]["properties"]["choiceA"], - asahi["features"][1]["properties"]["choiceB"], - asahi["features"][1]["properties"]["choiceC"], - asahi["features"][1]["properties"]["answer"], - asahi["features"][1]["properties"]["stampid"], - asahi["features"][1]["properties"]["stampsrc"], - asahi["features"][1]["properties"]["name"], - asahi["features"][1]["properties"]["description"]); + var file; + var imageUrl; + document.getElementById("addImage").addEventListener("change", function (e) { + file = e.target.files[0]; + imageUrl = window.URL.createObjectURL(file); }); - L.marker([asahi["features"][2]["geometry"]["coordinates"][1], asahi["features"][2]["geometry"]["coordinates"][0]], - {title: asahi["features"][2]["properties"]["name"], icon: purpleIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][2]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][2]["properties"]["html"], - asahi["features"][2]["properties"]["quiz"], - asahi["features"][2]["properties"]["choiceA"], - asahi["features"][2]["properties"]["choiceB"], - asahi["features"][2]["properties"]["choiceC"], - asahi["features"][2]["properties"]["answer"], - asahi["features"][2]["properties"]["stampid"], - asahi["features"][2]["properties"]["stampsrc"], - asahi["features"][2]["properties"]["name"], - asahi["features"][2]["properties"]["description"]); - }); - L.marker([asahi["features"][3]["geometry"]["coordinates"][1], asahi["features"][3]["geometry"]["coordinates"][0]], - {title: asahi["features"][3]["properties"]["name"], icon: orangeIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][3]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][3]["properties"]["html"], - asahi["features"][3]["properties"]["quiz"], - asahi["features"][3]["properties"]["choiceA"], - asahi["features"][3]["properties"]["choiceB"], - asahi["features"][3]["properties"]["choiceC"], - asahi["features"][3]["properties"]["answer"], - asahi["features"][3]["properties"]["stampid"], - asahi["features"][3]["properties"]["stampsrc"], - asahi["features"][3]["properties"]["name"], - asahi["features"][3]["properties"]["description"]); - }); - L.marker([asahi["features"][4]["geometry"]["coordinates"][1], asahi["features"][4]["geometry"]["coordinates"][0]], - {title: asahi["features"][4]["properties"]["name"]}) - .bindPopup(L.popup().setContent(""+asahi["features"][4]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][4]["properties"]["html"], - asahi["features"][4]["properties"]["quiz"], - asahi["features"][4]["properties"]["choiceA"], - asahi["features"][4]["properties"]["choiceB"], - asahi["features"][4]["properties"]["choiceC"], - asahi["features"][4]["properties"]["answer"], - asahi["features"][4]["properties"]["stampid"], - asahi["features"][4]["properties"]["stampsrc"], - asahi["features"][4]["properties"]["name"], - asahi["features"][4]["properties"]["description"]); - }); - L.marker([asahi["features"][5]["geometry"]["coordinates"][1], asahi["features"][5]["geometry"]["coordinates"][0]], - {title: asahi["features"][5]["properties"]["name"], icon: pinkIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][5]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][5]["properties"]["html"], - asahi["features"][5]["properties"]["quiz"], - asahi["features"][5]["properties"]["choiceA"], - asahi["features"][5]["properties"]["choiceB"], - asahi["features"][5]["properties"]["choiceC"], - asahi["features"][5]["properties"]["answer"], - asahi["features"][5]["properties"]["stampid"], - asahi["features"][5]["properties"]["stampsrc"], - asahi["features"][5]["properties"]["name"], - asahi["features"][5]["properties"]["description"]); - }); - L.marker([asahi["features"][6]["geometry"]["coordinates"][1], asahi["features"][6]["geometry"]["coordinates"][0]], - {title: asahi["features"][6]["properties"]["name"], icon: whiteIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][6]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][6]["properties"]["html"], - asahi["features"][6]["properties"]["quiz"], - asahi["features"][6]["properties"]["choiceA"], - asahi["features"][6]["properties"]["choiceB"], - asahi["features"][6]["properties"]["choiceC"], - asahi["features"][6]["properties"]["answer"], - asahi["features"][6]["properties"]["stampid"], - asahi["features"][6]["properties"]["stampsrc"], - asahi["features"][6]["properties"]["name"], - asahi["features"][6]["properties"]["description"]); - }); - L.marker([asahi["features"][7]["geometry"]["coordinates"][1], asahi["features"][7]["geometry"]["coordinates"][0]], - {title: asahi["features"][7]["properties"]["name"], icon: blackIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][7]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][7]["properties"]["html"], - asahi["features"][7]["properties"]["quiz"], - asahi["features"][7]["properties"]["choiceA"], - asahi["features"][7]["properties"]["choiceB"], - asahi["features"][7]["properties"]["choiceC"], - asahi["features"][7]["properties"]["answer"], - asahi["features"][7]["properties"]["stampid"], - asahi["features"][7]["properties"]["stampsrc"], - asahi["features"][7]["properties"]["name"], - asahi["features"][7]["properties"]["description"]); - }); - L.marker([asahi["features"][8]["geometry"]["coordinates"][1], asahi["features"][8]["geometry"]["coordinates"][0]], - {title: asahi["features"][8]["properties"]["name"], icon: darkgoldIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][8]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][8]["properties"]["html"], - asahi["features"][8]["properties"]["quiz"], - asahi["features"][8]["properties"]["choiceA"], - asahi["features"][8]["properties"]["choiceB"], - asahi["features"][8]["properties"]["choiceC"], - asahi["features"][8]["properties"]["answer"], - asahi["features"][8]["properties"]["stampid"], - asahi["features"][8]["properties"]["stampsrc"], - asahi["features"][8]["properties"]["name"], - asahi["features"][8]["properties"]["description"]); - }); - L.marker([asahi["features"][9]["geometry"]["coordinates"][1], asahi["features"][9]["geometry"]["coordinates"][0]], - {title: asahi["features"][9]["properties"]["name"], icon: redIcon}) - .bindPopup(L.popup().setContent(""+asahi["features"][9]["properties"]["description"]+"
"+"")) - .addTo(map).on("click", () => { - clickMarker(asahi["features"][9]["properties"]["html"], - asahi["features"][9]["properties"]["quiz"], - asahi["features"][9]["properties"]["choiceA"], - asahi["features"][9]["properties"]["choiceB"], - asahi["features"][9]["properties"]["choiceC"], - asahi["features"][9]["properties"]["answer"], - asahi["features"][9]["properties"]["stampid"], - asahi["features"][9]["properties"]["stampsrc"], - asahi["features"][9]["properties"]["name"], - asahi["features"][9]["properties"]["description"]); + // 地点の追加 + function addSpot(){ + // ローカルストレージにデータを保存する + localStorage.setItem("name", document.getElementById("addName").value); + localStorage.setItem("description", document.getElementById("addDesc").value); + localStorage.setItem("address", document.getElementById("addAddress").value); + localStorage.setItem("url", document.getElementById("addUrl").value); + localStorage.setItem("lat", clicklat); + localStorage.setItem("lng", clicklng); + localStorage.setItem("quiz", document.getElementById("addQuiz").value); + localStorage.setItem("choiceA", document.getElementById("addChoiceA").value); + localStorage.setItem("choiceB", document.getElementById("addChoiceB").value); + localStorage.setItem("choiceC", document.getElementById("addChoiceC").value); + localStorage.setItem("answer", document.getElementById("addAnswer").value); + // ローカルストレージからデータを取得する + let name = localStorage.getItem("name"); + let description = localStorage.getItem("description"); + let address = localStorage.getItem("address"); + let url = localStorage.getItem("url"); + let lat = localStorage.getItem("lat"); + let lng = localStorage.getItem("lng"); + let quiz = localStorage.getItem("quiz"); + let choiceA = localStorage.getItem("choiceA"); + let choiceB = localStorage.getItem("choiceB"); + let choiceC = localStorage.getItem("choiceC"); + let answer= localStorage.getItem("answer"); + let stampid = null + let stampsrc = null + // マップに地点を追加する + let popup = "" + description + "
" + address + "
" + url + "" + L.marker([lat, lng], {title: name}).bindPopup(popup) + .addEventListener("click", () => { + clickMarker(imageUrl, quiz, choiceA, choiceB, choiceC, answer, stampid, stampsrc); + }).addTo(map); + console.log(name, lat, lng, url, imageUrl, quiz, choiceA, choiceB, choiceC, answer); + } + document.getElementById("submitButton").addEventListener("click", () => { + addSpot(); + // データベースの処理 + const sqlite3 = require("sqlite3"); + const db = new sqlite3.Database("./test.db"); + db.run("create table if not exists members(name,age)"); + db.run("insert into members(name,age) values(?,?)", "hoge", 33); + db.run("insert into members(name,age) values(?,?)", "foo", 44); + db.each("select * from members", (err, row) => { + console.log(`${row.name} ${row.age}`); + }); + db.close(); }); } -//マーカーの情報に切り替わる -function clickMarker(url, quiz, a, b, c, ans, id, src, pname, explain){ - document.getElementById("model").setAttribute("src", url); +// マーカーの情報への切り替え +function clickMarker(image, quiz, a, b, c, ans, id, src){ + document.getElementById("image").setAttribute("src", image); document.getElementById("quiz").innerHTML = quiz; document.getElementById("a").innerHTML = a; document.getElementById("b").innerHTML = b; @@ -326,10 +145,8 @@ document.getElementById("answer").innerHTML = ans; document.getElementById("stamp-id").innerHTML = id; document.getElementById("stamp-src").innerHTML = src; - document.getElementById("pname").innerHTML = pname; - document.getElementById("explain").innerHTML = explain; } -//解答の判定 +// 解答の判定 function judgeAnswer(abc) { var select = document.getElementById(abc).value; var answer = document.getElementById("answer"); @@ -344,8 +161,16 @@ document.getElementById("result").setAttribute("class", "incorrect"); } } -//選択肢がクリックされたときの処理 +// 入力した内容のリセット +function textReset() { + document.getElementById("addName").value = "" + document.getElementById("addDesc").value = "" + document.getElementById("addLat").value = "" + document.getElementById("addLng").value = "" +} +// ページの読み込みが完了したとき document.addEventListener("DOMContentLoaded", () => { + // 選択肢がクリックされたとき document.getElementById("a").addEventListener("click", () => { judgeAnswer("a"); }); @@ -355,4 +180,7 @@ document.getElementById("c").addEventListener("click", () => { judgeAnswer("c"); }); + document.getElementById("resetButton").addEventListener("click", () => { + textReset(); + }); }); \ No newline at end of file diff --git a/A2teamkadai/quiz_old.html b/A2teamkadai/quiz_old.html index a554b57..69a9732 100644 --- a/A2teamkadai/quiz_old.html +++ b/A2teamkadai/quiz_old.html @@ -7,100 +7,85 @@ - - + - + -問題文
- - - --
マーカーをクリックするとクイズが切り替わります。
- 正解だと思う選択肢を選びましょう。
- ※地点の紹介にヒントが隠されているかも!?
クイズに正解すると、白い丸にスタンプが押されていきます。
-問題文
+ + + ++
名称:
+ 概要:
+ 住所:
+ URL:
+ 画像:
+ 問題文:
+ 選択肢A:
+ 選択肢B:
+ 選択肢C:
+ 解答:
+
+