Compare commits

..

2 commits

Author SHA1 Message Date
vanten-s a7340ba96b
Switched to Hugo 2024-07-21 19:41:39 +02:00
vanten-s 264bb79bfb
Removed submodules 2024-07-20 22:23:28 +02:00
163 changed files with 664 additions and 132663 deletions

6
.gitignore vendored
View file

@ -1,4 +1,2 @@
venv/ .hugo_build.lock
log.txt public
src/rss.xml
__pycache__/

12
.gitmodules vendored
View file

@ -1,9 +1,3 @@
[submodule "frmWrk"] [submodule "themes/hugo-xterm"]
path = frmWrk path = themes/hugo-xterm
url = https://github.com/vanten-s/frmWrk.git url = https://github.com/manid2/hugo-xterm.git
[submodule "feed_generator"]
path = feed_generator
url = https://forgejo.vanten-s.com/vanten-s/feed_generator.git
[submodule "feed_articles"]
path = feed_articles
url = https://forgejo.vanten-s.com/vanten-s/feed_articles.git

5
archetypes/default.md Normal file
View file

@ -0,0 +1,5 @@
+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }}
draft = true
+++

19
content/_index.md Normal file
View file

@ -0,0 +1,19 @@
+++
title = "Vanten"
date = "2024-07-20T22:26:48+02:00"
draft = false
+++
# Hii
I'm vanten. A software engineer and child from Sweden.
My geekcode:
```text
-----BEGIN GEEK CODE BLOCK-----
version: 3.1
gcs/gg d--(---) s+ a---- C++ UL+++ P L+++>++++ E- W++ N+ o? K? w--
O? M- V? PS++ PE-- Y+ PGP++ t- 5? X? R tv b+ DI? D+ G e-- h! r-
------END GEEK CODE BLOCK------
```

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 253 B

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 820 B

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 531 B

View file

Before

Width:  |  Height:  |  Size: 439 B

After

Width:  |  Height:  |  Size: 439 B

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 581 B

After

Width:  |  Height:  |  Size: 581 B

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 471 B

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

Before

Width:  |  Height:  |  Size: 411 B

After

Width:  |  Height:  |  Size: 411 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 483 B

After

Width:  |  Height:  |  Size: 483 B

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

5
content/posts/_index.md Normal file
View file

@ -0,0 +1,5 @@
+++
title = 'Posts'
date = 2024-07-21T14:52:15+02:00
draft = true
+++

12
content/posts/postage.md Normal file
View file

@ -0,0 +1,12 @@
+++
title = "Postage"
date = "2024-07-20T22:26:48+02:00"
tags = ["lowlevel"]
draft = true
summary = "IPoL (IP over Letters) + kernel module == true"
+++
## Introduction
I was talking with some friends...

@ -1 +0,0 @@
Subproject commit f1c8432ca24fe417f0979b1ac86f64b710818a1d

@ -1 +0,0 @@
Subproject commit a7d96ea52ffa42139ac5466b5ea7d5aa3ee7900b

1
frmWrk

@ -1 +0,0 @@
Subproject commit b454f70fbb366ad8b6ec84c8a6d3ca47549264f2

21
hugo.toml Normal file
View file

@ -0,0 +1,21 @@
baseURL = 'https://vanten-s.com/'
languageCode = 'en-us'
title = 'Vanten'
theme = 'vanten'
[markup]
[markup.highlight]
anchorLineNos = false
codeFences = true
guessSyntax = false
hl_Lines = ''
hl_inline = false
lineAnchors = ''
lineNoStart = 1
lineNos = true
lineNumbersInTable = true
noClasses = false
noHl = false
style = 'false'
tabWidth = 4

51
main.py
View file

@ -1,51 +0,0 @@
import frmWrk.website as website
import feed_generator
import pathlib
from time import sleep
article_base_html = ""
with open("src/article.html") as article_html:
article_base_html = article_html.read()
articles_base_html = ""
with open("src/articles.html") as articles_html:
articles_base_html = articles_html.read()
def article_list():
article_paths = (pathlib.Path.cwd() / "feed_articles").glob("[0-9]*")
article_paths_sorted = sorted(article_paths, key=lambda x: x.name, reverse=True)
metadatas = [(feed_generator.convert_markdown_to_html(path)[1], path.parts[-1]) for path in article_paths_sorted]
print(metadatas)
elements = ['<li><a href="articles.html?{guid}">{title} ({guid})</a></li>'.format(title=metadata[0]["title"][0], guid=metadata[1]) for metadata in metadatas]
return articles_base_html.format(elements="\n".join(elements))
def article(path):
if not "?" in path:
return article_list()
article_name = path.split("?")[1]
article_html = feed_generator.convert_markdown_to_html(pathlib.Path("feed_articles") / article_name)
return article_base_html.format(body=article_html[0])
if __name__ == "__main__":
webserver = website.WebServer("", 3000, "./src", overwrites={"/articles.html": article})
webserver.start()
while True:
feed = feed_generator.make_rss_feed("feed_articles", "Vantens", "https://vanten-s.com/", "Vantens personal feed")
with open("src/rss.xml", "w") as f:
f.write(feed)
try:
sleep(15)
except KeyboardInterrupt:
break
webserver.close()

View file

@ -1 +0,0 @@
markdown

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"Target":"styles.css","MediaType":"text/css","Data":{}}

7
shell.nix Normal file
View file

@ -0,0 +1,7 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell rec {
buildInputs = with pkgs; [
hugo
];
}

View file

@ -1,73 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Article</title>
<link rel="stylesheet" href="assets/main.css">
<link rel="stylesheet" href="assets/fontAwesome/css/fontawesome.css">
<link rel="stylesheet" href="assets/fontAwesome/css/brands.css">
<link rel="stylesheet" href="assets/fontAwesome/css/solid.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hack-font/3.3.0/web/hack.min.css">
<link rel="icon" href="/assets/favicon.png">
</head>
<body>
<div id="body" style="padding-right: 5em; max-width: 35em;">
{body}
</div>
<ul class="navbar">
<li>
<a href="mailto:vanten-s@vanten-s.com">
<span class="popup">Mail</span>
<i class="fa-solid fa-envelope fa"></i>
</a>
</li>
<li>
<a rel="me" href="https://fedi.vanten-s.com/@vanten_s">
<span class="popup">Mastodon</span>
<i class="fa-brands fa-mastodon fa"></i>
</a>
</li>
<li>
<a href="key.asc">
<span class="popup">GPG Key</span>
<i class="fa-solid fa-key"></i>
</a>
</li>
<li>
<a href="https://matrix.to/#/@vanten-s:matrix.org">
<span class="popup">Matrix</span>
<i class="fa-solid fa-comment"></i>
</a>
</li>
<li>
<a href="https://forgejo.vanten-s.com/vanten-s">
<span class="popup">Forgejo</span>
<i class="fa-brands fa-git-alt"></i>
</a>
</li>
<li>
<a href="rss.xml">
<span class="popup">RSS Feed</span>
<i class="fa-solid fa-square-rss"></i>
</a>
</li>
<li>
<a href="articles.html">
<span class="popup">Posts</span>
<i class="fa-solid fa-blog"></i>
</a>
</li>
<li>
<a href="/">
<span class="popup">Home</span>
<i class="fa-solid fa-home"></i>
</a>
</li>
<li>
<a href="/uwubible.txt">
<span class="popup">UwU Bible</span>
<i class="fa-solid fa-book-bible"></i>
</a>
</li>
</ul>
</body>
</html>

View file

