diff --git a/family-tracker/src/App.css b/family-tracker/src/App.css
index 664b79b..ebb104a 100644
--- a/family-tracker/src/App.css
+++ b/family-tracker/src/App.css
@@ -22,6 +22,51 @@
}
}
+.fadein {
+ animation-name: fadein;
+ animation-duration: 4s;
+}
+.badfadein {
+ animation-name: badfadein;
+ animation-duration: 4s;
+ background-color:#faa;
+}
+.badchildfadein {
+ animation-name: badchildfadein;
+ animation-duration: 4s;
+ background-color:#fae;
+}
+
+.tinytime{
+ font-size:12px;
+ position:absolute;
+ bottom:4px;
+ right:7px;
+ /*z-index:-10000;*/
+ color:#666;
+ font-style:italic;
+ /*background-color:rgba(240,240,255,0.8);*/
+}
+
+@keyframes fadein {
+ 0% {opacity:0;
+ background-color:#6ef;}
+ 100% {opacity:1;
+ background-color:#fff;}
+}
+@keyframes badfadein {
+ 0% {opacity:0;
+ background-color:#f00;}
+ 100% {opacity:1;
+ background-color:#faa;}
+}
+@keyframes badchildfadein {
+ 0% {opacity:0;
+ background-color:#f0a;}
+ 100% {opacity:1;
+ background-color:#fae;}
+}
+
.App-header {
background-color: #282c34;
min-height: 100vh;
diff --git a/family-tracker/src/App.js b/family-tracker/src/App.js
index 055c105..b24787a 100644
--- a/family-tracker/src/App.js
+++ b/family-tracker/src/App.js
@@ -12,20 +12,183 @@ import {
const axios = require('axios');
+var mapX=-110.267
+var mapY=31.544
+var mapXScale=0.00005
+var mapYScale=0.00005
+var ctx=undefined,locations=[],mousePos={x:0,y:0},members=[],requiresUpdate=false;
+function getMousePos(canvas, evt) {
+ var rect = canvas.getBoundingClientRect();
+ return {
+ x: evt.clientX - rect.left,
+ y: evt.clientY - rect.top
+ };
+}
+setInterval(()=>{
+ if (document.getElementById("map")!==null) {
+ var c = document.getElementById("map");
+ //console.log("Update map.")
+ requiresUpdate=!requiresUpdate;
+ if (ctx===undefined||ctx===null) {
+ ctx = c.getContext("2d");
+ //Draw all known locations.
+ axios.get("http://localhost:8080/knownlocation")
+ .then((data)=>{locations=data.data})
+ } else {
+ ctx.clearRect(0, 0, c.width, c.height);
+ for (var loc of locations) {
+ ctx.beginPath();
+ if (loc.safe) {
+ ctx.fillStyle="#6a6"
+ } else {
+ ctx.fillStyle="#a66"
+ }
+ ctx.arc((loc.x-mapX)/mapXScale,(loc.y-mapY)/mapYScale,10,0,2*Math.PI)
+ ctx.fill();
+ }
+ for (var m of members) {
+ ctx.beginPath();
+ ctx.fillStyle="#22f"
+ ctx.arc((m.x-mapX)/mapXScale,(m.y-mapY)/mapYScale,5,0,2*Math.PI);
+ ctx.fill();
+ }
+ ctx.font = "22px Verdana";
+ for (var loc of locations) {
+ if (mousePos.x>=(loc.x-mapX)/mapXScale-7 && mousePos.x<=(loc.x-mapX)/mapXScale+7 &&
+ mousePos.y>=(loc.y-mapY)/mapYScale-7 && mousePos.y<=(loc.y-mapY)/mapYScale+7) {
+ var size = ctx.measureText(loc.name)
+ ctx.fillStyle="#eef"
+ ctx.fillRect(mousePos.x-size.width/2-2,mousePos.y-30,size.width+4,24)
+ ctx.fillStyle="#000"
+ ctx.fillText(loc.name,mousePos.x-size.width/2,mousePos.y-8)
+ }
+ }
+ var labelY = -30;
+ ctx.font = "14px Verdana";
+ for (var m of members) {
+ if (mousePos.x>=(m.x-mapX)/mapXScale-7 && mousePos.x<=(m.x-mapX)/mapXScale+7 &&
+ mousePos.y>=(m.y-mapY)/mapYScale-7 && mousePos.y<=(m.y-mapY)/mapYScale+7) {
+ var size = ctx.measureText(m.firstName+" "+m.lastName)
+ ctx.fillStyle="#eef"
+ ctx.fillRect(mousePos.x-size.width/2-2,mousePos.y-20+labelY,size.width+4,14)
+ ctx.fillStyle="#000"
+ ctx.fillText(m.firstName+" "+m.lastName,mousePos.x-size.width/2,mousePos.y-8+labelY)
+ labelY-=20;
+ }
+ }
+ }
+ } else {
+ ctx=null;
+ }
+},50)
+
function Map(p) {
- p.setActive("/map")
+ const [familyId,setFamilyId] = useState(0)
+ const [family,setFamily] = useState([])
+
+ useEffect(()=>{
+ p.setActive("/map")
+ })
+ useEffect(()=>{
+ if (p.family[familyId]) {
+ members=p.family[familyId].members
+ //console.log(members)
+ }
+ },[p.family])
+ useEffect(()=>{
+ if (family[familyId]) {
+ members=family[familyId].members
+ //console.log(members)
+ }
+ },[family])
+ useEffect(()=>{
+
+ const interval = setInterval(()=>{
+ axios.get("http://localhost:8080/family")
+ .then((data)=>{setFamily(data.data)})
+ },50)
+ return () => clearInterval(interval);
+ },[requiresUpdate])
return (
<>
Map View
+
+