site-libsoc/Server/app/svelte/public/js/communes.js

76 lines
2.6 KiB
JavaScript
Raw Normal View History

2023-06-24 20:44:16 +07:00
2023-07-12 05:42:33 +07:00
export let communes = [
2023-07-10 18:09:25 +07:00
{
2023-07-13 18:32:49 +07:00
location: [["Canada","Montreal"],[45.55541047232767, -73.42859611607271]],
2023-07-10 18:09:25 +07:00
status: "forming",
members: 2,
2023-07-15 18:29:26 +07:00
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
2023-07-10 18:09:25 +07:00
},
2023-07-16 18:15:53 +07:00
{
2023-07-16 20:56:28 +07:00
location: [["Denmark"],[55.915625218626275, 9.673445220831253]],
2023-07-16 18:15:53 +07:00
status: "forming",
members: 1,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
},
2023-06-24 20:44:16 +07:00
{
2023-07-13 18:32:49 +07:00
location: [["Estonia","KohtlaJarve"],[59.409521829709504, 27.288415912535914]],
2023-07-09 19:25:09 +07:00
status: "forming",
2023-06-24 20:44:16 +07:00
members: 2,
2023-07-15 18:29:26 +07:00
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
2023-07-11 21:36:09 +07:00
},
{
2023-07-16 20:56:28 +07:00
location: [["Latvia"],[56.934159375258055, 25.269099001330265]],
2023-07-11 21:36:09 +07:00
status: "forming",
members: 1,
2023-07-15 18:29:26 +07:00
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
2023-06-24 20:44:16 +07:00
}
]
2023-07-13 18:32:49 +07:00
export let communesByCountry = {}
for (let c of communes) {
let country = c.location[0][0]
if (country in communesByCountry) {
communesByCountry[country].push(c)
}
else {
communesByCountry[country] = [c]
}
}
2023-07-15 02:27:11 +07:00
export let communesMarkersLayer = L.layerGroup()
2023-07-12 05:42:33 +07:00
export function addMarkersCommunes(map,content) {
for (let g of communes) {
2023-06-24 20:44:16 +07:00
let coordinates
2023-07-16 18:22:48 +07:00
let text = "<b>"+content["Commune"]+"</b><br>"
2023-06-24 20:44:16 +07:00
for (let field in g) {
2023-07-03 03:07:45 +07:00
let fieldText = content[field] + ": "
2023-06-24 20:44:16 +07:00
if (field=="contact") {
2023-07-09 19:25:09 +07:00
text += fieldText + "<a href='" + g.contact[0] + "' target='_blank' rel=noreferrer>" + content[g.contact[1]]+ "</a>"
2023-06-24 20:44:16 +07:00
}
else if (field=="location") {
2023-07-13 18:32:49 +07:00
let location = g[field][0]
2023-07-16 20:56:28 +07:00
let locationString = location.map(x => content[x]).join(", ")
text += fieldText + locationString + "<br>"
2023-06-24 20:44:16 +07:00
coordinates = g[field][1]
}
2023-07-03 03:07:45 +07:00
else if (field=="status") {
2023-07-09 19:25:09 +07:00
text += fieldText + content[g[field]] + "<br>"
2023-07-03 03:07:45 +07:00
}
2023-06-24 20:44:16 +07:00
else {
text += fieldText + g[field] + "<br>"
}
}
2023-07-10 21:22:33 +07:00
var markerIcon = new L.Icon({
2023-07-10 21:37:04 +07:00
iconUrl: 'https://www.libsoc.org/img/common/markers/marker-red.png',
2023-06-24 20:44:16 +07:00
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
2023-07-10 21:22:33 +07:00
let marker = L.marker(coordinates, {icon: markerIcon})
2023-07-15 02:27:11 +07:00
marker.addTo(communesMarkersLayer).bindPopup(text)
2023-06-24 20:44:16 +07:00
}
2023-07-15 02:27:11 +07:00
communesMarkersLayer.addTo(map)
2023-06-24 20:44:16 +07:00
}