@ -1,72 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Articles</title>
<link rel="stylesheet" href="assets/main.css">
<link rel="stylesheet" href="assets/fontAwesome/css/fontawesome.css">
<link rel="stylesheet" href="assets/fontAwesome/css/brands.css">
<link rel="stylesheet" href="assets/fontAwesome/css/solid.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hack-font/3.3.0/web/hack.min.css">
<link rel="icon" href="/assets/favicon.png">
</head>
<body>
<h1>Posts</h1>
{elements}
<ul class="navbar">
<li>
<a href="mailto:vanten-s@vanten-s.com">
<span class="popup">Mail</span>
<i class="fa-solid fa-envelope fa"></i>
</a>
</li>
<li>
<a rel="me" href="https://fedi.vanten-s.com/@vanten_s">
<span class="popup">Mastodon</span>
<i class="fa-brands fa-mastodon fa"></i>
</a>
</li>
<li>
<a href="key.asc">
<span class="popup">GPG Key</span>
<i class="fa-solid fa-key"></i>
</a>
</li>
<li>
<a href="https://matrix.to/#/@vanten-s:matrix.org">
<span class="popup">Matrix</span>
<i class="fa-solid fa-comment"></i>
</a>
</li>
<li>
<a href="https://forgejo.vanten-s.com/vanten-s">
<span class="popup">Forgejo</span>
<i class="fa-brands fa-git-alt"></i>
</a>
</li>
<li>
<a href="rss.xml">
<span class="popup">RSS Feed</span>
<i class="fa-solid fa-square-rss"></i>
</a>
</li>
<li>
<a href="articles.html">
<span class="popup">Posts</span>
<i class="fa-solid fa-blog"></i>
</a>
</li>
<li>
<a href="/">
<span class="popup">Home</span>
<i class="fa-solid fa-home"></i>
</a>
</li>
<li>
<a href="/uwubible.txt">
<span class="popup">UwU Bible</span>
<i class="fa-solid fa-book-bible"></i>
</a>
</li>
</ul>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,19 +0,0 @@
/*!
* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2023 Fonticons, Inc.
*/
:root, :host {
--fa-style-family-classic: 'Font Awesome 6 Free';
--fa-font-solid: normal 900 1em/1 'Font Awesome 6 Free'; }
@font-face {
font-family: 'Font Awesome 6 Free';
font-style: normal;
font-weight: 900;
font-display: block;
src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); }
.fas,
.fa-solid {
font-weight: 900; }

View file

