-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
858ecc8
commit 386f412
Showing
38 changed files
with
8,857 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"projects": { | ||
"default": "zooproject-taipei" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"firestore": { | ||
"rules": "firestore.rules", | ||
"indexes": "firestore.indexes.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"indexes": [], | ||
"fieldOverrides": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
rules_version = '2'; | ||
service cloud.firestore { | ||
match /databases/{database}/documents { | ||
match /{document=**} { | ||
allow read, write: if | ||
request.time < timestamp.date(2021, 6, 12); | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { Marker, Popup } from "react-leaflet"; | ||
import L from "leaflet"; | ||
import { firebaseGetData } from "../../../Utils/Firebase.js"; | ||
import svg from "../../../Icons/like-02.svg"; | ||
|
||
function FacilitiesMarkers() { | ||
const [facilities, setfacilities] = useState([]); | ||
useEffect(() => { | ||
firebaseGetData("Facilities").then((data) => { | ||
setfacilities(data); | ||
}); | ||
}, []); | ||
|
||
if (!facilities.length) { | ||
return null; | ||
} else if (facilities.length) { | ||
console.log(facilities); | ||
return facilities.map((item, index) => ( | ||
<Marker | ||
key={`fac${item.Index}`} | ||
position={[item.Geo[1], item.Geo[0]]} | ||
icon={ | ||
new L.Icon({ | ||
iconUrl: svg, | ||
iconSize: [5, 5], | ||
iconAnchor: [2.5, 2.5], | ||
}) | ||
} | ||
> | ||
<Popup>{`${item.Title}+${item.Index}`}</Popup> | ||
</Marker> | ||
)); | ||
} | ||
} | ||
|
||
export default FacilitiesMarkers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { Marker } from "react-leaflet"; | ||
import L from "leaflet"; | ||
import { firebaseAddData, firebaseGetData } from "../../../Utils/Firebase.js"; | ||
|
||
function PavilionsMarkers() { | ||
const [pavilions, setPavilions] = useState([]); | ||
useEffect(() => { | ||
firebaseGetData("Pavilion").then((data) => { | ||
setPavilions(data); | ||
}); | ||
}, []); | ||
|
||
if (!pavilions.length) { | ||
return null; | ||
} else if (pavilions.length) { | ||
return pavilions.map((item, index) => ( | ||
<Marker | ||
key={index} | ||
position={item.Geo} | ||
icon={ | ||
new L.Icon({ | ||
iconUrl: require(`../../../Icons/${item.Name}.svg`).default, | ||
iconSize: [150, 90], | ||
iconAnchor: [75, 45], | ||
}) | ||
} | ||
></Marker> | ||
)); | ||
} | ||
} | ||
|
||
export default PavilionsMarkers; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet"; | ||
import L from "leaflet"; | ||
import svg from "../../icons/like-02.svg"; | ||
|
||
const position = [24.996, 121.585]; | ||
import PavilionsMarkers from "./Markers/PavilionsMarker.js"; | ||
import FacilitiesMarkers from "./Markers/FacilitiesMarkers.js"; | ||
import { | ||
firebaseAddData, | ||
firebaseGetData, | ||
firebaseAddFacilities, | ||
} from "../../Utils/Firebase.js"; | ||
import facility from "../../Utils/facilities.json"; | ||
|
||
function Markers() { | ||
const iconPerson = new L.Icon({ | ||
iconUrl: svg, | ||
iconSize: [15, 15], | ||
iconAnchor: [7.5, 7.5], | ||
}); | ||
|
||
return <Marker key={5} position={position} icon={iconPerson}></Marker>; | ||
return ( | ||
<> | ||
<PavilionsMarkers /> | ||
<FacilitiesMarkers /> | ||
</> | ||
); | ||
} | ||
|
||
export default Markers; | ||
export { Markers }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import firebase from "firebase"; | ||
|
||
const firebaseConfig = { | ||
apiKey: "AIzaSyCI3Hmv_gjjmFzRO-t0BngdDIKCcaSlyeM", | ||
authDomain: "zooproject-taipei.firebaseapp.com", | ||
projectId: "zooproject-taipei", | ||
storageBucket: "zooproject-taipei.appspot.com", | ||
messagingSenderId: "96578304850", | ||
appId: "1:96578304850:web:6f511770927ca18279588b", | ||
measurementId: "G-6SSVE3J0KN", | ||
}; | ||
firebase.initializeApp(firebaseConfig); | ||
var db = firebase.firestore(); | ||
|
||
const firebaseAddAnimals = (data) => { | ||
data.forEach((item) => { | ||
db.collection("Animals") | ||
.doc(item.Name_Ch) | ||
.set({ | ||
AlsoKnow: item.AlsoKnown, | ||
Behavior: item.Behavior, | ||
Class: item.Class, | ||
Code: item.Code, | ||
Conservation: item.Conservation, | ||
Crisis: item.Crisis, | ||
Diet: item.Diet, | ||
Distribution: item.Distribution, | ||
Family: item.Family, | ||
Feature: item.Feature, | ||
Geo: item.Geo, | ||
Habitat: item.Habitat, | ||
Location: item.Location, | ||
Name_Ch: item.Name_Ch, | ||
Name_En: item.Name_En, | ||
Order: item.Order, | ||
Phylum: item.Phylum, | ||
PicURL: item.Pic01_URL, | ||
}) | ||
.then(() => { | ||
console.log("ok"); | ||
}) | ||
.catch((error) => { | ||
console.error("Error writing document: ", error); | ||
}); | ||
}); | ||
}; | ||
|
||
const firebaseAddFacilities = (data) => { | ||
data.forEach((item, index) => { | ||
db.collection("Facilities") | ||
.doc() | ||
.set({ | ||
Index: index, | ||
Brief: item.Brief, | ||
Keywords: item.Keywords, | ||
Geo: item.Geo, | ||
Category: item.Category, | ||
Item: item.Item, | ||
Meal: item.Meal, | ||
Memo: item.Memo, | ||
Pic01_ALT: item.Pic01_ALT, | ||
Shop: item.Shop, | ||
Summary: item.Summary, | ||
Title: item.Title, | ||
}) | ||
.then(() => { | ||
console.log("OK"); | ||
}); | ||
}); | ||
}; | ||
|
||
const firebaseAddData = () => { | ||
db.collection("city") | ||
.doc("LA") | ||
.set({ | ||
name: "Los Angeles", | ||
state: "CA", | ||
country: "USA", | ||
}) | ||
.then(() => { | ||
console.log("Document successfully written!"); | ||
}) | ||
.catch((error) => { | ||
console.error("Error writing document: ", error); | ||
}); | ||
}; | ||
|
||
const firebaseGetData = (collection) => { | ||
return db | ||
.collection(collection) | ||
.get() | ||
.then((querySnapshot) => { | ||
let firebaseData = []; | ||
querySnapshot.forEach((doc) => { | ||
firebaseData.push(doc.data()); | ||
}); | ||
return firebaseData; | ||
}); | ||
}; | ||
|
||
export { | ||
firebaseAddData, | ||
firebaseGetData, | ||
firebaseAddFacilities, | ||
firebaseAddAnimals, | ||
}; |
Oops, something went wrong.