This commit is contained in:
a-ill
2023-07-22 13:22:35 +03:00
parent 9387cdca70
commit 242c50043d
11 changed files with 197 additions and 85 deletions

View File

@@ -0,0 +1 @@
[{"town":"Atlanta","contact":null,"latitude":33.7243396617476,"longitude":-84.39697265625,"id":9,"members":1,"country":"United States","state":"Georgia"},{"town":null,"contact":null,"latitude":39.98855476000615,"longitude":-105.2105712890625,"id":10,"members":1,"country":"United States","state":"Colorado"},{"town":null,"contact":null,"latitude":28.27955105276024,"longitude":-81.47460937500001,"id":11,"members":1,"country":"United States","state":"Florida"},{"town":"Dublin","contact":null,"latitude":40.13360099478965,"longitude":-83.10607910156251,"id":12,"members":1,"country":"United States","state":"Ohio"},{"town":"Toronto","contact":null,"latitude":43.68959002213805,"longitude":-79.36523437500001,"id":13,"members":1,"country":"Canada","state":"Ontario"},{"town":"Halifax","contact":null,"latitude":44.64996307546047,"longitude":-63.60809326171876,"id":14,"members":1,"country":"Canada","state":"Nova Scotia"},{"town":null,"contact":null,"latitude":53.353612430518126,"longitude":-8.085937500000002,"id":15,"members":1,"country":"Ireland","state":null},{"town":"Cham","contact":null,"latitude":47.18444711300418,"longitude":8.461189270019533,"id":16,"members":1,"country":"Switzerland","state":"Zug"},{"town":"Wiesbaden","contact":null,"latitude":50.085975903187155,"longitude":8.240432739257814,"id":17,"members":1,"country":"Germany","state":"Hesse"},{"town":"Copenhagen","contact":null,"latitude":55.68832070332783,"longitude":12.568359375000002,"id":18,"members":1,"country":"Denmark","state":"Capital Region of Denmark"},{"town":"Kolding","contact":null,"latitude":55.5095568556412,"longitude":9.486694335937502,"id":19,"members":1,"country":"Denmark","state":null},{"town":"Municipal Unit of Moschato","contact":null,"latitude":37.950275539773436,"longitude":23.673992156982425,"id":20,"members":1,"country":"Greece","state":"Attica"},{"town":"Varna","contact":null,"latitude":43.18381722560103,"longitude":27.905273437500004,"id":21,"members":1,"country":"Bulgaria","state":null},{"town":"Riga","contact":null,"latitude":56.966939887376796,"longitude":24.142456054687504,"id":22,"members":1,"country":"Latvia","state":"Vidzeme"},{"town":"Kohtla-Järve linn","contact":null,"latitude":59.40196127188141,"longitude":27.28042602539063,"id":23,"members":1,"country":"Estonia","state":null},{"town":"Tallinn","contact":null,"latitude":59.39656672058008,"longitude":24.72610473655427,"id":24,"members":1,"country":"Estonia","state":null},{"town":"Chiang Mai","contact":null,"latitude":18.796128352413316,"longitude":98.98753015423392,"id":25,"members":1,"country":"Thailand","state":null}]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,4 @@
/*
export let groups = [
{
location: [["Bulgaria","Varna"],[43.21582161671174, 27.89896092161012]],
@@ -85,17 +86,7 @@ export let groups = [
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
}
]
export let groupsByCountry = {}
for (let g of groups) {
let country = g.location[0][0]
if (country in groupsByCountry) {
groupsByCountry[country].push(g)
}
else {
groupsByCountry[country] = [g]
}
}
*/
export let groupsMarkersLayer = L.layerGroup()
let groupsMarkersLayerOut = L.layerGroup()
@@ -116,13 +107,14 @@ export function translate(content, x) {
function addMarkersToLayer(g,layer,content,locale) {
let coordinates
let text = "<b>"+content["Group"]+"</b><br>"
for (let field in g) {
for (let field of ["location","members","contact"]) {
let fieldText = content[field] + ": "
if (field=="contact") {
text += fieldText + "<a href='" + g.contact[0] + "' target='_blank' rel=noreferrer>" + content[g.contact[1]] + "</a>"
text += fieldText + "<a href='" + g.contact + "' target='_blank' rel=noreferrer>" + g.contact + "</a>"
}
else if (field=="location") {
let location = g[field][0]
let location = [g.country,g.state,g.town].filter(x => x!=null && x!=undefined)
let locationString
if (locale=="en") {
locationString = location.map(x => x).join(", ")
@@ -131,7 +123,7 @@ function addMarkersToLayer(g,layer,content,locale) {
locationString = location.map(x => translate(content, x)).join(", ")
}
text += fieldText + locationString + "<br>"
coordinates = g[field][1]
coordinates = [g.latitude,g.longitude]
}
else {
text += fieldText + g[field] + "<br>"
@@ -145,28 +137,29 @@ function addMarkersToLayer(g,layer,content,locale) {
popupAnchor: [1, -34],
shadowSize: [41, 41]
})
//console.log(text)
let marker = L.marker(coordinates, {icon: markerIcon})
marker.addTo(layer).bindPopup(text)
}
export function addMarkersGroups(map,content,locale) {
export function addMarkersGroups(groups,groupsByCountry,map,content,locale) {
for (let g of groups) {
addMarkersToLayer(g,groupsMarkersLayerIn,content,locale)
}
for (let gs of Object.values(groupsByCountry)) {
if (gs.length==1) {
let g = {...gs[0]}
g.location[0] = [g.location[0][0]]
g.country = [g.country]
addMarkersToLayer(g,groupsMarkersLayerOut,content,locale)
}
else {
let locationName = [gs[0].location[0][0]]
let locationName = gs[0].country
let locationCoordinates = [0,0]
let members = 0
let contact = gs[0].contact
for (let g of gs) {
locationCoordinates[0] += g.location[1][0]
locationCoordinates[1] += g.location[1][1]
locationCoordinates[0] += g.latitude
locationCoordinates[1] += g.longitude
members += g.members
if (g.contact[0]!=gs[0].contact[0]) {
contact = contactGeneral
@@ -175,13 +168,16 @@ export function addMarkersGroups(map,content,locale) {
locationCoordinates[0] = locationCoordinates[0]/gs.length
locationCoordinates[1] = locationCoordinates[1]/gs.length
let gNew = {
location: [locationName,locationCoordinates],
country: locationName,
latitude: locationCoordinates[0],
longitude: locationCoordinates[1],
members: members,
contact: contact
}
addMarkersToLayer(gNew,groupsMarkersLayerOut,content,locale)
}
}
groupsMarkersLayerOut.addTo(groupsMarkersLayer)
groupsMarkersLayer.addTo(map)
map.on("zoomend", () => onZoomEnd(map))