@ -1,120 +0,0 @@
:root {
--base: #1e1e2e;
--mantle: #181825;
--text: #cdd6f4;
--link: #94e2d5;
--surface: #313244;
--pink: #f5c2e7;
}
body {
font-family: Hack, monospace;
background-color: var(--mantle);
color: var(--text);
padding: 5em;
margin: 0;
}
img {
padding: 1em;
}
.navbar {
/* Positioning */
top: 0;
margin-top: 0;
right: 0;
position: fixed;
/* Size */
height: 100vh;
width: 4.5em;
padding: 0;
/* Markers */
list-style-type: none;
background-color: var(--surface);
display: flex;
flex-direction: column;
align-items: center;
}
.navbar > li {
width: 3em;
height: 3em;
margin: 0.5em;
display: flex;
align-items: center;
justify-content: center;
background-color: var(--mantle);
text-align: center;
border-radius: 100%;
outline: var(--pink) 0.2rem solid;
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.navbar > li:hover {
border-radius: 30%;
background-color: var(--link);
outline: var(--pink) 0 solid;
}
.navbar > li:hover > a {
color: var(--base);
}
.navbar > li > a > i {
font-size: 1.5em;
}
.navbar > li > a > .popup {
position: absolute;
right: 6em;
scale: 0;
background-color: var(--base);
color: var(--link);
padding: .5em;
white-space: nowrap;
font-weight: bold;
border-radius: 0.75rem;
outline: var(--pink) 0.2rem solid;
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.navbar > li:hover > a > .popup {
scale: 100%;
}
a {
color: var(--link);
text-decoration: underline var(--mantle) auto;
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
a:hover {
text-decoration: underline var(--link) auto;
}
.buttons {
display: flex;
width: 40em;
flex-wrap: wrap;
}
.buttons > img {
padding: 0.15em;
width: 88px;
height: 31px;
}
.buttons > a > img {
padding: 0.15em;
width: 88px;
height: 31px;
}

View file

@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGooKx47UKeIGxy8uqgaQzsJ48n/6hC/gtmHls+3f0a9 svante@nixos

View file

@ -1,172 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Homepage</title>
<link rel="stylesheet" href="assets/main.css">
<link rel="stylesheet" href="assets/fontAwesome/css/fontawesome.css">
<link rel="stylesheet" href="assets/fontAwesome/css/brands.css">
<link rel="stylesheet" href="assets/fontAwesome/css/solid.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hack-font/3.3.0/web/hack.min.css">
<link rel="icon" href="/assets/favicon.png">
</head>
<body>
<h1>Vanten</h1>
<p>Software dev, OSS enthusiast, server admin and 13 year old</p>
<p>Maybe script kiddie idk</p>
<h3>Weird computer thingys that I know</h3>
<ul>
<li>Rust </li>
<li>Python </li>
<li>Some C++ </li>
<li>Java </li>
<li>Bash </li>
<li>Processor design </li>
<li>Server administration</li>
</ul>
<h3>Projects</h3>
<ul>
<li><a href="https://forgejo.vanten-s.com/vanten-s/vanten-s.com">This website</a> </li>
<li><a href="https://forgejo.vanten-s.com/vanten-s/e2e-irc" >An end-to-end encrypted IRC bouncer</a></li>
<li><a href="https://forgejo.vanten-s.com/vanten-s/plonkus" >The Plonkus language</a> </li>
<li><a href="https://github.com/vanten-s/frmWrk" >The webserver this is running on</a> </li>
<li><a href="https://github.com/vanten-s/8bit-computer" >Pretty simple 8 bit processor</a> </li>
</ul>
<h3>Weird things that run on my server</h3>
<ul>
<li><a href="rss.xml" >RSS feed</a></li>
<li><a href="https://forgejo.vanten-s.com/">Forgejo</a> </li>
<li><a href="https://fedi.vanten-s.com" >Firefish</a></li>
<li><a href="ircs://irc.vanten-s.com" >IRC</a> </li>
</ul>
<p>
|_|0|_|<br>
|_|_|0|<br>
|0|0|0|<br>
</p>
<div class="buttons">
<img src="buttons/animegay.gif">
<img src="buttons/antifa.gif">
<img src="buttons/anythingbut.gif">
<img src="buttons/crushit.gif">
<img src="buttons/dbd.gif">
<img src="buttons/ddg.gif">
<img src="buttons/discord-no-way.gif">
<img src="buttons/doomrl.gif">
<a href="https://cyber.dabamos.de/88x31/">
<img src="buttons/eightyeight.gif">
</a>
<img src="buttons/evilnet.gif">
<img src="buttons/fediverse.gif">
<img src="buttons/fspeech.gif">
<img src="buttons/graphic-design.gif">
<img src="buttons/hehimm.png">
<img src="buttons/home-assistant.gif">
<a href="https://leap123.neocities.org">
<img src="buttons/leap123.gif">
</a>
<img src="buttons/linux-now.gif">
<a href="https://neocities.org">
<img src="buttons/neocities.gif">
</a>
<img src="buttons/nft.gif">
<img src="buttons/nocookie.gif">
<img src="buttons/no_fkn_thanks.gif">
<img src="buttons/onyx.gif">
<img src="buttons/say-no-to-web3.gif">
<img src="buttons/scouting.gif">
<img src="buttons/tiktok.gif">
<img src="buttons/transnow2.gif">
<img src="buttons/ublock.png">
<img src="buttons/vanten-s.gif">
<img src="buttons/vim_a.gif">
<img src="buttons/vim.gif">
<img src="buttons/vim.vialle.love.anim.gif">
<img src="buttons/web11badge.gif">
<img src="buttons/web3.gif">
<img src="buttons/webpassion.gif">
<img src="buttons/wikipedia.gif">
</div>
<ul class="navbar">
<li>
<a href="mailto:vanten-s@vanten-s.com">
<span class="popup">Mail</span>
<i class="fa-solid fa-envelope fa"></i>
</a>
</li>
<li>
<a rel="me" href="https://fedi.vanten-s.com/@vanten_s">
<span class="popup">Mastodon</span>
<i class="fa-brands fa-mastodon fa"></i>
</a>
</li>
<li>
<a href="key.asc">
<span class="popup">GPG Key</span>
<i class="fa-solid fa-key"></i>
</a>
</li>
<li>
<a href="https://matrix.to/#/@vanten-s:matrix.org">
<span class="popup">Matrix</span>
<i class="fa-solid fa-comment"></i>
</a>
</li>
<li>
<a href="https://forgejo.vanten-s.com/vanten-s">
<span class="popup">Forgejo</span>
<i class="fa-brands fa-git-alt"></i>
</a>
</li>
<li>
<a href="rss.xml">
<span class="popup">RSS Feed</span>
<i class="fa-solid fa-square-rss"></i>
</a>
</li>
<li>
<a href="articles.html">
<span class="popup">Posts</span>
<i class="fa-solid fa-blog"></i>
</a>
</li>
<li>
<a href="/">
<span class="popup">Home</span>
<i class="fa-solid fa-home"></i>
</a>
</li>
<li>
<a href="/uwubible.txt">
<span class="popup">UwU Bible</span>
<i class="fa-solid fa-book-bible"></i>
</a>
</li>
<li>
<a href="https://fediring.net/next?host=vanten-s.com">
<span class="popup">Next</span>
<i class="fa-solid fa-up-long"></i>
</a>
</li>
<li>
<a href="https://fediring.net/previous?host=vanten-s.com">
<span class="popup">Previous</span>
<i class="fa-solid fa-down-long"></i>
</a>
</li>
<li>
<a href="https://fediring.net">
<span class="popup">Fediring</span>
<i class="fa-solid fa-circle-nodes"></i>
</a>
</li>
</ul>
</body>
</html>

View file

@ -1,41 +0,0 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBGSr42ABDAC4mZ8Li7Z8P2BHkAU8Rku5og9nmUn19hGQIXQuI+8/e7MAlKOm
E74d83S5ZY0E/42Ne5w0+JpCrS+sDZio0sNmr62S5OMYBWVGdfJXIedG9WaMzRyg
ZwoN1qdFGnKJmK/f7qJpCwHLvJRLq50L0XNVclynBycCwuF3baSuZUf5jAkbTAFQ
oYECr/kQlBh2Cectv4h3TfeW0WS4OU5KCVWD17Rn0qu56ahlMhFic8K7LkU7CPT2
1a0xsFyOixy/j5KmTF2Oit6uZU8vr59SydiVfaris+fal1FSeT1E1a3DmmhsXQka
sXP22+ar9tJbHwgI1200Epa1eQzIy72YVW2YDyJ8T3iEkC9q35AYxKadDLwjnUpD
zEudEtZ+g/onk0qB7TqXcnSp92kAAcXhVLGwid1tX9QhFespryZP/dawNR5F3jM1
+6fTQhCX4Yci+NEWscS1p64Kuow8SEmoaLJVfTX3fCpInGr8+6xtmOIzQ34WVqnV
9mWrO834JEpnwDkAEQEAAbQVdmFudGVuLXNAdmFudGVuLXMuY29tiQHUBBMBCAA+
FiEEWNejRYw2Vm4giKBK3jBgOWiE0/IFAmSr42ACGwMFCQPCZwAFCwkIBwIGFQoJ
CAsCBBYCAwECHgECF4AACgkQ3jBgOWiE0/LA5wv9GayoDU/Hjbdo4knmWDgsmZMe
Oq6vqIs3Z6kusAl8mRH80Hs1bWMFIPMxgbnvQhSJl4POA0kSv++Y9pR374z+yx+s
e/9BbnFLLIxLozSrGGnYU74uMQqNVV2pmCJs8hSf3VV/YwvgMIi4CeHEzUMCFFsz
RcOO0iayF0EeEtVeI6riQ5fJVk6THrSpD4hUy0h/dUSZ+wF/zZ5z1NN4n/jOw2kx
oqfDJftDBi0qYfNVBQy/RvpaBH2QWE8cCQlO7IiHo2IdPcsQZLYEINZ9PIXjvrcE
qQbHh5kc3ZG9emtHgm6BSPJlsolJ6Jo2zWkD7Bscg62JkX32JbOkpE3+T61V2I5o
TQPXvA660z6nUO9d0/3rUf8mfoRTotquiKmcjttklGRNOAnmbeAuf3Po3FzQqZA+
fLgrVECyhnURNLZ+8/KyX1K7kQ86hvd9vzt2qGjfaA0vVD8mRW9vzWJQgVhEAlf8
zfUSlGPUMRbiGBdz8t95Pz2056uOURCuc4O0ykeCuQGNBGSr42ABDADRziSWvMJe
0t+pj2dv/C1TJxez8ZH/0XoOGEcZ310IK7zv6r/oSpqGDb1438tatScsY0cl/ZZ5
+2ry2VDBTX0H2HkQKSMgdldXiOo3t1JvjLKfdowsvi77BYvLFjHOfb9HbqiiU218
arjDDnu98xYTTXu2bbvhCB6Rynfbs8ySC9I7goeC47mdDc9khN2Ofc+GZxbloYut
+Nt8U/6D2ut3wEuqEalEPo/ahpoX9guoLCF81/82fOPQCsmsKm2ta5HSOyJg1O4o
lfKzsVvhu3BkbDmJjY9alVhrD7KO5dmfGQCwiVm3eWfBr281zTXhKjgFcdeVI+sO
iQmUWcMf79hG3bdaHJmnREboFjJteefrJEoM0N1vfqTpZ7vith57fKUicTfiQjp9
UVP/zO13b00zJ6tZnnicEbeuh74HpwX6eMTdl6epS00oihDE4RWc2qdIE0SfoOV+
8qypZSquCKfYdk1s/FAFHKRnq4znZP5VjwuXb9FR/GDwZe157OYANxUAEQEAAYkB
vAQYAQgAJhYhBFjXo0WMNlZuIIigSt4wYDlohNPyBQJkq+NgAhsMBQkDwmcAAAoJ
EN4wYDlohNPydBsL+wYUacj3fn1DvVF071z8N2a0JriUlduwx3P7inJ7pBiXOd7Y
TFW95TGuJXtOLR8XNAIpXiju9um6EGpfzpI1jH6JEIx3/Jicmm+bxkdlmKsK+b+L
cSC3qWfIMVlZZM1uJv56bcFzNlw41IwhT33UbU22wl/KzW9GrO+alxWqUIAZJPiQ
20f/9vCjN8Dn7IbeIf5ugHWivMmvNWROHKRJWkIGRA5YXxzpJbEcaaZrLErBdbO6
L1e8Rfg6dq/dDvkGANQeoHBpjMaOd4s0uOB1mLEBoYYYrr27X3G1S80O0DhtmtWh
Hmd7CgiXY8avL4xnRYFUflZzv4paVneTOnGM0699uB/T2ucy/hCnvSZLTbagomTt
7FTIbd8zWc1HRFc6xJg34/siEXzDtZ39sVCRk55EzKlUwjlMpcwZZAWOJSCngJZ+
Uk2jFhT4WnHnw+dtcoc27g/2fyFOnR0zmc5pP6BBTFO1aNW4TP59dL4aJL+RiG5L
SeRKQTIIJ325dPY0mg==
=kPFF
-----END PGP PUBLIC KEY BLOCK-----

View file

@ -1,32 +0,0 @@
fetch("./locations.json").then((locations_unparsed) => {
locations_unparsed.json().then((places) => handle_response(places));
});
function handle_response(places) {
console.log(places);
Object.keys(places).forEach(name => {
let document_element = document.createElement("li");
document_element.className = "element";
let link_element = document.createElement("a");
link_element.href = "./map.html?" + name;
link_element.innerHTML = places[name].display_name;
document_element.appendChild(link_element);
document.getElementById("search_list").appendChild(document_element);
});
}
function eliminate_results() {
let input = document.getElementById("search_bar").value;
input = input.toLowerCase();
console.log("Typed a charachter");
let x = document.getElementsByClassName('element');
for (i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display = "none";
}
else {
x[i].style.display = "list-item";
}
}
}

View file

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>TreeHug - Search</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./style.css" />
<link rel="icon" type="image/x-icon" href="treehug.png">
</head>
<body>
<input type="text" placeholder="Search..." id="search_bar" class="search_bar" onkeyup="eliminate_results()">
<ul id="search_list"></ul>
<script src="fetch_places.js"></script>
</body>
</html>

View file

@ -1,86 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var RADIUS = 2000.0;
var MAX_RESULTS = 20;
var INCLUDED_TYPES = ["park"];
var map;
var pos = { lat: 30, lng: -110 };
function initMap() {
return __awaiter(this, void 0, void 0, function () {
var Map;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, google.maps.importLibrary("maps")];
case 1:
Map = (_a.sent()).Map;
map = new Map(document.getElementById("map"), {
center: pos,
zoom: 8,
mapId: "DEMO_MAP",
});
return [2 /*return*/];
}
});
});
}
function handle_response(places) {
var place_id = document.URL.split('?')[1];
var place = places[place_id];
var place_location = { lat: place.lat, lng: place.lng };
new google.maps.Marker({
position: place_location,
map: map,
title: place.display_name,
});
map.setCenter(place_location);
Object.keys(places).forEach(function (name) {
var document_element = document.createElement("li");
document_element.className = "element";
var link_element = document.createElement("a");
link_element.href = "./map.html?" + name;
link_element.innerHTML = places[name].display_name;
document_element.appendChild(link_element);
// @ts-ignore
document.getElementById("search_list").appendChild(document_element);
});
}
initMap().then(function () {
fetch("./locations.json").then(function (locations_unparsed) {
locations_unparsed.json().then(function (places) { return handle_response(places); });
});
});

View file

@ -1,46 +0,0 @@
const RADIUS = 2000.0;
const MAX_RESULTS = 20;
const INCLUDED_TYPES = ["park"];
let map: google.maps.Map;
let pos: google.maps.LatLngLiteral = {lat: 30, lng: -110};
async function initMap() {
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
map = new Map(document.getElementById("map") as HTMLElement, {
center: pos,
zoom: 8,
mapId: "DEMO_MAP",
});
}
function handle_response(places: {[index: string]: {lat: number, lng: number, display_name: string}}) {
let place_id = document.URL.split('?')[1];
let place = places[place_id];
let place_location: google.maps.LatLngLiteral = { lat: place.lat, lng: place.lng};
new google.maps.Marker({
position: place_location,
map,
title: place.display_name,
});
map.setCenter(place_location);
Object.keys(places).forEach(name => {
let document_element = document.createElement("li");
document_element.className = "element";
let link_element = document.createElement("a");
link_element.href = "./map.html?" + name;
link_element.innerHTML = places[name].display_name;
document_element.appendChild(link_element);
// @ts-ignore
document.getElementById("search_list").appendChild(document_element);
});
}
initMap().then(() => {
fetch("./locations.json").then((locations_unparsed) => {
locations_unparsed.json().then((places) => handle_response(places));
});
});

View file

@ -1,17 +0,0 @@
{
"rana_bibliotek": {
"lat": 66.31144686667197,
"lng": 14.138761809521128,
"display_name": "Rana Bibliotek"
},
"nordland_fylkesbibliotek": {
"lat": 66.31132186276196,
"lng": 14.138815453697577,
"display_name": "Nordland Fylkesbibliotek"
},
"storhauge_start": {
"lat": 66.32937944214652,
"lng": 14.2029277866417,
"display_name": "Storhauge Start"
}
}

View file

@ -1,42 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>TreeHug - Map</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<script src="node_modules/@googlemaps/markerclusterer/dist/index.min.js"></script>
<link rel="stylesheet" type="text/css" href="./style.css" />
<link rel="icon" type="image/x-icon" href="treehug.png">
</head>
<body>
<div id="map"></div>
<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyCneCqjzobnZ-ksYh85eosk1whovucTjQE", v: "weekly"});</script>
<script type="module" src="./index.js"></script>
<input type="text" placeholder="Search..." id="search_bar" class="search_bar" onkeyup="eliminate_results()">
<ul id="search_list"></ul>
<script>
function eliminate_results() {
let input = document.getElementById("search_bar").value;
input = input.toLowerCase();
console.log("Typed a charachter");
let x = document.getElementsByClassName('element');
for (let i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display = "none";
}
else {
x[i].style.display = "list-item";
}
}
}
</script>
</body>
</html>

View file

@ -1,40 +0,0 @@
{
"name": "TreeHug",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/@googlemaps/markerclusterer": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@googlemaps/markerclusterer/-/markerclusterer-2.5.0.tgz",
"integrity": "sha512-WpHLCZxP7QmB4Hc5kyODGdTfJPsZiOIbcvbYhcS/VeiRNDVjf6CRQ8ViQjwrG5OySC66rtOdj4RVhUXsd1tNTQ==",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"supercluster": "^8.0.1"
}
},
"node_modules/@types/google.maps": {
"version": "3.54.6",
"resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.54.6.tgz",
"integrity": "sha512-cTGbsddDgEwZ/6xPywI7HKbeYJkfXFg92HdYnlE0HO3gT/030CVdUHLO2uQOkEo0YMp6TRPqTlAnRGNbQJu8vw==",
"dev": true
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
},
"node_modules/kdbush": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/kdbush/-/kdbush-4.0.2.tgz",
"integrity": "sha512-WbCVYJ27Sz8zi9Q7Q0xHC+05iwkm3Znipc2XTlrnJbsHMYktW4hPhXUE8Ys1engBrvffoSCqbil1JQAa7clRpA=="
},
"node_modules/supercluster": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/supercluster/-/supercluster-8.0.1.tgz",
"integrity": "sha512-IiOea5kJ9iqzD2t7QJq/cREyLHTtSmUT6gQsweojg9WH2sYJqZK9SswTu6jrscO6D1G5v5vYZ9ru/eq85lXeZQ==",
"dependencies": {
"kdbush": "^4.0.2"
}
}
}
}

View file

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,105 +0,0 @@
# Google Maps JavaScript MarkerClusterer
[![npm](https://img.shields.io/npm/v/@googlemaps/markerclusterer)](https://www.npmjs.com/package/@googlemaps/markerclusterer)
![Build](https://github.com/googlemaps/js-markerclusterer/workflows/Test/badge.svg)
![Release](https://github.com/googlemaps/js-markerclusterer/workflows/Release/badge.svg)
[![codecov](https://codecov.io/gh/googlemaps/js-markerclusterer/branch/main/graph/badge.svg)](https://codecov.io/gh/googlemaps/js-markerclusterer)
![GitHub contributors](https://img.shields.io/github/contributors/googlemaps/js-markerclusterer?color=green)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![](https://github.com/jpoehnelt/in-solidarity-bot/raw/main/static//badge-flat.png)](https://github.com/apps/in-solidarity)
## Description
The library creates and manages per-zoom-level clusters for large amounts of markers.
[**Try the demo**](https://googlemaps.github.io/js-markerclusterer/public/defaults/)
![screenshot](https://user-images.githubusercontent.com/3392975/135143029-20abd824-0f3e-4e28-bad3-327acf7aec04.png)
See the [history section](#history) and [migration section](#migration) for how this library relates to [@google/markerclusterer][@google/markerclusterer] and [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus].
## Install
Available via npm as the package [@googlemaps/markerclusterer](https://www.npmjs.com/package/@googlemaps/markerclusterer).
```
npm i @googlemaps/markerclusterer
```
Alternativly you may add the umd package directly to the html document using the unpkg link.
```html
<script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>
```
When adding via unpkg, the `MarkerClusterer` can be accessed at `markerClusterer.MarkerClusterer`.
#### TypeScript
This library uses the official TypeScript typings for Google Maps Platform, [@types/google.maps](https://www.npmjs.com/package/@types/google.maps).
```sh
npm i -D @types/google.maps
```
## Documentation
The [reference documentation](https://googlemaps.github.io/js-markerclusterer/) is generated from the TypeScript definitions.
## Examples
```js
import { MarkerClusterer } from "@googlemaps/markerclusterer";
// use default algorithm and renderer
const markerCluster = new MarkerClusterer({ map, markers });
```
View the package in action:
- [Algorithm Comparisons](https://googlemaps.github.io/js-markerclusterer/public/algorithms) - This example demonstrates the different algorithms. Please note that spacing and many other options can be changed for each algorithm.
- [Renderer Usage](https://googlemaps.github.io/js-markerclusterer/public/renderers) - This example demonstrates different renderers similar to the image below.
![Screen Shot 2021-09-28 at 1 41 06 PM](https://user-images.githubusercontent.com/3392975/135154898-a5abb5a4-3022-44e0-92d2-5dcefa247e87.png)
## History
This library has a heritage in [@google/markerclusterer][@google/markerclusterer] and [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus], originally made available on [code.google.com](https://code.google.com/archive/) and then transferred to GitHub at https://github.com/googlemaps/v3-utility-library. The following is an approximate timeline.
- 201X - [@google/markerclusterer][@google/markerclusterer] was created.
- 201X - [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus] was created.
- 2019 - Libraries were published to NPM.
- 2019 - [@google/markerclusterer][@google/markerclusterer] was deprecated for [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus].
- 2020 - [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus] was refactored to TypeScript.
- 2020 - [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus] was moved to a separate repository.
- 2021 - [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus] was rewritten as [@googlemaps/markerclusterer (**new**)][@googlemaps/markerclusterer].
- TBD - [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus] is deprecated for [@googlemaps/markerclusterer (**new**)][@googlemaps/markerclusterer].
## Migration
The API of [@googlemaps/markerclusterer][@googlemaps/markerclusterer] has changed in a number of ways from [@googlemaps/markerclustererplus][@googlemaps/markerclustererplus].
- The `MarkerClusterer` class now accepts an `algorithm` and `renderer` parameter to allow for more flexibility. The interface looks like the following:
```js
{
algorithm?: Algorithm;
map?: google.maps.Map;
markers?: google.maps.Marker[];
renderer?: Renderer;
onClusterClick?: onClusterClickHandler;
}
```
- The `MarkerClusterer` accepts a single options argument instead of positional parameters.
- The traditional `GridAlgorithm` is still supported, **but is not the default**. The default is [supercluster](https://www.npmjs.com/package/supercluster) which uses [k-d trees](https://en.wikipedia.org/wiki/K-d_tree) for improved performance.
- Styling of clusters has been simplifed and moved to the renderer interface.
- The `MarkerClusterer` class is still an instance of `google.maps.OverlayView`, but uses `google.maps.Marker`s instead of `google.maps.Overlay` to render the clusters. This solves issues related to the usage of map panes and click handlers.
- @googlemaps/markerclusterer supports Marker and Map [a11y improvements](https://cloud.google.com/blog/products/maps-platform/improved-accessibility-maps-javascript-api).
[@googlemaps/markerclustererplus]: https://www.npmjs.com/package/@googlemaps/markerclustererplus
[@google/markerclusterer]: https://www.npmjs.com/package/@google/markerclusterer
[@googlemaps/markerclusterer]: https://www.npmjs.com/package/@googlemaps/markerclusterer

View file

@ -1,113 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="google.maps" />
import { Cluster } from "../cluster";
import { Marker } from "../marker-utils";
export interface AlgorithmInput {
/**
* The map containing the markers and clusters.
*/
map: google.maps.Map;
/**
* An array of markers to be clustered.
*
* There are some specific edge cases to be aware of including the following:
* * Markers that are not visible.
*/
markers: Marker[];
/**
* The `mapCanvasProjection` enables easy conversion from lat/lng to pixel.
*
* @see [MapCanvasProjection](https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapCanvasProjection)
*/
mapCanvasProjection: google.maps.MapCanvasProjection;
}
export interface AlgorithmOutput {
/**
* The clusters returned based upon the {@link AlgorithmInput}.
*/
clusters: Cluster[];
/**
* A boolean flag indicating that the clusters have not changed.
*/
changed?: boolean;
}
export interface Algorithm {
/**
* Calculates an array of {@link Cluster}.
*/
calculate: ({ markers, map }: AlgorithmInput) => AlgorithmOutput;
}
export interface AlgorithmOptions {
maxZoom?: number;
}
/**
* @hidden
*/
export declare abstract class AbstractAlgorithm implements Algorithm {
protected maxZoom: number;
constructor({ maxZoom }: AlgorithmOptions);
/**
* Helper function to bypass clustering based upon some map state such as
* zoom, number of markers, etc.
*
* ```typescript
* cluster({markers, map}: AlgorithmInput): Cluster[] {
* if (shouldBypassClustering(map)) {
* return this.noop({markers})
* }
* }
* ```
*/
protected noop<T extends Pick<AlgorithmInput, "markers">>({ markers, }: T): Cluster[];
/**
* Calculates an array of {@link Cluster}. Calculate is separate from
* {@link cluster} as it does preprocessing on the markers such as filtering
* based upon the viewport as in {@link AbstractViewportAlgorithm}. Caching
* and other optimizations can also be done here.
*/
abstract calculate({ markers, map }: AlgorithmInput): AlgorithmOutput;
/**
* Clusters the markers and called from {@link calculate}.
*/
protected abstract cluster({ markers, map }: AlgorithmInput): Cluster[];
}
/**
* @hidden
*/
export interface ViewportAlgorithmOptions extends AlgorithmOptions {
/**
* The number of pixels to extend beyond the viewport bounds when filtering
* markers prior to clustering.
*/
viewportPadding?: number;
}
/**
* Abstract viewport algorithm proves a class to filter markers by a padded
* viewport. This is a common optimization.
*
* @hidden
*/
export declare abstract class AbstractViewportAlgorithm extends AbstractAlgorithm {
protected viewportPadding: number;
constructor({ viewportPadding, ...options }: ViewportAlgorithmOptions);
calculate({ markers, map, mapCanvasProjection, }: AlgorithmInput): AlgorithmOutput;
protected abstract cluster({ markers, map }: AlgorithmInput): Cluster[];
}
/**
* @hidden
*/
export declare const noop: (markers: Marker[]) => Cluster[];

View file

@ -1,16 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View file

@ -1,46 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="google.maps" />
import { AbstractViewportAlgorithm, AlgorithmInput, AlgorithmOutput, ViewportAlgorithmOptions } from "./core";
import { Cluster } from "../cluster";
import { Marker } from "../marker-utils";
export interface GridOptions extends ViewportAlgorithmOptions {
gridSize?: number;
/**
* Max distance between cluster center and point in meters.
* @default 10000
*/
maxDistance?: number;
}
/**
* The default Grid algorithm historically used in Google Maps marker
* clustering.
*
* The Grid algorithm does not implement caching and markers may flash as the
* viewport changes. Instead use {@link SuperClusterAlgorithm}.
*/
export declare class GridAlgorithm extends AbstractViewportAlgorithm {
protected gridSize: number;
protected maxDistance: number;
protected clusters: Cluster[];
protected state: {
zoom: number;
};
constructor({ maxDistance, gridSize, ...options }: GridOptions);
calculate({ markers, map, mapCanvasProjection, }: AlgorithmInput): AlgorithmOutput;
protected cluster({ markers, map, mapCanvasProjection, }: AlgorithmInput): Cluster[];
protected addToClosestCluster(marker: Marker, map: google.maps.Map, projection: google.maps.MapCanvasProjection): void;
}

View file

@ -1,16 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View file

@ -1,21 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from "./core";
export * from "./grid";
export * from "./noop";
export * from "./supercluster";
export * from "./superviewport";
export * from "./utils";

View file

@ -1,25 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AbstractAlgorithm, AlgorithmInput, AlgorithmOptions, AlgorithmOutput } from "./core";
import { Cluster } from "../cluster";
/**
* Noop algorithm does not generate any clusters or filter markers by the an extended viewport.
*/
export declare class NoopAlgorithm extends AbstractAlgorithm {
constructor({ ...options }: AlgorithmOptions);
calculate({ markers, map, mapCanvasProjection, }: AlgorithmInput): AlgorithmOutput;
protected cluster(input: AlgorithmInput): Cluster[];
}

View file

@ -1,43 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AbstractAlgorithm, AlgorithmInput, AlgorithmOutput } from "./core";
import SuperCluster, { ClusterFeature } from "supercluster";
import { Marker } from "../marker-utils";
import { Cluster } from "../cluster";
export type SuperClusterOptions = SuperCluster.Options<{
[name: string]: any;
}, {
[name: string]: any;
}>;
/**
* A very fast JavaScript algorithm for geospatial point clustering using KD trees.
*
* @see https://www.npmjs.com/package/supercluster for more information on options.
*/
export declare class SuperClusterAlgorithm extends AbstractAlgorithm {
protected superCluster: SuperCluster;
protected markers: Marker[];
protected clusters: Cluster[];
protected state: {
zoom: number;
};
constructor({ maxZoom, radius, ...options }: SuperClusterOptions);
calculate(input: AlgorithmInput): AlgorithmOutput;
cluster({ map }: AlgorithmInput): Cluster[];
protected transformCluster({ geometry: { coordinates: [lng, lat], }, properties, }: ClusterFeature<{
marker: Marker;
}>): Cluster;
}

View file

@ -1,16 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View file

@ -1,43 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AbstractViewportAlgorithm, AlgorithmInput, AlgorithmOutput, ViewportAlgorithmOptions } from "./core";
import { SuperClusterOptions } from "./supercluster";
import SuperCluster, { ClusterFeature } from "supercluster";
import { Marker } from "../marker-utils";
import { Cluster } from "../cluster";
export interface SuperClusterViewportOptions extends SuperClusterOptions, ViewportAlgorithmOptions {
}
export interface SuperClusterViewportState {
zoom: number;
view: [number, number, number, number];
}
/**
* A very fast JavaScript algorithm for geospatial point clustering using KD trees.
*
* @see https://www.npmjs.com/package/supercluster for more information on options.
*/
export declare class SuperClusterViewportAlgorithm extends AbstractViewportAlgorithm {
protected superCluster: SuperCluster;
protected markers: Marker[];
protected clusters: Cluster[];
protected state: SuperClusterViewportState;
constructor({ maxZoom, radius, viewportPadding, ...options }: SuperClusterViewportOptions);
calculate(input: AlgorithmInput): AlgorithmOutput;
cluster({ map, mapCanvasProjection }: AlgorithmInput): Cluster[];
protected transformCluster({ geometry: { coordinates: [lng, lat], }, properties, }: ClusterFeature<{
marker: Marker;
}>): Cluster;
}

View file

@ -1,16 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View file

@ -1,56 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="google.maps" />
import { Marker } from "../marker-utils";
/**
* Returns the markers visible in a padded map viewport
*
* @param map
* @param mapCanvasProjection
* @param markers The list of marker to filter
* @param viewportPaddingPixels The padding in pixel
* @returns The list of markers in the padded viewport
*/
export declare const filterMarkersToPaddedViewport: (map: google.maps.Map, mapCanvasProjection: google.maps.MapCanvasProjection, markers: Marker[], viewportPaddingPixels: number) => Marker[];
/**
* Extends a bounds by a number of pixels in each direction
*/
export declare const extendBoundsToPaddedViewport: (bounds: google.maps.LatLngBounds, projection: google.maps.MapCanvasProjection, numPixels: number) => google.maps.LatLngBounds;
/**
* Gets the extended bounds as a bbox [westLng, southLat, eastLng, northLat]
*/
export declare const getPaddedViewport: (bounds: google.maps.LatLngBounds, projection: google.maps.MapCanvasProjection, pixels: number) => [number, number, number, number];
/**
* Returns the distance between 2 positions.
*
* @hidden
*/
export declare const distanceBetweenPoints: (p1: google.maps.LatLngLiteral, p2: google.maps.LatLngLiteral) => number;
type PixelBounds = {
northEast: google.maps.Point;
southWest: google.maps.Point;
};
/**
* Extends a pixel bounds by numPixels in all directions.
*
* @hidden
*/
export declare const extendPixelBounds: ({ northEast, southWest }: PixelBounds, numPixels: number) => PixelBounds;
/**
* @hidden
*/
export declare const pixelBoundsToLatLngBounds: ({ northEast, southWest }: PixelBounds, projection: google.maps.MapCanvasProjection) => google.maps.LatLngBounds;
export {};

View file

@ -1,16 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View file

@ -1,41 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="google.maps" />
import { Marker } from "./marker-utils";
export interface ClusterOptions {
position?: google.maps.LatLng | google.maps.LatLngLiteral;
markers?: Marker[];
}
export declare class Cluster {
marker?: Marker;
readonly markers?: Marker[];
protected _position: google.maps.LatLng;
constructor({ markers, position }: ClusterOptions);
get bounds(): google.maps.LatLngBounds | undefined;
get position(): google.maps.LatLng;
/**
* Get the count of **visible** markers.
*/
get count(): number;
/**
* Add a marker to the cluster.
*/
push(marker: Marker): void;
/**
* Cleanup references and remove marker from map.
*/
delete(): void;
}

View file

@ -1,16 +0,0 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};

View file

@ -1,20 +0,0 @@
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from "./algorithms";
export * from "./cluster";
export * from "./markerclusterer";
export * from "./renderer";
export * from "./marker-utils";

File diff suppressed because it is too large Load diff

View file

@ -1,956 +0,0 @@
import equal from 'fast-deep-equal';
import SuperCluster from 'supercluster';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* util class that creates a common set of convenience functions to wrap
* shared behavior of Advanced Markers and Markers.
*/
class MarkerUtils {
static isAdvancedMarkerAvailable(map) {
return (google.maps.marker &&
map.getMapCapabilities().isAdvancedMarkersAvailable === true);
}
static isAdvancedMarker(marker) {
return (google.maps.marker &&
marker instanceof google.maps.marker.AdvancedMarkerElement);
}
static setMap(marker, map) {
if (this.isAdvancedMarker(marker)) {
marker.map = map;
}
else {
marker.setMap(map);
}
}
static getPosition(marker) {
// SuperClusterAlgorithm.calculate expects a LatLng instance so we fake it for Adv Markers
if (this.isAdvancedMarker(marker)) {
if (marker.position) {
if (marker.position instanceof google.maps.LatLng) {
return marker.position;
}
// since we can't cast to LatLngLiteral for reasons =(
if (marker.position.lat && marker.position.lng) {
return new google.maps.LatLng(marker.position.lat, marker.position.lng);
}
}
return new google.maps.LatLng(null);
}
return marker.getPosition();
}
static getVisible(marker) {
if (this.isAdvancedMarker(marker)) {
/**
* Always return true for Advanced Markers because the clusterer
* uses getVisible as a way to count legacy markers not as an actual
* indicator of visibility for some reason. Even when markers are hidden
* Marker.getVisible returns `true` and this is used to set the marker count
* on the cluster. See the behavior of Cluster.count
*/
return true;
}
return marker.getVisible();
}
}
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Cluster {
constructor({ markers, position }) {
this.markers = markers;
if (position) {
if (position instanceof google.maps.LatLng) {
this._position = position;
}
else {
this._position = new google.maps.LatLng(position);
}
}
}
get bounds() {
if (this.markers.length === 0 && !this._position) {
return;
}
const bounds = new google.maps.LatLngBounds(this._position, this._position);
for (const marker of this.markers) {
bounds.extend(MarkerUtils.getPosition(marker));
}
return bounds;
}
get position() {
return this._position || this.bounds.getCenter();
}
/**
* Get the count of **visible** markers.
*/
get count() {
return this.markers.filter((m) => MarkerUtils.getVisible(m)).length;
}
/**
* Add a marker to the cluster.
*/
push(marker) {
this.markers.push(marker);
}
/**
* Cleanup references and remove marker from map.
*/
delete() {
if (this.marker) {
MarkerUtils.setMap(this.marker, null);
this.marker = undefined;
}
this.markers.length = 0;
}
}
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Returns the markers visible in a padded map viewport
*
* @param map
* @param mapCanvasProjection
* @param markers The list of marker to filter
* @param viewportPaddingPixels The padding in pixel
* @returns The list of markers in the padded viewport
*/
const filterMarkersToPaddedViewport = (map, mapCanvasProjection, markers, viewportPaddingPixels) => {
const extendedMapBounds = extendBoundsToPaddedViewport(map.getBounds(), mapCanvasProjection, viewportPaddingPixels);
return markers.filter((marker) => extendedMapBounds.contains(MarkerUtils.getPosition(marker)));
};
/**
* Extends a bounds by a number of pixels in each direction
*/
const extendBoundsToPaddedViewport = (bounds, projection, numPixels) => {
const { northEast, southWest } = latLngBoundsToPixelBounds(bounds, projection);
const extendedPixelBounds = extendPixelBounds({ northEast, southWest }, numPixels);
return pixelBoundsToLatLngBounds(extendedPixelBounds, projection);
};
/**
* Gets the extended bounds as a bbox [westLng, southLat, eastLng, northLat]
*/
const getPaddedViewport = (bounds, projection, pixels) => {
const extended = extendBoundsToPaddedViewport(bounds, projection, pixels);
const ne = extended.getNorthEast();
const sw = extended.getSouthWest();
return [sw.lng(), sw.lat(), ne.lng(), ne.lat()];
};
/**
* Returns the distance between 2 positions.
*
* @hidden
*/
const distanceBetweenPoints = (p1, p2) => {
const R = 6371; // Radius of the Earth in km
const dLat = ((p2.lat - p1.lat) * Math.PI) / 180;
const dLon = ((p2.lng - p1.lng) * Math.PI) / 180;
const sinDLat = Math.sin(dLat / 2);
const sinDLon = Math.sin(dLon / 2);
const a = sinDLat * sinDLat +
Math.cos((p1.lat * Math.PI) / 180) *
Math.cos((p2.lat * Math.PI) / 180) *
sinDLon *
sinDLon;
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return R * c;
};
/**
* Converts a LatLng bound to pixels.
*
* @hidden
*/
const latLngBoundsToPixelBounds = (bounds, projection) => {
return {
northEast: projection.fromLatLngToDivPixel(bounds.getNorthEast()),
southWest: projection.fromLatLngToDivPixel(bounds.getSouthWest()),
};
};
/**
* Extends a pixel bounds by numPixels in all directions.
*
* @hidden
*/
const extendPixelBounds = ({ northEast, southWest }, numPixels) => {
northEast.x += numPixels;
northEast.y -= numPixels;
southWest.x -= numPixels;
southWest.y += numPixels;
return { northEast, southWest };
};
/**
* @hidden
*/
const pixelBoundsToLatLngBounds = ({ northEast, southWest }, projection) => {
const sw = projection.fromDivPixelToLatLng(southWest);
const ne = projection.fromDivPixelToLatLng(northEast);
return new google.maps.LatLngBounds(sw, ne);
};
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @hidden
*/
class AbstractAlgorithm {
constructor({ maxZoom = 16 }) {
this.maxZoom = maxZoom;
}
/**
* Helper function to bypass clustering based upon some map state such as
* zoom, number of markers, etc.
*
* ```typescript
* cluster({markers, map}: AlgorithmInput): Cluster[] {
* if (shouldBypassClustering(map)) {
* return this.noop({markers})
* }
* }
* ```
*/
noop({ markers, }) {
return noop(markers);
}
}
/**
* Abstract viewport algorithm proves a class to filter markers by a padded
* viewport. This is a common optimization.
*
* @hidden
*/
class AbstractViewportAlgorithm extends AbstractAlgorithm {
constructor(_a) {
var { viewportPadding = 60 } = _a, options = __rest(_a, ["viewportPadding"]);
super(options);
this.viewportPadding = 60;
this.viewportPadding = viewportPadding;
}
calculate({ markers, map, mapCanvasProjection, }) {
if (map.getZoom() >= this.maxZoom) {
return {
clusters: this.noop({
markers,
}),
changed: false,
};
}
return {
clusters: this.cluster({
markers: filterMarkersToPaddedViewport(map, mapCanvasProjection, markers, this.viewportPadding),
map,
mapCanvasProjection,
}),
};
}
}
/**
* @hidden
*/
const noop = (markers) => {
const clusters = markers.map((marker) => new Cluster({
position: MarkerUtils.getPosition(marker),
markers: [marker],
}));
return clusters;
};
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The default Grid algorithm historically used in Google Maps marker
* clustering.
*
* The Grid algorithm does not implement caching and markers may flash as the
* viewport changes. Instead use {@link SuperClusterAlgorithm}.
*/
class GridAlgorithm extends AbstractViewportAlgorithm {
constructor(_a) {
var { maxDistance = 40000, gridSize = 40 } = _a, options = __rest(_a, ["maxDistance", "gridSize"]);
super(options);
this.clusters = [];
this.state = { zoom: -1 };
this.maxDistance = maxDistance;
this.gridSize = gridSize;
}
calculate({ markers, map, mapCanvasProjection, }) {
const state = { zoom: map.getZoom() };
let changed = false;
if (this.state.zoom >= this.maxZoom && state.zoom >= this.maxZoom) ;
else {
changed = !equal(this.state, state);
}
this.state = state;
if (map.getZoom() >= this.maxZoom) {
return {
clusters: this.noop({
markers,
}),
changed,
};
}
return {
clusters: this.cluster({
markers: filterMarkersToPaddedViewport(map, mapCanvasProjection, markers, this.viewportPadding),
map,
mapCanvasProjection,
}),
};
}
cluster({ markers, map, mapCanvasProjection, }) {
this.clusters = [];
markers.forEach((marker) => {
this.addToClosestCluster(marker, map, mapCanvasProjection);
});
return this.clusters;
}
addToClosestCluster(marker, map, projection) {
let maxDistance = this.maxDistance; // Some large number
let cluster = null;
for (let i = 0; i < this.clusters.length; i++) {
const candidate = this.clusters[i];
const distance = distanceBetweenPoints(candidate.bounds.getCenter().toJSON(), MarkerUtils.getPosition(marker).toJSON());
if (distance < maxDistance) {
maxDistance = distance;
cluster = candidate;
}
}
if (cluster &&
extendBoundsToPaddedViewport(cluster.bounds, projection, this.gridSize).contains(MarkerUtils.getPosition(marker))) {
cluster.push(marker);
}
else {
const cluster = new Cluster({ markers: [marker] });
this.clusters.push(cluster);
}
}
}
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Noop algorithm does not generate any clusters or filter markers by the an extended viewport.
*/
class NoopAlgorithm extends AbstractAlgorithm {
constructor(_a) {
var options = __rest(_a, []);
super(options);
}
calculate({ markers, map, mapCanvasProjection, }) {
return {
clusters: this.cluster({ markers, map, mapCanvasProjection }),
changed: false,
};
}
cluster(input) {
return this.noop(input);
}
}
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A very fast JavaScript algorithm for geospatial point clustering using KD trees.
*
* @see https://www.npmjs.com/package/supercluster for more information on options.
*/
class SuperClusterAlgorithm extends AbstractAlgorithm {
constructor(_a) {
var { maxZoom, radius = 60 } = _a, options = __rest(_a, ["maxZoom", "radius"]);
super({ maxZoom });
this.state = { zoom: -1 };
this.superCluster = new SuperCluster(Object.assign({ maxZoom: this.maxZoom, radius }, options));
}
calculate(input) {
let changed = false;
const state = { zoom: input.map.getZoom() };
if (!equal(input.markers, this.markers)) {
changed = true;
// TODO use proxy to avoid copy?
this.markers = [...input.markers];
const points = this.markers.map((marker) => {
const position = MarkerUtils.getPosition(marker);
const coordinates = [position.lng(), position.lat()];
return {
type: "Feature",
geometry: {
type: "Point",
coordinates,
},
properties: { marker },
};
});
this.superCluster.load(points);
}
if (!changed) {
if (this.state.zoom <= this.maxZoom || state.zoom <= this.maxZoom) {
changed = !equal(this.state, state);
}
}
this.state = state;
if (changed) {
this.clusters = this.cluster(input);
}
return { clusters: this.clusters, changed };
}
cluster({ map }) {
return this.superCluster
.getClusters([-180, -90, 180, 90], Math.round(map.getZoom()))
.map((feature) => this.transformCluster(feature));
}
transformCluster({ geometry: { coordinates: [lng, lat], }, properties, }) {
if (properties.cluster) {
return new Cluster({
markers: this.superCluster
.getLeaves(properties.cluster_id, Infinity)
.map((leaf) => leaf.properties.marker),
position: { lat, lng },
});
}
const marker = properties.marker;
return new Cluster({
markers: [marker],
position: MarkerUtils.getPosition(marker),
});
}
}
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A very fast JavaScript algorithm for geospatial point clustering using KD trees.
*
* @see https://www.npmjs.com/package/supercluster for more information on options.
*/
class SuperClusterViewportAlgorithm extends AbstractViewportAlgorithm {
constructor(_a) {
var { maxZoom, radius = 60, viewportPadding = 60 } = _a, options = __rest(_a, ["maxZoom", "radius", "viewportPadding"]);
super({ maxZoom, viewportPadding });
this.superCluster = new SuperCluster(Object.assign({ maxZoom: this.maxZoom, radius }, options));
this.state = { zoom: -1, view: [0, 0, 0, 0] };
}
calculate(input) {
const state = {
zoom: Math.round(input.map.getZoom()),
view: getPaddedViewport(input.map.getBounds(), input.mapCanvasProjection, this.viewportPadding),
};
let changed = !equal(this.state, state);
if (!equal(input.markers, this.markers)) {
changed = true;
// TODO use proxy to avoid copy?
this.markers = [...input.markers];
const points = this.markers.map((marker) => {
const position = MarkerUtils.getPosition(marker);
const coordinates = [position.lng(), position.lat()];
return {
type: "Feature",
geometry: {
type: "Point",
coordinates,
},
properties: { marker },
};
});
this.superCluster.load(points);
}
if (changed) {
this.clusters = this.cluster(input);
this.state = state;
}
return { clusters: this.clusters, changed };
}
cluster({ map, mapCanvasProjection }) {
/* recalculate new state because we can't use the cached version. */
const state = {
zoom: Math.round(map.getZoom()),
view: getPaddedViewport(map.getBounds(), mapCanvasProjection, this.viewportPadding),
};
return this.superCluster
.getClusters(state.view, state.zoom)
.map((feature) => this.transformCluster(feature));
}
transformCluster({ geometry: { coordinates: [lng, lat], }, properties, }) {
if (properties.cluster) {
return new Cluster({
markers: this.superCluster
.getLeaves(properties.cluster_id, Infinity)
.map((leaf) => leaf.properties.marker),
position: { lat, lng },
});
}
const marker = properties.marker;
return new Cluster({
markers: [marker],
position: MarkerUtils.getPosition(marker),
});
}
}
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Provides statistics on all clusters in the current render cycle for use in {@link Renderer.render}.
*/
class ClusterStats {
constructor(markers, clusters) {
this.markers = { sum: markers.length };
const clusterMarkerCounts = clusters.map((a) => a.count);
const clusterMarkerSum = clusterMarkerCounts.reduce((a, b) => a + b, 0);
this.clusters = {
count: clusters.length,
markers: {
mean: clusterMarkerSum / clusters.length,
sum: clusterMarkerSum,
min: Math.min(...clusterMarkerCounts),
max: Math.max(...clusterMarkerCounts),
},
};
}
}
class DefaultRenderer {
/**
* The default render function for the library used by {@link MarkerClusterer}.
*
* Currently set to use the following:
*
* ```typescript
* // change color if this cluster has more markers than the mean cluster
* const color =
* count > Math.max(10, stats.clusters.markers.mean)
* ? "#ff0000"
* : "#0000ff";
*
* // create svg url with fill color
* const svg = window.btoa(`
* <svg fill="${color}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240">
* <circle cx="120" cy="120" opacity=".6" r="70" />
* <circle cx="120" cy="120" opacity=".3" r="90" />
* <circle cx="120" cy="120" opacity=".2" r="110" />
* <circle cx="120" cy="120" opacity=".1" r="130" />
* </svg>`);
*
* // create marker using svg icon
* return new google.maps.Marker({
* position,
* icon: {
* url: `data:image/svg+xml;base64,${svg}`,
* scaledSize: new google.maps.Size(45, 45),
* },
* label: {
* text: String(count),
* color: "rgba(255,255,255,0.9)",
* fontSize: "12px",
* },
* // adjust zIndex to be above other markers
* zIndex: 1000 + count,
* });
* ```
*/
render({ count, position }, stats, map) {
// change color if this cluster has more markers than the mean cluster
const color = count > Math.max(10, stats.clusters.markers.mean) ? "#ff0000" : "#0000ff";
// create svg literal with fill color
const svg = `<svg fill="${color}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">
<circle cx="120" cy="120" opacity=".6" r="70" />
<circle cx="120" cy="120" opacity=".3" r="90" />
<circle cx="120" cy="120" opacity=".2" r="110" />
<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${count}</text>
</svg>`;
const title = `Cluster of ${count} markers`,
// adjust zIndex to be above other markers
zIndex = Number(google.maps.Marker.MAX_ZINDEX) + count;
if (MarkerUtils.isAdvancedMarkerAvailable(map)) {
// create cluster SVG element
const parser = new DOMParser();
const svgEl = parser.parseFromString(svg, "image/svg+xml").documentElement;
svgEl.setAttribute("transform", "translate(0 25)");
const clusterOptions = {
map,
position,
zIndex,
title,
content: svgEl,
};
return new google.maps.marker.AdvancedMarkerElement(clusterOptions);
}
const clusterOptions = {
position,
zIndex,
title,
icon: {
url: `data:image/svg+xml;base64,${btoa(svg)}`,
anchor: new google.maps.Point(25, 25),
},
};
return new google.maps.Marker(clusterOptions);
}
}
/**
* Copyright 2019 Google LLC. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Extends an object's prototype by another's.
*
* @param type1 The Type to be extended.
* @param type2 The Type to extend with.
* @ignore
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function extend(type1, type2) {
/* istanbul ignore next */
// eslint-disable-next-line prefer-const
for (let property in type2.prototype) {
type1.prototype[property] = type2.prototype[property];
}
}
/**
* @ignore
*/
class OverlayViewSafe {
constructor() {
// MarkerClusterer implements google.maps.OverlayView interface. We use the
// extend function to extend MarkerClusterer with google.maps.OverlayView
// because it might not always be available when the code is defined so we
// look for it at the last possible moment. If it doesn't exist now then
// there is no point going ahead :)
extend(OverlayViewSafe, google.maps.OverlayView);
}
}
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var MarkerClustererEvents;
(function (MarkerClustererEvents) {
MarkerClustererEvents["CLUSTERING_BEGIN"] = "clusteringbegin";
MarkerClustererEvents["CLUSTERING_END"] = "clusteringend";
MarkerClustererEvents["CLUSTER_CLICK"] = "click";
})(MarkerClustererEvents || (MarkerClustererEvents = {}));
const defaultOnClusterClickHandler = (_, cluster, map) => {
map.fitBounds(cluster.bounds);
};
/**
* MarkerClusterer creates and manages per-zoom-level clusters for large amounts
* of markers. See {@link MarkerClustererOptions} for more details.
*
*/
class MarkerClusterer extends OverlayViewSafe {
constructor({ map, markers = [], algorithmOptions = {}, algorithm = new SuperClusterAlgorithm(algorithmOptions), renderer = new DefaultRenderer(), onClusterClick = defaultOnClusterClickHandler, }) {
super();
this.markers = [...markers];
this.clusters = [];
this.algorithm = algorithm;
this.renderer = renderer;
this.onClusterClick = onClusterClick;
if (map) {
this.setMap(map);
}
}
addMarker(marker, noDraw) {
if (this.markers.includes(marker)) {
return;
}
this.markers.push(marker);
if (!noDraw) {
this.render();
}
}
addMarkers(markers, noDraw) {
markers.forEach((marker) => {
this.addMarker(marker, true);
});
if (!noDraw) {
this.render();
}
}
removeMarker(marker, noDraw) {
const index = this.markers.indexOf(marker);
if (index === -1) {
// Marker is not in our list of markers, so do nothing:
return false;
}
MarkerUtils.setMap(marker, null);
this.markers.splice(index, 1); // Remove the marker from the list of managed markers
if (!noDraw) {
this.render();
}
return true;
}
removeMarkers(markers, noDraw) {
let removed = false;
markers.forEach((marker) => {
removed = this.removeMarker(marker, true) || removed;
});
if (removed && !noDraw) {
this.render();
}
return removed;
}
clearMarkers(noDraw) {
this.markers.length = 0;
if (!noDraw) {
this.render();
}
}
/**
* Recalculates and draws all the marker clusters.
*/
render() {
const map = this.getMap();
if (map instanceof google.maps.Map && map.getProjection()) {
google.maps.event.trigger(this, MarkerClustererEvents.CLUSTERING_BEGIN, this);
const { clusters, changed } = this.algorithm.calculate({
markers: this.markers,
map,
mapCanvasProjection: this.getProjection(),
});
// Allow algorithms to return flag on whether the clusters/markers have changed.
if (changed || changed == undefined) {
// Accumulate the markers of the clusters composed of a single marker.
// Those clusters directly use the marker.
// Clusters with more than one markers use a group marker generated by a renderer.
const singleMarker = new Set();
for (const cluster of clusters) {
if (cluster.markers.length == 1) {
singleMarker.add(cluster.markers[0]);
}
}
const groupMarkers = [];
// Iterate the clusters that are currently rendered.
for (const cluster of this.clusters) {
if (cluster.marker == null) {
continue;
}
if (cluster.markers.length == 1) {
if (!singleMarker.has(cluster.marker)) {
// The marker:
// - was previously rendered because it is from a cluster with 1 marker,
// - should no more be rendered as it is not in singleMarker.
MarkerUtils.setMap(cluster.marker, null);
}
}
else {
// Delay the removal of old group markers to avoid flickering.
groupMarkers.push(cluster.marker);
}
}
this.clusters = clusters;
this.renderClusters();
// Delayed removal of the markers of the former groups.
requestAnimationFrame(() => groupMarkers.forEach((marker) => MarkerUtils.setMap(marker, null)));
}
google.maps.event.trigger(this, MarkerClustererEvents.CLUSTERING_END, this);
}
}
onAdd() {
this.idleListener = this.getMap().addListener("idle", this.render.bind(this));
this.render();
}
onRemove() {
google.maps.event.removeListener(this.idleListener);
this.reset();
}
reset() {
this.markers.forEach((marker) => MarkerUtils.setMap(marker, null));
this.clusters.forEach((cluster) => cluster.delete());
this.clusters = [];
}
renderClusters() {
// Generate stats to pass to renderers.
const stats = new ClusterStats(this.markers, this.clusters);
const map = this.getMap();
this.clusters.forEach((cluster) => {
if (cluster.markers.length === 1) {
cluster.marker = cluster.markers[0];
}
else {
// Generate the marker to represent the group.
cluster.marker = this.renderer.render(cluster, stats, map);
// Make sure all individual markers are removed from the map.
cluster.markers.forEach((marker) => MarkerUtils.setMap(marker, null));
if (this.onClusterClick) {
cluster.marker.addListener("click",
/* istanbul ignore next */
(event) => {
google.maps.event.trigger(this, MarkerClustererEvents.CLUSTER_CLICK, cluster);
this.onClusterClick(event, cluster, map);
});
}
}
MarkerUtils.setMap(cluster.marker, map);
});
}
}
export { AbstractAlgorithm, AbstractViewportAlgorithm, Cluster, ClusterStats, DefaultRenderer, GridAlgorithm, MarkerClusterer, MarkerClustererEvents, MarkerUtils, NoopAlgorithm, SuperClusterAlgorithm, SuperClusterViewportAlgorithm, defaultOnClusterClickHandler, distanceBetweenPoints, extendBoundsToPaddedViewport, extendPixelBounds, filterMarkersToPaddedViewport, getPaddedViewport, noop, pixelBoundsToLatLngBounds };
//# sourceMappingURL=index.esm.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more