init
This commit is contained in:
202
node_modules/@googlemaps/js-api-loader/LICENSE
generated
vendored
Normal file
202
node_modules/@googlemaps/js-api-loader/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
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.
|
||||
157
node_modules/@googlemaps/js-api-loader/README.md
generated
vendored
Normal file
157
node_modules/@googlemaps/js-api-loader/README.md
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
[][npm-pkg]
|
||||

|
||||

|
||||
[](https://github.com/googlemaps/js-api-loader/actions/workflows/test.yml)
|
||||
|
||||
[](https://codecov.io/gh/googlemaps/js-api-loader)
|
||||
[](https://github.com/semantic-release/semantic-release)
|
||||
|
||||

|
||||
[][license]
|
||||
[](https://stackoverflow.com/questions/tagged/google-maps)
|
||||
[][Discord server]
|
||||
|
||||
# Google Maps JavaScript API Loader
|
||||
|
||||
## Description
|
||||
Load the Google Maps JavaScript API script dynamically. This takes inspiration from the [google-maps](https://www.npmjs.com/package/google-maps) npm package but updates it with ES6, Promises, and TypeScript.
|
||||
|
||||
## Requirements
|
||||
|
||||
* [Sign up with Google Maps Platform]
|
||||
* A Google Maps Platform [project] with the [**Maps Javascript API**][maps-sdk] enabled
|
||||
* An [API key] associated with the project above
|
||||
* [@googlemaps/js-api-loader NPM package][npm-pkg]
|
||||
|
||||
## Installation
|
||||
|
||||
Install the [@googlemaps/js-api-loader NPM package][npm-pkg] with:
|
||||
|
||||
```sh
|
||||
npm i @googlemaps/js-api-loader
|
||||
```
|
||||
|
||||
Alternatively you may add the umd package directly to the html document using the unpkg link.
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/@googlemaps/js-api-loader@1.x/dist/index.min.js"></script>
|
||||
```
|
||||
|
||||
When adding via unpkg, the loader can be accessed at `google.maps.plugins.loader.Loader`.
|
||||
|
||||
### TypeScript
|
||||
|
||||
TypeScript users need to install the following types package.
|
||||
|
||||
```sh
|
||||
npm i -D @types/google.maps
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
The reference documentation can be found at this [link](https://googlemaps.github.io/js-api-loader/index.html). The Google Maps JavaScript API [documentation](https://developers.google.com/maps/documentation/javascript/tutorial) is the authoritative source for the loader options.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import { Loader } from '@googlemaps/js-api-loader';
|
||||
|
||||
const loader = new Loader({
|
||||
apiKey: "",
|
||||
version: "weekly",
|
||||
libraries: ["places"]
|
||||
});
|
||||
|
||||
const mapOptions = {
|
||||
center: {
|
||||
lat: 0,
|
||||
lng: 0
|
||||
},
|
||||
zoom: 4
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
Using a promise for a specific library.
|
||||
|
||||
```javascript
|
||||
// Promise for a specific library
|
||||
loader
|
||||
.importLibrary('maps')
|
||||
.then(({Map}) => {
|
||||
new Map(document.getElementById("map"), mapOptions);
|
||||
})
|
||||
.catch((e) => {
|
||||
// do something
|
||||
});
|
||||
```
|
||||
|
||||
Using a promise for when the script has loaded.
|
||||
|
||||
```javascript
|
||||
// Promise
|
||||
loader
|
||||
.load()
|
||||
.then((google) => {
|
||||
new google.maps.Map(document.getElementById("map"), mapOptions);
|
||||
})
|
||||
.catch(e => {
|
||||
// do something
|
||||
});
|
||||
```
|
||||
|
||||
Alternatively, if you want to use a callback.
|
||||
|
||||
```javascript
|
||||
// Callback
|
||||
loader.loadCallback(e => {
|
||||
if (e) {
|
||||
console.log(e);
|
||||
} else {
|
||||
new google.maps.Map(document.getElementById("map"), mapOptions);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
View the package in action [here](https://googlemaps.github.io/js-api-loader/examples/index.html).
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome and encouraged! If you'd like to contribute, send us a [pull request] and refer to our [code of conduct] and [contributing guide].
|
||||
|
||||
## Terms of Service
|
||||
|
||||
This library uses Google Maps Platform services. Use of Google Maps Platform services through this library is subject to the Google Maps Platform [Terms of Service].
|
||||
|
||||
This library is not a Google Maps Platform Core Service. Therefore, the Google Maps Platform Terms of Service (e.g. Technical Support Services, Service Level Agreements, and Deprecation Policy) do not apply to the code in this library.
|
||||
|
||||
## Support
|
||||
|
||||
This library is offered via an open source [license]. It is not governed by the Google Maps Platform Support [Technical Support Services Guidelines, the SLA, or the [Deprecation Policy]. However, any Google Maps Platform services used by the library remain subject to the Google Maps Platform Terms of Service.
|
||||
|
||||
This library adheres to [semantic versioning] to indicate when backwards-incompatible changes are introduced. Accordingly, while the library is in version 0.x, backwards-incompatible changes may be introduced at any time.
|
||||
|
||||
If you find a bug, or have a feature request, please [file an issue] on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of our [developer community channels]. If you'd like to contribute, please check the [contributing guide].
|
||||
|
||||
You can also discuss this library on our [Discord server].
|
||||
|
||||
[API key]: https://developers.google.com/maps/documentation/javascript/get-api-key
|
||||
[maps-sdk]: https://developers.google.com/maps/documentation/javascript
|
||||
[documentation]: https://googlemaps.github.io/js-api-loader
|
||||
[npm-pkg]: https://npmjs.com/package/@googlemaps/js-api-loader
|
||||
|
||||
[code of conduct]: ?tab=coc-ov-file#readme
|
||||
[contributing guide]: CONTRIBUTING.md
|
||||
[Deprecation Policy]: https://cloud.google.com/maps-platform/terms
|
||||
[developer community channels]: https://developers.google.com/maps/developer-community
|
||||
[Discord server]: https://discord.gg/hYsWbmk
|
||||
[file an issue]: https://github.com/googlemaps/js-api-loader/issues/new/choose
|
||||
[license]: LICENSE
|
||||
[project]: https://developers.google.com/maps/documentation/javascript/cloud-setup#enabling-apis
|
||||
[pull request]: https://github.com/googlemaps/js-api-loader/compare
|
||||
[semantic versioning]: https://semver.org
|
||||
[Sign up with Google Maps Platform]: https://console.cloud.google.com/google/maps-apis/start
|
||||
[similar inquiry]: https://github.com/googlemaps/js-api-loader/issues
|
||||
[SLA]: https://cloud.google.com/maps-platform/terms/sla
|
||||
[Technical Support Services Guidelines]: https://cloud.google.com/maps-platform/terms/tssg
|
||||
[Terms of Service]: https://cloud.google.com/maps-platform/terms
|
||||
315
node_modules/@googlemaps/js-api-loader/dist/index.d.ts
generated
vendored
Normal file
315
node_modules/@googlemaps/js-api-loader/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
/**
|
||||
* 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 declare const DEFAULT_ID = "__googleMapsScriptId";
|
||||
export type Library = "core" | "maps" | "maps3d" | "places" | "geocoding" | "routes" | "marker" | "geometry" | "elevation" | "streetView" | "journeySharing" | "drawing" | "visualization";
|
||||
export type Libraries = Library[];
|
||||
/**
|
||||
* The Google Maps JavaScript API
|
||||
* [documentation](https://developers.google.com/maps/documentation/javascript/tutorial)
|
||||
* is the authoritative source for [[LoaderOptions]].
|
||||
/**
|
||||
* Loader options
|
||||
*/
|
||||
export interface LoaderOptions {
|
||||
/**
|
||||
* See https://developers.google.com/maps/documentation/javascript/get-api-key.
|
||||
*/
|
||||
apiKey: string;
|
||||
/**
|
||||
* @deprecated See https://developers.google.com/maps/premium/overview.
|
||||
*/
|
||||
channel?: string;
|
||||
/**
|
||||
* @deprecated See https://developers.google.com/maps/premium/overview, use `apiKey` instead.
|
||||
*/
|
||||
client?: string;
|
||||
/**
|
||||
* In your application you can specify release channels or version numbers:
|
||||
*
|
||||
* The weekly version is specified with `version=weekly`. This version is
|
||||
* updated once per week, and is the most current.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: 'weekly'});
|
||||
* ```
|
||||
*
|
||||
* The quarterly version is specified with `version=quarterly`. This version
|
||||
* is updated once per quarter, and is the most predictable.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: 'quarterly'});
|
||||
* ```
|
||||
*
|
||||
* The version number is specified with `version=n.nn`. You can choose
|
||||
* `version=3.40`, `version=3.39`, or `version=3.38`. Version numbers are
|
||||
* updated once per quarter.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: '3.40'});
|
||||
* ```
|
||||
*
|
||||
* If you do not explicitly specify a version, you will receive the
|
||||
* weekly version by default.
|
||||
*/
|
||||
version?: string;
|
||||
/**
|
||||
* The id of the script tag. Before adding a new script, the Loader will check for an existing one.
|
||||
*/
|
||||
id?: string;
|
||||
/**
|
||||
* When loading the Maps JavaScript API via the URL you may optionally load
|
||||
* additional libraries through use of the libraries URL parameter. Libraries
|
||||
* are modules of code that provide additional functionality to the main Maps
|
||||
* JavaScript API but are not loaded unless you specifically request them.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({
|
||||
* apiKey,
|
||||
* libraries: ['drawing', 'geometry', 'places', 'visualization'],
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Set the [list of libraries](https://developers.google.com/maps/documentation/javascript/libraries) for more options.
|
||||
*/
|
||||
libraries?: Libraries;
|
||||
/**
|
||||
* By default, the Maps JavaScript API uses the user's preferred language
|
||||
* setting as specified in the browser, when displaying textual information
|
||||
* such as the names for controls, copyright notices, driving directions and
|
||||
* labels on maps. In most cases, it's preferable to respect the browser
|
||||
* setting. However, if you want the Maps JavaScript API to ignore the
|
||||
* browser's language setting, you can force it to display information in a
|
||||
* particular language when loading the Maps JavaScript API code.
|
||||
*
|
||||
* For example, the following example localizes the language to Japan:
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, language: 'ja', region: 'JP'});
|
||||
* ```
|
||||
*
|
||||
* See the [list of supported
|
||||
* languages](https://developers.google.com/maps/faq#languagesupport). Note
|
||||
* that new languages are added often, so this list may not be exhaustive.
|
||||
*
|
||||
*/
|
||||
language?: string;
|
||||
/**
|
||||
* When you load the Maps JavaScript API from maps.googleapis.com it applies a
|
||||
* default bias for application behavior towards the United States. If you
|
||||
* want to alter your application to serve different map tiles or bias the
|
||||
* application (such as biasing geocoding results towards the region), you can
|
||||
* override this default behavior by adding a region parameter when loading
|
||||
* the Maps JavaScript API code.
|
||||
*
|
||||
* The region parameter accepts Unicode region subtag identifiers which
|
||||
* (generally) have a one-to-one mapping to country code Top-Level Domains
|
||||
* (ccTLDs). Most Unicode region identifiers are identical to ISO 3166-1
|
||||
* codes, with some notable exceptions. For example, Great Britain's ccTLD is
|
||||
* "uk" (corresponding to the domain .co.uk) while its region identifier is
|
||||
* "GB."
|
||||
*
|
||||
* For example, the following example localizes the map to the United Kingdom:
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, region: 'GB'});
|
||||
* ```
|
||||
*/
|
||||
region?: string;
|
||||
/**
|
||||
* @deprecated Passing `mapIds` is no longer required in the script tag.
|
||||
*/
|
||||
mapIds?: string[];
|
||||
/**
|
||||
* Use a custom url and path to load the Google Maps API script.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Use a cryptographic nonce attribute.
|
||||
*/
|
||||
nonce?: string;
|
||||
/**
|
||||
* The number of script load retries.
|
||||
*/
|
||||
retries?: number;
|
||||
/**
|
||||
* Maps JS customers can configure HTTP Referrer Restrictions in the Cloud
|
||||
* Console to limit which URLs are allowed to use a particular API Key. By
|
||||
* default, these restrictions can be configured to allow only certain paths
|
||||
* to use an API Key. If any URL on the same domain or origin may use the API
|
||||
* Key, you can set `auth_referrer_policy=origin` to limit the amount of data
|
||||
* sent when authorizing requests from the Maps JavaScript API. This is
|
||||
* available starting in version 3.46. When this parameter is specified and
|
||||
* HTTP Referrer Restrictions are enabled on Cloud Console, Maps JavaScript
|
||||
* API will only be able to load if there is an HTTP Referrer Restriction that
|
||||
* matches the current website's domain without a path specified.
|
||||
*/
|
||||
authReferrerPolicy?: "origin";
|
||||
}
|
||||
/**
|
||||
* The status of the [[Loader]].
|
||||
*/
|
||||
export declare enum LoaderStatus {
|
||||
INITIALIZED = 0,
|
||||
LOADING = 1,
|
||||
SUCCESS = 2,
|
||||
FAILURE = 3
|
||||
}
|
||||
/**
|
||||
* [[Loader]] makes it easier to add Google Maps JavaScript API to your application
|
||||
* dynamically using
|
||||
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||
* It works by dynamically creating and appending a script node to the the
|
||||
* document head and wrapping the callback function so as to return a promise.
|
||||
*
|
||||
* ```
|
||||
* const loader = new Loader({
|
||||
* apiKey: "",
|
||||
* version: "weekly",
|
||||
* libraries: ["places"]
|
||||
* });
|
||||
*
|
||||
* loader.load().then((google) => {
|
||||
* const map = new google.maps.Map(...)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export declare class Loader {
|
||||
private static instance;
|
||||
/**
|
||||
* See [[LoaderOptions.version]]
|
||||
*/
|
||||
readonly version: string;
|
||||
/**
|
||||
* See [[LoaderOptions.apiKey]]
|
||||
*/
|
||||
readonly apiKey: string;
|
||||
/**
|
||||
* See [[LoaderOptions.channel]]
|
||||
*/
|
||||
readonly channel: string;
|
||||
/**
|
||||
* See [[LoaderOptions.client]]
|
||||
*/
|
||||
readonly client: string;
|
||||
/**
|
||||
* See [[LoaderOptions.id]]
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* See [[LoaderOptions.libraries]]
|
||||
*/
|
||||
readonly libraries: Libraries;
|
||||
/**
|
||||
* See [[LoaderOptions.language]]
|
||||
*/
|
||||
readonly language: string;
|
||||
/**
|
||||
* See [[LoaderOptions.region]]
|
||||
*/
|
||||
readonly region: string;
|
||||
/**
|
||||
* See [[LoaderOptions.mapIds]]
|
||||
*/
|
||||
readonly mapIds: string[];
|
||||
/**
|
||||
* See [[LoaderOptions.nonce]]
|
||||
*/
|
||||
readonly nonce: string | null;
|
||||
/**
|
||||
* See [[LoaderOptions.retries]]
|
||||
*/
|
||||
readonly retries: number;
|
||||
/**
|
||||
* See [[LoaderOptions.url]]
|
||||
*/
|
||||
readonly url: string;
|
||||
/**
|
||||
* See [[LoaderOptions.authReferrerPolicy]]
|
||||
*/
|
||||
readonly authReferrerPolicy: "origin";
|
||||
private callbacks;
|
||||
private done;
|
||||
private loading;
|
||||
private onerrorEvent;
|
||||
private errors;
|
||||
/**
|
||||
* Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
|
||||
* using this library, instead the defaults are set by the Google Maps
|
||||
* JavaScript API server.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
|
||||
* ```
|
||||
*/
|
||||
constructor({ apiKey, authReferrerPolicy, channel, client, id, language, libraries, mapIds, nonce, region, retries, url, version, }: LoaderOptions);
|
||||
get options(): LoaderOptions;
|
||||
get status(): LoaderStatus;
|
||||
private get failed();
|
||||
/**
|
||||
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
|
||||
*
|
||||
* @ignore
|
||||
* @deprecated
|
||||
*/
|
||||
createUrl(): string;
|
||||
deleteScript(): void;
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script and return a Promise.
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
load(): Promise<typeof google>;
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script and return a Promise.
|
||||
*
|
||||
* @ignore
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
loadPromise(): Promise<typeof google>;
|
||||
/**
|
||||
* See https://developers.google.com/maps/documentation/javascript/reference/top-level#google.maps.importLibrary
|
||||
*/
|
||||
importLibrary(name: "core"): Promise<google.maps.CoreLibrary>;
|
||||
importLibrary(name: "maps"): Promise<google.maps.MapsLibrary>;
|
||||
importLibrary(name: "maps3d"): Promise<google.maps.Maps3DLibrary>;
|
||||
importLibrary(name: "places"): Promise<google.maps.PlacesLibrary>;
|
||||
importLibrary(name: "geocoding"): Promise<google.maps.GeocodingLibrary>;
|
||||
importLibrary(name: "routes"): Promise<google.maps.RoutesLibrary>;
|
||||
importLibrary(name: "marker"): Promise<google.maps.MarkerLibrary>;
|
||||
importLibrary(name: "geometry"): Promise<google.maps.GeometryLibrary>;
|
||||
importLibrary(name: "elevation"): Promise<google.maps.ElevationLibrary>;
|
||||
importLibrary(name: "streetView"): Promise<google.maps.StreetViewLibrary>;
|
||||
importLibrary(name: "journeySharing"): Promise<google.maps.JourneySharingLibrary>;
|
||||
importLibrary(name: "drawing"): Promise<google.maps.DrawingLibrary>;
|
||||
importLibrary(name: "visualization"): Promise<google.maps.VisualizationLibrary>;
|
||||
importLibrary(name: Library): Promise<unknown>;
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script with a callback.
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
loadCallback(fn: (e: ErrorEvent) => void): void;
|
||||
/**
|
||||
* Set the script on document.
|
||||
*/
|
||||
private setScript;
|
||||
/**
|
||||
* Reset the loader state.
|
||||
*/
|
||||
private reset;
|
||||
private resetIfRetryingFailed;
|
||||
private loadErrorCallback;
|
||||
private callback;
|
||||
private execute;
|
||||
}
|
||||
2793
node_modules/@googlemaps/js-api-loader/dist/index.dev.js
generated
vendored
Normal file
2793
node_modules/@googlemaps/js-api-loader/dist/index.dev.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@googlemaps/js-api-loader/dist/index.dev.js.map
generated
vendored
Normal file
1
node_modules/@googlemaps/js-api-loader/dist/index.dev.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@googlemaps/js-api-loader/dist/index.min.js
generated
vendored
Normal file
2
node_modules/@googlemaps/js-api-loader/dist/index.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@googlemaps/js-api-loader/dist/index.min.js.map
generated
vendored
Normal file
1
node_modules/@googlemaps/js-api-loader/dist/index.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
420
node_modules/@googlemaps/js-api-loader/dist/index.mjs
generated
vendored
Normal file
420
node_modules/@googlemaps/js-api-loader/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,420 @@
|
||||
/******************************************************************************
|
||||
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.
|
||||
***************************************************************************** */
|
||||
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
||||
|
||||
|
||||
function __awaiter(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());
|
||||
});
|
||||
}
|
||||
|
||||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
};
|
||||
|
||||
function getDefaultExportFromCjs (x) {
|
||||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
||||
}
|
||||
|
||||
var fastDeepEqual;
|
||||
var hasRequiredFastDeepEqual;
|
||||
|
||||
function requireFastDeepEqual () {
|
||||
if (hasRequiredFastDeepEqual) return fastDeepEqual;
|
||||
hasRequiredFastDeepEqual = 1;
|
||||
|
||||
// do not edit .js files directly - edit src/index.jst
|
||||
|
||||
|
||||
|
||||
fastDeepEqual = function equal(a, b) {
|
||||
if (a === b) return true;
|
||||
|
||||
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
||||
if (a.constructor !== b.constructor) return false;
|
||||
|
||||
var length, i, keys;
|
||||
if (Array.isArray(a)) {
|
||||
length = a.length;
|
||||
if (length != b.length) return false;
|
||||
for (i = length; i-- !== 0;)
|
||||
if (!equal(a[i], b[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
||||
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
||||
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
||||
|
||||
keys = Object.keys(a);
|
||||
length = keys.length;
|
||||
if (length !== Object.keys(b).length) return false;
|
||||
|
||||
for (i = length; i-- !== 0;)
|
||||
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
||||
|
||||
for (i = length; i-- !== 0;) {
|
||||
var key = keys[i];
|
||||
|
||||
if (!equal(a[key], b[key])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// true if both NaN, false otherwise
|
||||
return a!==a && b!==b;
|
||||
};
|
||||
return fastDeepEqual;
|
||||
}
|
||||
|
||||
var fastDeepEqualExports = requireFastDeepEqual();
|
||||
var isEqual = /*@__PURE__*/getDefaultExportFromCjs(fastDeepEqualExports);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const DEFAULT_ID = "__googleMapsScriptId";
|
||||
/**
|
||||
* The status of the [[Loader]].
|
||||
*/
|
||||
var LoaderStatus;
|
||||
(function (LoaderStatus) {
|
||||
LoaderStatus[LoaderStatus["INITIALIZED"] = 0] = "INITIALIZED";
|
||||
LoaderStatus[LoaderStatus["LOADING"] = 1] = "LOADING";
|
||||
LoaderStatus[LoaderStatus["SUCCESS"] = 2] = "SUCCESS";
|
||||
LoaderStatus[LoaderStatus["FAILURE"] = 3] = "FAILURE";
|
||||
})(LoaderStatus || (LoaderStatus = {}));
|
||||
/**
|
||||
* [[Loader]] makes it easier to add Google Maps JavaScript API to your application
|
||||
* dynamically using
|
||||
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||
* It works by dynamically creating and appending a script node to the the
|
||||
* document head and wrapping the callback function so as to return a promise.
|
||||
*
|
||||
* ```
|
||||
* const loader = new Loader({
|
||||
* apiKey: "",
|
||||
* version: "weekly",
|
||||
* libraries: ["places"]
|
||||
* });
|
||||
*
|
||||
* loader.load().then((google) => {
|
||||
* const map = new google.maps.Map(...)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
class Loader {
|
||||
/**
|
||||
* Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
|
||||
* using this library, instead the defaults are set by the Google Maps
|
||||
* JavaScript API server.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
|
||||
* ```
|
||||
*/
|
||||
constructor({ apiKey, authReferrerPolicy, channel, client, id = DEFAULT_ID, language, libraries = [], mapIds, nonce, region, retries = 3, url = "https://maps.googleapis.com/maps/api/js", version, }) {
|
||||
this.callbacks = [];
|
||||
this.done = false;
|
||||
this.loading = false;
|
||||
this.errors = [];
|
||||
this.apiKey = apiKey;
|
||||
this.authReferrerPolicy = authReferrerPolicy;
|
||||
this.channel = channel;
|
||||
this.client = client;
|
||||
this.id = id || DEFAULT_ID; // Do not allow empty string
|
||||
this.language = language;
|
||||
this.libraries = libraries;
|
||||
this.mapIds = mapIds;
|
||||
this.nonce = nonce;
|
||||
this.region = region;
|
||||
this.retries = retries;
|
||||
this.url = url;
|
||||
this.version = version;
|
||||
if (Loader.instance) {
|
||||
if (!isEqual(this.options, Loader.instance.options)) {
|
||||
throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(Loader.instance.options)}`);
|
||||
}
|
||||
return Loader.instance;
|
||||
}
|
||||
Loader.instance = this;
|
||||
}
|
||||
get options() {
|
||||
return {
|
||||
version: this.version,
|
||||
apiKey: this.apiKey,
|
||||
channel: this.channel,
|
||||
client: this.client,
|
||||
id: this.id,
|
||||
libraries: this.libraries,
|
||||
language: this.language,
|
||||
region: this.region,
|
||||
mapIds: this.mapIds,
|
||||
nonce: this.nonce,
|
||||
url: this.url,
|
||||
authReferrerPolicy: this.authReferrerPolicy,
|
||||
};
|
||||
}
|
||||
get status() {
|
||||
if (this.errors.length) {
|
||||
return LoaderStatus.FAILURE;
|
||||
}
|
||||
if (this.done) {
|
||||
return LoaderStatus.SUCCESS;
|
||||
}
|
||||
if (this.loading) {
|
||||
return LoaderStatus.LOADING;
|
||||
}
|
||||
return LoaderStatus.INITIALIZED;
|
||||
}
|
||||
get failed() {
|
||||
return this.done && !this.loading && this.errors.length >= this.retries + 1;
|
||||
}
|
||||
/**
|
||||
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
|
||||
*
|
||||
* @ignore
|
||||
* @deprecated
|
||||
*/
|
||||
createUrl() {
|
||||
let url = this.url;
|
||||
url += `?callback=__googleMapsCallback&loading=async`;
|
||||
if (this.apiKey) {
|
||||
url += `&key=${this.apiKey}`;
|
||||
}
|
||||
if (this.channel) {
|
||||
url += `&channel=${this.channel}`;
|
||||
}
|
||||
if (this.client) {
|
||||
url += `&client=${this.client}`;
|
||||
}
|
||||
if (this.libraries.length > 0) {
|
||||
url += `&libraries=${this.libraries.join(",")}`;
|
||||
}
|
||||
if (this.language) {
|
||||
url += `&language=${this.language}`;
|
||||
}
|
||||
if (this.region) {
|
||||
url += `®ion=${this.region}`;
|
||||
}
|
||||
if (this.version) {
|
||||
url += `&v=${this.version}`;
|
||||
}
|
||||
if (this.mapIds) {
|
||||
url += `&map_ids=${this.mapIds.join(",")}`;
|
||||
}
|
||||
if (this.authReferrerPolicy) {
|
||||
url += `&auth_referrer_policy=${this.authReferrerPolicy}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
deleteScript() {
|
||||
const script = document.getElementById(this.id);
|
||||
if (script) {
|
||||
script.remove();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script and return a Promise.
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
load() {
|
||||
return this.loadPromise();
|
||||
}
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script and return a Promise.
|
||||
*
|
||||
* @ignore
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
loadPromise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.loadCallback((err) => {
|
||||
if (!err) {
|
||||
resolve(window.google);
|
||||
}
|
||||
else {
|
||||
reject(err.error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
importLibrary(name) {
|
||||
this.execute();
|
||||
return google.maps.importLibrary(name);
|
||||
}
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script with a callback.
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
loadCallback(fn) {
|
||||
this.callbacks.push(fn);
|
||||
this.execute();
|
||||
}
|
||||
/**
|
||||
* Set the script on document.
|
||||
*/
|
||||
setScript() {
|
||||
var _a, _b;
|
||||
if (document.getElementById(this.id)) {
|
||||
// TODO wrap onerror callback for cases where the script was loaded elsewhere
|
||||
this.callback();
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
key: this.apiKey,
|
||||
channel: this.channel,
|
||||
client: this.client,
|
||||
libraries: this.libraries.length && this.libraries,
|
||||
v: this.version,
|
||||
mapIds: this.mapIds,
|
||||
language: this.language,
|
||||
region: this.region,
|
||||
authReferrerPolicy: this.authReferrerPolicy,
|
||||
};
|
||||
// keep the URL minimal:
|
||||
Object.keys(params).forEach(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(key) => !params[key] && delete params[key]);
|
||||
if (!((_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.importLibrary)) {
|
||||
// tweaked copy of https://developers.google.com/maps/documentation/javascript/load-maps-js-api#dynamic-library-import
|
||||
// which also sets the base url, the id, and the nonce
|
||||
/* eslint-disable */
|
||||
((g) => {
|
||||
// @ts-ignore
|
||||
let h, a, k, p = "The Google Maps JavaScript API", c = "google", l = "importLibrary", q = "__ib__", m = document, b = window;
|
||||
// @ts-ignore
|
||||
b = b[c] || (b[c] = {});
|
||||
// @ts-ignore
|
||||
const d = b.maps || (b.maps = {}), r = new Set(), e = new URLSearchParams(), u = () =>
|
||||
// @ts-ignore
|
||||
h || (h = new Promise((f, n) => __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
yield (a = m.createElement("script"));
|
||||
a.id = this.id;
|
||||
e.set("libraries", [...r] + "");
|
||||
// @ts-ignore
|
||||
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 = this.url + `?` + e;
|
||||
d[q] = f;
|
||||
a.onerror = () => (h = n(Error(p + " could not load.")));
|
||||
// @ts-ignore
|
||||
a.nonce = this.nonce || ((_a = m.querySelector("script[nonce]")) === null || _a === void 0 ? void 0 : _a.nonce) || "";
|
||||
m.head.append(a);
|
||||
})));
|
||||
// @ts-ignore
|
||||
d[l] ? console.warn(p + " only loads once. Ignoring:", g) : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n)));
|
||||
})(params);
|
||||
/* eslint-enable */
|
||||
}
|
||||
// While most libraries populate the global namespace when loaded via bootstrap params,
|
||||
// this is not the case for "marker" when used with the inline bootstrap loader
|
||||
// (and maybe others in the future). So ensure there is an importLibrary for each:
|
||||
const libraryPromises = this.libraries.map((library) => this.importLibrary(library));
|
||||
// ensure at least one library, to kick off loading...
|
||||
if (!libraryPromises.length) {
|
||||
libraryPromises.push(this.importLibrary("core"));
|
||||
}
|
||||
Promise.all(libraryPromises).then(() => this.callback(), (error) => {
|
||||
const event = new ErrorEvent("error", { error }); // for backwards compat
|
||||
this.loadErrorCallback(event);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Reset the loader state.
|
||||
*/
|
||||
reset() {
|
||||
this.deleteScript();
|
||||
this.done = false;
|
||||
this.loading = false;
|
||||
this.errors = [];
|
||||
this.onerrorEvent = null;
|
||||
}
|
||||
resetIfRetryingFailed() {
|
||||
if (this.failed) {
|
||||
this.reset();
|
||||
}
|
||||
}
|
||||
loadErrorCallback(e) {
|
||||
this.errors.push(e);
|
||||
if (this.errors.length <= this.retries) {
|
||||
const delay = this.errors.length * Math.pow(2, this.errors.length);
|
||||
console.error(`Failed to load Google Maps script, retrying in ${delay} ms.`);
|
||||
setTimeout(() => {
|
||||
this.deleteScript();
|
||||
this.setScript();
|
||||
}, delay);
|
||||
}
|
||||
else {
|
||||
this.onerrorEvent = e;
|
||||
this.callback();
|
||||
}
|
||||
}
|
||||
callback() {
|
||||
this.done = true;
|
||||
this.loading = false;
|
||||
this.callbacks.forEach((cb) => {
|
||||
cb(this.onerrorEvent);
|
||||
});
|
||||
this.callbacks = [];
|
||||
}
|
||||
execute() {
|
||||
this.resetIfRetryingFailed();
|
||||
if (this.loading) {
|
||||
// do nothing but wait
|
||||
return;
|
||||
}
|
||||
if (this.done) {
|
||||
this.callback();
|
||||
}
|
||||
else {
|
||||
// short circuit and warn if google.maps is already loaded
|
||||
if (window.google && window.google.maps && window.google.maps.version) {
|
||||
console.warn("Google Maps already loaded outside @googlemaps/js-api-loader. " +
|
||||
"This may result in undesirable behavior as options and script parameters may not match.");
|
||||
this.callback();
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
this.setScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { DEFAULT_ID, Loader, LoaderStatus };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
node_modules/@googlemaps/js-api-loader/dist/index.mjs.map
generated
vendored
Normal file
1
node_modules/@googlemaps/js-api-loader/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@googlemaps/js-api-loader/dist/index.umd.js
generated
vendored
Normal file
2
node_modules/@googlemaps/js-api-loader/dist/index.umd.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@googlemaps/js-api-loader/dist/index.umd.js.map
generated
vendored
Normal file
1
node_modules/@googlemaps/js-api-loader/dist/index.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
73
node_modules/@googlemaps/js-api-loader/package.json
generated
vendored
Normal file
73
node_modules/@googlemaps/js-api-loader/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "@googlemaps/js-api-loader",
|
||||
"type": "commonjs",
|
||||
"version": "1.16.10",
|
||||
"description": "Wrapper for the loading of Google Maps JavaScript API script in the browser",
|
||||
"keywords": [
|
||||
"google",
|
||||
"maps"
|
||||
],
|
||||
"homepage": "https://github.com/googlemaps/js-api-loader",
|
||||
"bugs": {
|
||||
"url": "https://github.com/googlemaps/js-api-loader/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/googlemaps/js-api-loader.git"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"author": "Justin Poehnelt",
|
||||
"main": "dist/index.umd.js",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/",
|
||||
"src/"
|
||||
],
|
||||
"scripts": {
|
||||
"docs": "typedoc src/index.ts && cp -r dist docs/dist && cp -r examples docs/examples",
|
||||
"format": "eslint . --fix",
|
||||
"lint": "eslint .",
|
||||
"prepare": "rm -rf dist && rollup -c",
|
||||
"test": "jest src/*",
|
||||
"test:e2e": "jest e2e/*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.9.5",
|
||||
"@babel/runtime-corejs3": "^7.9.2",
|
||||
"@rollup/plugin-babel": "^6.0.3",
|
||||
"@rollup/plugin-commonjs": "^28.0.0",
|
||||
"@rollup/plugin-node-resolve": "^16.0.0",
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"@rollup/plugin-typescript": "^12.1.0",
|
||||
"@types/google.maps": "^3.53.1",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/selenium-webdriver": "^4.0.9",
|
||||
"@typescript-eslint/eslint-plugin": "^8.8.1",
|
||||
"@typescript-eslint/parser": "^8.8.1",
|
||||
"core-js": "^3.6.4",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"geckodriver": "^5.0.0",
|
||||
"jest": "^30.0.3",
|
||||
"jest-environment-jsdom": "^30.0.2",
|
||||
"prettier": "^3.0.3",
|
||||
"rollup": "^4.6.1",
|
||||
"selenium-webdriver": "^4.0.0-alpha.7",
|
||||
"ts-jest": "^29.1.1",
|
||||
"tslib": "^2.8.1",
|
||||
"typedoc": "^0.28.5",
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://wombat-dressing-room.appspot.com"
|
||||
},
|
||||
"prettier": {
|
||||
"trailingComma": "es5"
|
||||
}
|
||||
}
|
||||
469
node_modules/@googlemaps/js-api-loader/src/index.test.ts
generated
vendored
Normal file
469
node_modules/@googlemaps/js-api-loader/src/index.test.ts
generated
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
||||
import { DEFAULT_ID, Loader, LoaderOptions, LoaderStatus } from ".";
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
afterEach(() => {
|
||||
document.getElementsByTagName("html")[0].innerHTML = "";
|
||||
delete Loader["instance"];
|
||||
if (window.google) delete window.google;
|
||||
});
|
||||
|
||||
test.each([
|
||||
[
|
||||
{},
|
||||
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async",
|
||||
],
|
||||
[
|
||||
{ apiKey: "foo" },
|
||||
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&key=foo",
|
||||
],
|
||||
[
|
||||
{
|
||||
apiKey: "foo",
|
||||
version: "weekly",
|
||||
libraries: ["marker", "places"],
|
||||
language: "language",
|
||||
region: "region",
|
||||
},
|
||||
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&key=foo&libraries=marker,places&language=language®ion=region&v=weekly",
|
||||
],
|
||||
[
|
||||
{ mapIds: ["foo", "bar"] },
|
||||
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&map_ids=foo,bar",
|
||||
],
|
||||
[
|
||||
{ url: "https://example.com/js" },
|
||||
"https://example.com/js?callback=__googleMapsCallback&loading=async",
|
||||
],
|
||||
[
|
||||
{ client: "bar", channel: "foo" },
|
||||
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&channel=foo&client=bar",
|
||||
],
|
||||
[
|
||||
{ authReferrerPolicy: "origin" },
|
||||
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&auth_referrer_policy=origin",
|
||||
],
|
||||
])("createUrl is correct", (options: LoaderOptions, expected: string) => {
|
||||
const loader = new Loader(options);
|
||||
expect(loader.createUrl()).toEqual(expected);
|
||||
expect(loader.status).toBe(LoaderStatus.INITIALIZED);
|
||||
});
|
||||
|
||||
test("uses default id if empty string", () => {
|
||||
expect(new Loader({ apiKey: "foo", id: "" }).id).toBe(DEFAULT_ID);
|
||||
});
|
||||
|
||||
test("setScript adds a script to head with correct attributes", async () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
|
||||
loader["setScript"]();
|
||||
await 0;
|
||||
|
||||
const script = document.head.childNodes[0] as HTMLScriptElement;
|
||||
|
||||
expect(script.id).toEqual(loader.id);
|
||||
});
|
||||
|
||||
test("setScript adds a script with id", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", id: "bar" });
|
||||
loader["setScript"]();
|
||||
await 0;
|
||||
|
||||
const script = document.head.childNodes[0] as HTMLScriptElement;
|
||||
expect(script.localName).toEqual("script");
|
||||
expect(loader.id).toEqual("bar");
|
||||
expect(script.id).toEqual("bar");
|
||||
});
|
||||
|
||||
test("setScript does not add second script with same id", async () => {
|
||||
new Loader({ apiKey: "foo", id: "bar" })["setScript"]();
|
||||
new Loader({ apiKey: "foo", id: "bar" })["setScript"]();
|
||||
await 0;
|
||||
new Loader({ apiKey: "foo", id: "bar" })["setScript"]();
|
||||
await 0;
|
||||
|
||||
expect(document.head.childNodes.length).toBe(1);
|
||||
});
|
||||
|
||||
test("setScript adds a script to head with valid src", async () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
|
||||
loader["setScript"]();
|
||||
await 0;
|
||||
|
||||
const script = document.head.childNodes[0] as HTMLScriptElement;
|
||||
|
||||
expect(script.src).toEqual(
|
||||
"https://maps.googleapis.com/maps/api/js?libraries=core&key=foo&callback=google.maps.__ib__"
|
||||
);
|
||||
});
|
||||
|
||||
test("setScript adds a script to head with valid src with libraries", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", libraries: ["marker", "places"] });
|
||||
|
||||
loader["setScript"]();
|
||||
await 0;
|
||||
|
||||
const script = document.head.childNodes[0] as HTMLScriptElement;
|
||||
|
||||
expect(script.src).toEqual(
|
||||
"https://maps.googleapis.com/maps/api/js?libraries=marker%2Cplaces&key=foo&callback=google.maps.__ib__"
|
||||
);
|
||||
});
|
||||
|
||||
test("load should return a promise that resolves even if called twice", () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
loader.importLibrary = (() => Promise.resolve()) as any;
|
||||
|
||||
expect.assertions(1);
|
||||
const promise = Promise.all([loader.load(), loader.load()]).then(() => {
|
||||
expect(loader["done"]).toBeTruthy();
|
||||
});
|
||||
|
||||
return promise;
|
||||
});
|
||||
|
||||
test("loadCallback callback should fire", () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
loader.importLibrary = (() => Promise.resolve()) as any;
|
||||
|
||||
expect.assertions(2);
|
||||
loader.loadCallback((e: Event) => {
|
||||
expect(loader["done"]).toBeTruthy();
|
||||
expect(e).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
test("script onerror should reject promise", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
|
||||
const rejection = expect(loader.load()).rejects.toBeInstanceOf(Error);
|
||||
|
||||
loader["loadErrorCallback"](
|
||||
new ErrorEvent("ErrorEvent(", { error: new Error("") })
|
||||
);
|
||||
|
||||
await rejection;
|
||||
expect(loader["done"]).toBeTruthy();
|
||||
expect(loader["loading"]).toBeFalsy();
|
||||
expect(loader["errors"].length).toBe(1);
|
||||
expect(loader.status).toBe(LoaderStatus.FAILURE);
|
||||
});
|
||||
|
||||
test("script onerror should reject promise with multiple loaders", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
const extraLoader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
|
||||
let rejection = expect(loader.load()).rejects.toBeInstanceOf(Error);
|
||||
loader["loadErrorCallback"](
|
||||
new ErrorEvent("ErrorEvent(", { error: new Error("") })
|
||||
);
|
||||
|
||||
await rejection;
|
||||
expect(loader["done"]).toBeTruthy();
|
||||
expect(loader["loading"]).toBeFalsy();
|
||||
expect(loader["onerrorEvent"]).toBeInstanceOf(ErrorEvent);
|
||||
|
||||
rejection = expect(extraLoader.load()).rejects.toBeInstanceOf(Error);
|
||||
loader["loadErrorCallback"](
|
||||
new ErrorEvent("ErrorEvent(", { error: new Error("") })
|
||||
);
|
||||
|
||||
await rejection;
|
||||
expect(extraLoader["done"]).toBeTruthy();
|
||||
expect(extraLoader["loading"]).toBeFalsy();
|
||||
});
|
||||
|
||||
test("script onerror should retry", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 1 });
|
||||
const deleteScript = jest.spyOn(loader, "deleteScript");
|
||||
loader.importLibrary = (() => Promise.reject(new Error("fake error"))) as any;
|
||||
const rejection = expect(loader.load()).rejects.toBeInstanceOf(Error);
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
console.error = jest.fn();
|
||||
|
||||
// wait for the first failure
|
||||
await 0;
|
||||
await 0;
|
||||
expect(loader["errors"].length).toBe(1);
|
||||
// trigger the retry delay:
|
||||
jest.runAllTimers();
|
||||
|
||||
await rejection;
|
||||
expect(loader["errors"].length).toBe(2);
|
||||
expect(loader["done"]).toBeTruthy();
|
||||
expect(loader["failed"]).toBeTruthy();
|
||||
expect(loader["loading"]).toBeFalsy();
|
||||
expect(deleteScript).toHaveBeenCalledTimes(1);
|
||||
expect(console.error).toHaveBeenCalledTimes(loader.retries);
|
||||
});
|
||||
|
||||
test("script onerror should reset retry mechanism with next loader", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 1 });
|
||||
const deleteScript = jest.spyOn(loader, "deleteScript");
|
||||
loader.importLibrary = (() => Promise.reject(new Error("fake error"))) as any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
console.error = jest.fn();
|
||||
|
||||
let rejection = expect(loader.load()).rejects.toBeInstanceOf(Error);
|
||||
// wait for the first first failure
|
||||
await 0;
|
||||
await 0;
|
||||
expect(loader["errors"].length).toBe(1);
|
||||
// trigger the retry delay:
|
||||
jest.runAllTimers();
|
||||
await rejection;
|
||||
|
||||
// try again...
|
||||
rejection = expect(loader.load()).rejects.toBeInstanceOf(Error);
|
||||
expect(loader["done"]).toBeFalsy();
|
||||
expect(loader["failed"]).toBeFalsy();
|
||||
expect(loader["loading"]).toBeTruthy();
|
||||
expect(loader["errors"].length).toBe(0);
|
||||
|
||||
// wait for the second first failure
|
||||
await 0;
|
||||
await 0;
|
||||
expect(loader["errors"].length).toBe(1);
|
||||
// trigger the retry delay:
|
||||
jest.runAllTimers();
|
||||
|
||||
await rejection;
|
||||
expect(deleteScript).toHaveBeenCalledTimes(3);
|
||||
expect(console.error).toHaveBeenCalledTimes(loader.retries * 2);
|
||||
});
|
||||
|
||||
test("script onerror should not reset retry mechanism with parallel loaders", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 1 });
|
||||
const deleteScript = jest.spyOn(loader, "deleteScript");
|
||||
loader.importLibrary = (() => Promise.reject(new Error("fake error"))) as any;
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
console.error = jest.fn();
|
||||
|
||||
const rejection1 = expect(loader.load()).rejects.toBeInstanceOf(Error);
|
||||
const rejection2 = expect(loader.load()).rejects.toBeInstanceOf(Error);
|
||||
// wait for the first first failure
|
||||
await 0;
|
||||
await 0;
|
||||
jest.runAllTimers();
|
||||
|
||||
await Promise.all([rejection1, rejection2]);
|
||||
expect(loader["done"]).toBeTruthy();
|
||||
expect(loader["loading"]).toBeFalsy();
|
||||
expect(loader["errors"].length).toBe(2);
|
||||
expect(deleteScript).toHaveBeenCalledTimes(1);
|
||||
expect(console.error).toHaveBeenCalledTimes(loader.retries);
|
||||
});
|
||||
|
||||
test("reset should clear state", () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
const deleteScript = jest.spyOn(loader, "deleteScript");
|
||||
|
||||
loader["done"] = true;
|
||||
loader["loading"] = false;
|
||||
loader["errors"] = [new ErrorEvent("foo")];
|
||||
|
||||
loader["reset"]();
|
||||
|
||||
expect(loader["done"]).toBeFalsy();
|
||||
expect(loader["loading"]).toBeFalsy();
|
||||
expect(loader["onerrorEvent"]).toBe(null);
|
||||
expect(deleteScript).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("failed getter should be correct", () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
|
||||
// initial
|
||||
expect(loader["failed"]).toBeFalsy();
|
||||
|
||||
// not done
|
||||
loader["done"] = false;
|
||||
loader["loading"] = false;
|
||||
loader["errors"] = [new ErrorEvent("foo")];
|
||||
expect(loader["failed"]).toBeFalsy();
|
||||
|
||||
// still loading
|
||||
loader["done"] = false;
|
||||
loader["loading"] = true;
|
||||
loader["errors"] = [new ErrorEvent("foo")];
|
||||
expect(loader["failed"]).toBeFalsy();
|
||||
|
||||
// no errors
|
||||
loader["done"] = true;
|
||||
loader["loading"] = false;
|
||||
loader["errors"] = [];
|
||||
expect(loader["failed"]).toBeFalsy();
|
||||
|
||||
// done with errors
|
||||
loader["done"] = true;
|
||||
loader["loading"] = false;
|
||||
loader["errors"] = [new ErrorEvent("foo")];
|
||||
expect(loader["failed"]).toBeTruthy();
|
||||
});
|
||||
|
||||
test("loader should not reset retry mechanism if successfully loaded", async () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
const deleteScript = jest.spyOn(loader, "deleteScript");
|
||||
loader.importLibrary = (() => Promise.resolve()) as any;
|
||||
|
||||
await expect(loader.load()).resolves.not.toBeUndefined();
|
||||
|
||||
expect(loader["done"]).toBeTruthy();
|
||||
expect(loader["loading"]).toBeFalsy();
|
||||
expect(deleteScript).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("singleton should be used", () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
const extraLoader = new Loader({ apiKey: "foo" });
|
||||
expect(extraLoader).toBe(loader);
|
||||
|
||||
loader["done"] = true;
|
||||
expect(extraLoader["done"]).toBe(loader["done"]);
|
||||
expect(loader.status).toBe(LoaderStatus.SUCCESS);
|
||||
});
|
||||
|
||||
test("singleton should throw with different options", () => {
|
||||
new Loader({ apiKey: "foo" });
|
||||
expect(() => {
|
||||
new Loader({ apiKey: "bar" });
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
test("loader should resolve immediately when successfully loaded", async () => {
|
||||
// use await/async pattern since the promise resolves without trigger
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
loader["done"] = true;
|
||||
// TODO causes warning
|
||||
window.google = { maps: { version: "3.*.*" } as any };
|
||||
await expect(loader.loadPromise()).resolves.toBeDefined();
|
||||
});
|
||||
|
||||
test("loader should resolve immediately when failed loading", async () => {
|
||||
// use await/async pattern since the promise rejects without trigger
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
loader["done"] = true;
|
||||
loader["onerrorEvent"] = new ErrorEvent("ErrorEvent(", {
|
||||
error: new Error(""),
|
||||
});
|
||||
|
||||
await expect(loader.loadPromise()).rejects.toBeDefined();
|
||||
});
|
||||
|
||||
test("loader should wait if already loading", () => {
|
||||
const loader = new Loader({ apiKey: "foo", retries: 0 });
|
||||
loader["loading"] = true;
|
||||
expect(loader.status).toBe(LoaderStatus.LOADING);
|
||||
loader.load();
|
||||
});
|
||||
|
||||
test("setScript adds a nonce", async () => {
|
||||
const nonce = "bar";
|
||||
const loader = new Loader({ apiKey: "foo", nonce });
|
||||
loader["setScript"]();
|
||||
await 0;
|
||||
const script = document.head.childNodes[0] as HTMLScriptElement;
|
||||
expect(script.nonce).toBe(nonce);
|
||||
});
|
||||
|
||||
test("loader should resolve immediately when google.maps defined", async () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
window.google = { maps: { version: "3.*.*" } as any };
|
||||
console.warn = jest.fn();
|
||||
await expect(loader.loadPromise()).resolves.toBeDefined();
|
||||
delete window.google;
|
||||
expect(console.warn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("loader should not warn if done and google.maps is defined", async () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
loader["done"] = true;
|
||||
window.google = { maps: { version: "3.*.*" } as any };
|
||||
console.warn = jest.fn();
|
||||
await expect(loader.loadPromise()).resolves.toBeDefined();
|
||||
delete window.google;
|
||||
expect(console.warn).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("deleteScript removes script tag from head", async () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
loader["setScript"]();
|
||||
await 0;
|
||||
expect(document.head.childNodes.length).toBe(1);
|
||||
loader.deleteScript();
|
||||
expect(document.head.childNodes.length).toBe(0);
|
||||
// should work without script existing
|
||||
loader.deleteScript();
|
||||
expect(document.head.childNodes.length).toBe(0);
|
||||
});
|
||||
|
||||
test("importLibrary resolves correctly", async () => {
|
||||
window.google = { maps: {} } as any;
|
||||
google.maps.importLibrary = async (name) => ({ [name]: "fake" }) as any;
|
||||
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
const corePromise = loader.importLibrary("core");
|
||||
|
||||
const core = await corePromise;
|
||||
expect(core).toEqual({ core: "fake" });
|
||||
});
|
||||
|
||||
test("importLibrary resolves correctly without warning with sequential await", async () => {
|
||||
console.warn = jest.fn();
|
||||
window.google = { maps: {} } as any;
|
||||
google.maps.importLibrary = async (name) => {
|
||||
google.maps.version = "3.*.*";
|
||||
return { [name]: "fake" } as any;
|
||||
};
|
||||
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
const core = await loader.importLibrary("core");
|
||||
const marker = await loader.importLibrary("marker");
|
||||
|
||||
expect(console.warn).toHaveBeenCalledTimes(0);
|
||||
expect(core).toEqual({ core: "fake" });
|
||||
expect(marker).toEqual({ marker: "fake" });
|
||||
});
|
||||
|
||||
test("importLibrary can also set up bootstrap libraries (if bootstrap libraries empty)", async () => {
|
||||
const loader = new Loader({ apiKey: "foo" });
|
||||
loader.importLibrary("marker");
|
||||
loader.importLibrary("places");
|
||||
|
||||
await 0;
|
||||
|
||||
const script = document.head.childNodes[0] as HTMLScriptElement;
|
||||
|
||||
expect(script.src).toEqual(
|
||||
"https://maps.googleapis.com/maps/api/js?libraries=core%2Cmarker%2Cplaces&key=foo&callback=google.maps.__ib__"
|
||||
);
|
||||
});
|
||||
|
||||
test("importLibrary resolves correctly even with different bootstrap libraries", async () => {
|
||||
window.google = { maps: {} } as any;
|
||||
google.maps.importLibrary = async (name) => ({ [name]: "fake" }) as any;
|
||||
|
||||
const loader = new Loader({ apiKey: "foo", libraries: ["places"] });
|
||||
const corePromise = loader.importLibrary("core");
|
||||
|
||||
const core = await corePromise;
|
||||
expect(core).toEqual({ core: "fake" });
|
||||
expect(await loader.importLibrary("places")).toEqual({ places: "fake" });
|
||||
});
|
||||
650
node_modules/@googlemaps/js-api-loader/src/index.ts
generated
vendored
Normal file
650
node_modules/@googlemaps/js-api-loader/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,650 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import isEqual from "fast-deep-equal";
|
||||
|
||||
export const DEFAULT_ID = "__googleMapsScriptId";
|
||||
|
||||
// https://developers.google.com/maps/documentation/javascript/libraries#libraries-for-dynamic-library-import
|
||||
export type Library =
|
||||
| "core"
|
||||
| "maps"
|
||||
| "maps3d"
|
||||
| "places"
|
||||
| "geocoding"
|
||||
| "routes"
|
||||
| "marker"
|
||||
| "geometry"
|
||||
| "elevation"
|
||||
| "streetView"
|
||||
| "journeySharing"
|
||||
| "drawing"
|
||||
| "visualization";
|
||||
|
||||
export type Libraries = Library[];
|
||||
|
||||
/**
|
||||
* The Google Maps JavaScript API
|
||||
* [documentation](https://developers.google.com/maps/documentation/javascript/tutorial)
|
||||
* is the authoritative source for [[LoaderOptions]].
|
||||
/**
|
||||
* Loader options
|
||||
*/
|
||||
export interface LoaderOptions {
|
||||
/**
|
||||
* See https://developers.google.com/maps/documentation/javascript/get-api-key.
|
||||
*/
|
||||
apiKey: string;
|
||||
/**
|
||||
* @deprecated See https://developers.google.com/maps/premium/overview.
|
||||
*/
|
||||
channel?: string;
|
||||
/**
|
||||
* @deprecated See https://developers.google.com/maps/premium/overview, use `apiKey` instead.
|
||||
*/
|
||||
client?: string;
|
||||
/**
|
||||
* In your application you can specify release channels or version numbers:
|
||||
*
|
||||
* The weekly version is specified with `version=weekly`. This version is
|
||||
* updated once per week, and is the most current.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: 'weekly'});
|
||||
* ```
|
||||
*
|
||||
* The quarterly version is specified with `version=quarterly`. This version
|
||||
* is updated once per quarter, and is the most predictable.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: 'quarterly'});
|
||||
* ```
|
||||
*
|
||||
* The version number is specified with `version=n.nn`. You can choose
|
||||
* `version=3.40`, `version=3.39`, or `version=3.38`. Version numbers are
|
||||
* updated once per quarter.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: '3.40'});
|
||||
* ```
|
||||
*
|
||||
* If you do not explicitly specify a version, you will receive the
|
||||
* weekly version by default.
|
||||
*/
|
||||
version?: string;
|
||||
/**
|
||||
* The id of the script tag. Before adding a new script, the Loader will check for an existing one.
|
||||
*/
|
||||
id?: string;
|
||||
/**
|
||||
* When loading the Maps JavaScript API via the URL you may optionally load
|
||||
* additional libraries through use of the libraries URL parameter. Libraries
|
||||
* are modules of code that provide additional functionality to the main Maps
|
||||
* JavaScript API but are not loaded unless you specifically request them.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({
|
||||
* apiKey,
|
||||
* libraries: ['drawing', 'geometry', 'places', 'visualization'],
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Set the [list of libraries](https://developers.google.com/maps/documentation/javascript/libraries) for more options.
|
||||
*/
|
||||
libraries?: Libraries;
|
||||
/**
|
||||
* By default, the Maps JavaScript API uses the user's preferred language
|
||||
* setting as specified in the browser, when displaying textual information
|
||||
* such as the names for controls, copyright notices, driving directions and
|
||||
* labels on maps. In most cases, it's preferable to respect the browser
|
||||
* setting. However, if you want the Maps JavaScript API to ignore the
|
||||
* browser's language setting, you can force it to display information in a
|
||||
* particular language when loading the Maps JavaScript API code.
|
||||
*
|
||||
* For example, the following example localizes the language to Japan:
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, language: 'ja', region: 'JP'});
|
||||
* ```
|
||||
*
|
||||
* See the [list of supported
|
||||
* languages](https://developers.google.com/maps/faq#languagesupport). Note
|
||||
* that new languages are added often, so this list may not be exhaustive.
|
||||
*
|
||||
*/
|
||||
language?: string;
|
||||
/**
|
||||
* When you load the Maps JavaScript API from maps.googleapis.com it applies a
|
||||
* default bias for application behavior towards the United States. If you
|
||||
* want to alter your application to serve different map tiles or bias the
|
||||
* application (such as biasing geocoding results towards the region), you can
|
||||
* override this default behavior by adding a region parameter when loading
|
||||
* the Maps JavaScript API code.
|
||||
*
|
||||
* The region parameter accepts Unicode region subtag identifiers which
|
||||
* (generally) have a one-to-one mapping to country code Top-Level Domains
|
||||
* (ccTLDs). Most Unicode region identifiers are identical to ISO 3166-1
|
||||
* codes, with some notable exceptions. For example, Great Britain's ccTLD is
|
||||
* "uk" (corresponding to the domain .co.uk) while its region identifier is
|
||||
* "GB."
|
||||
*
|
||||
* For example, the following example localizes the map to the United Kingdom:
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, region: 'GB'});
|
||||
* ```
|
||||
*/
|
||||
region?: string;
|
||||
/**
|
||||
* @deprecated Passing `mapIds` is no longer required in the script tag.
|
||||
*/
|
||||
mapIds?: string[];
|
||||
/**
|
||||
* Use a custom url and path to load the Google Maps API script.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Use a cryptographic nonce attribute.
|
||||
*/
|
||||
nonce?: string;
|
||||
/**
|
||||
* The number of script load retries.
|
||||
*/
|
||||
retries?: number;
|
||||
/**
|
||||
* Maps JS customers can configure HTTP Referrer Restrictions in the Cloud
|
||||
* Console to limit which URLs are allowed to use a particular API Key. By
|
||||
* default, these restrictions can be configured to allow only certain paths
|
||||
* to use an API Key. If any URL on the same domain or origin may use the API
|
||||
* Key, you can set `auth_referrer_policy=origin` to limit the amount of data
|
||||
* sent when authorizing requests from the Maps JavaScript API. This is
|
||||
* available starting in version 3.46. When this parameter is specified and
|
||||
* HTTP Referrer Restrictions are enabled on Cloud Console, Maps JavaScript
|
||||
* API will only be able to load if there is an HTTP Referrer Restriction that
|
||||
* matches the current website's domain without a path specified.
|
||||
*/
|
||||
authReferrerPolicy?: "origin";
|
||||
}
|
||||
|
||||
/**
|
||||
* The status of the [[Loader]].
|
||||
*/
|
||||
export enum LoaderStatus {
|
||||
INITIALIZED,
|
||||
LOADING,
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
}
|
||||
|
||||
/**
|
||||
* [[Loader]] makes it easier to add Google Maps JavaScript API to your application
|
||||
* dynamically using
|
||||
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||
* It works by dynamically creating and appending a script node to the the
|
||||
* document head and wrapping the callback function so as to return a promise.
|
||||
*
|
||||
* ```
|
||||
* const loader = new Loader({
|
||||
* apiKey: "",
|
||||
* version: "weekly",
|
||||
* libraries: ["places"]
|
||||
* });
|
||||
*
|
||||
* loader.load().then((google) => {
|
||||
* const map = new google.maps.Map(...)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export class Loader {
|
||||
private static instance: Loader;
|
||||
/**
|
||||
* See [[LoaderOptions.version]]
|
||||
*/
|
||||
public readonly version: string;
|
||||
/**
|
||||
* See [[LoaderOptions.apiKey]]
|
||||
*/
|
||||
public readonly apiKey: string;
|
||||
/**
|
||||
* See [[LoaderOptions.channel]]
|
||||
*/
|
||||
public readonly channel: string;
|
||||
/**
|
||||
* See [[LoaderOptions.client]]
|
||||
*/
|
||||
public readonly client: string;
|
||||
/**
|
||||
* See [[LoaderOptions.id]]
|
||||
*/
|
||||
public readonly id: string;
|
||||
/**
|
||||
* See [[LoaderOptions.libraries]]
|
||||
*/
|
||||
public readonly libraries: Libraries;
|
||||
/**
|
||||
* See [[LoaderOptions.language]]
|
||||
*/
|
||||
public readonly language: string;
|
||||
|
||||
/**
|
||||
* See [[LoaderOptions.region]]
|
||||
*/
|
||||
public readonly region: string;
|
||||
|
||||
/**
|
||||
* See [[LoaderOptions.mapIds]]
|
||||
*/
|
||||
public readonly mapIds: string[];
|
||||
|
||||
/**
|
||||
* See [[LoaderOptions.nonce]]
|
||||
*/
|
||||
public readonly nonce: string | null;
|
||||
|
||||
/**
|
||||
* See [[LoaderOptions.retries]]
|
||||
*/
|
||||
public readonly retries: number;
|
||||
|
||||
/**
|
||||
* See [[LoaderOptions.url]]
|
||||
*/
|
||||
public readonly url: string;
|
||||
/**
|
||||
* See [[LoaderOptions.authReferrerPolicy]]
|
||||
*/
|
||||
public readonly authReferrerPolicy: "origin";
|
||||
|
||||
private callbacks: ((e: ErrorEvent) => void)[] = [];
|
||||
private done = false;
|
||||
private loading = false;
|
||||
private onerrorEvent: ErrorEvent;
|
||||
private errors: ErrorEvent[] = [];
|
||||
|
||||
/**
|
||||
* Creates an instance of Loader using [[LoaderOptions]]. No defaults are set
|
||||
* using this library, instead the defaults are set by the Google Maps
|
||||
* JavaScript API server.
|
||||
*
|
||||
* ```
|
||||
* const loader = Loader({apiKey, version: 'weekly', libraries: ['places']});
|
||||
* ```
|
||||
*/
|
||||
constructor({
|
||||
apiKey,
|
||||
authReferrerPolicy,
|
||||
channel,
|
||||
client,
|
||||
id = DEFAULT_ID,
|
||||
language,
|
||||
libraries = [],
|
||||
mapIds,
|
||||
nonce,
|
||||
region,
|
||||
retries = 3,
|
||||
url = "https://maps.googleapis.com/maps/api/js",
|
||||
version,
|
||||
}: LoaderOptions) {
|
||||
this.apiKey = apiKey;
|
||||
this.authReferrerPolicy = authReferrerPolicy;
|
||||
this.channel = channel;
|
||||
this.client = client;
|
||||
this.id = id || DEFAULT_ID; // Do not allow empty string
|
||||
this.language = language;
|
||||
this.libraries = libraries;
|
||||
this.mapIds = mapIds;
|
||||
this.nonce = nonce;
|
||||
this.region = region;
|
||||
this.retries = retries;
|
||||
this.url = url;
|
||||
this.version = version;
|
||||
|
||||
if (Loader.instance) {
|
||||
if (!isEqual(this.options, Loader.instance.options)) {
|
||||
throw new Error(
|
||||
`Loader must not be called again with different options. ${JSON.stringify(
|
||||
this.options
|
||||
)} !== ${JSON.stringify(Loader.instance.options)}`
|
||||
);
|
||||
}
|
||||
|
||||
return Loader.instance;
|
||||
}
|
||||
|
||||
Loader.instance = this;
|
||||
}
|
||||
|
||||
public get options(): LoaderOptions {
|
||||
return {
|
||||
version: this.version,
|
||||
apiKey: this.apiKey,
|
||||
channel: this.channel,
|
||||
client: this.client,
|
||||
id: this.id,
|
||||
libraries: this.libraries,
|
||||
language: this.language,
|
||||
region: this.region,
|
||||
mapIds: this.mapIds,
|
||||
nonce: this.nonce,
|
||||
url: this.url,
|
||||
authReferrerPolicy: this.authReferrerPolicy,
|
||||
};
|
||||
}
|
||||
|
||||
public get status(): LoaderStatus {
|
||||
if (this.errors.length) {
|
||||
return LoaderStatus.FAILURE;
|
||||
}
|
||||
if (this.done) {
|
||||
return LoaderStatus.SUCCESS;
|
||||
}
|
||||
if (this.loading) {
|
||||
return LoaderStatus.LOADING;
|
||||
}
|
||||
return LoaderStatus.INITIALIZED;
|
||||
}
|
||||
|
||||
private get failed(): boolean {
|
||||
return this.done && !this.loading && this.errors.length >= this.retries + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateUrl returns the Google Maps JavaScript API script url given the [[LoaderOptions]].
|
||||
*
|
||||
* @ignore
|
||||
* @deprecated
|
||||
*/
|
||||
public createUrl(): string {
|
||||
let url = this.url;
|
||||
|
||||
url += `?callback=__googleMapsCallback&loading=async`;
|
||||
|
||||
if (this.apiKey) {
|
||||
url += `&key=${this.apiKey}`;
|
||||
}
|
||||
|
||||
if (this.channel) {
|
||||
url += `&channel=${this.channel}`;
|
||||
}
|
||||
|
||||
if (this.client) {
|
||||
url += `&client=${this.client}`;
|
||||
}
|
||||
|
||||
if (this.libraries.length > 0) {
|
||||
url += `&libraries=${this.libraries.join(",")}`;
|
||||
}
|
||||
|
||||
if (this.language) {
|
||||
url += `&language=${this.language}`;
|
||||
}
|
||||
|
||||
if (this.region) {
|
||||
url += `®ion=${this.region}`;
|
||||
}
|
||||
|
||||
if (this.version) {
|
||||
url += `&v=${this.version}`;
|
||||
}
|
||||
|
||||
if (this.mapIds) {
|
||||
url += `&map_ids=${this.mapIds.join(",")}`;
|
||||
}
|
||||
|
||||
if (this.authReferrerPolicy) {
|
||||
url += `&auth_referrer_policy=${this.authReferrerPolicy}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public deleteScript(): void {
|
||||
const script = document.getElementById(this.id);
|
||||
if (script) {
|
||||
script.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script and return a Promise.
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
public load(): Promise<typeof google> {
|
||||
return this.loadPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script and return a Promise.
|
||||
*
|
||||
* @ignore
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
public loadPromise(): Promise<typeof google> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.loadCallback((err: ErrorEvent) => {
|
||||
if (!err) {
|
||||
resolve(window.google);
|
||||
} else {
|
||||
reject(err.error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* See https://developers.google.com/maps/documentation/javascript/reference/top-level#google.maps.importLibrary
|
||||
*/
|
||||
public importLibrary(name: "core"): Promise<google.maps.CoreLibrary>;
|
||||
public importLibrary(name: "maps"): Promise<google.maps.MapsLibrary>;
|
||||
public importLibrary(name: "maps3d"): Promise<google.maps.Maps3DLibrary>;
|
||||
public importLibrary(name: "places"): Promise<google.maps.PlacesLibrary>;
|
||||
public importLibrary(
|
||||
name: "geocoding"
|
||||
): Promise<google.maps.GeocodingLibrary>;
|
||||
public importLibrary(name: "routes"): Promise<google.maps.RoutesLibrary>;
|
||||
public importLibrary(name: "marker"): Promise<google.maps.MarkerLibrary>;
|
||||
public importLibrary(name: "geometry"): Promise<google.maps.GeometryLibrary>;
|
||||
public importLibrary(
|
||||
name: "elevation"
|
||||
): Promise<google.maps.ElevationLibrary>;
|
||||
public importLibrary(
|
||||
name: "streetView"
|
||||
): Promise<google.maps.StreetViewLibrary>;
|
||||
public importLibrary(
|
||||
name: "journeySharing"
|
||||
): Promise<google.maps.JourneySharingLibrary>;
|
||||
public importLibrary(name: "drawing"): Promise<google.maps.DrawingLibrary>;
|
||||
public importLibrary(
|
||||
name: "visualization"
|
||||
): Promise<google.maps.VisualizationLibrary>;
|
||||
public importLibrary(name: Library): Promise<unknown>;
|
||||
public importLibrary(name: Library): Promise<unknown> {
|
||||
this.execute();
|
||||
return google.maps.importLibrary(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Google Maps JavaScript API script with a callback.
|
||||
* @deprecated, use importLibrary() instead.
|
||||
*/
|
||||
public loadCallback(fn: (e: ErrorEvent) => void): void {
|
||||
this.callbacks.push(fn);
|
||||
this.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script on document.
|
||||
*/
|
||||
private setScript(): void {
|
||||
if (document.getElementById(this.id)) {
|
||||
// TODO wrap onerror callback for cases where the script was loaded elsewhere
|
||||
this.callback();
|
||||
return;
|
||||
}
|
||||
|
||||
const params = {
|
||||
key: this.apiKey,
|
||||
channel: this.channel,
|
||||
client: this.client,
|
||||
libraries: this.libraries.length && this.libraries,
|
||||
v: this.version,
|
||||
mapIds: this.mapIds,
|
||||
language: this.language,
|
||||
region: this.region,
|
||||
authReferrerPolicy: this.authReferrerPolicy,
|
||||
};
|
||||
// keep the URL minimal:
|
||||
Object.keys(params).forEach(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(key) => !(params as any)[key] && delete (params as any)[key]
|
||||
);
|
||||
|
||||
if (!window?.google?.maps?.importLibrary) {
|
||||
// tweaked copy of https://developers.google.com/maps/documentation/javascript/load-maps-js-api#dynamic-library-import
|
||||
// which also sets the base url, the id, and the nonce
|
||||
/* eslint-disable */
|
||||
((g) => {
|
||||
// @ts-ignore
|
||||
let h,
|
||||
a,
|
||||
k,
|
||||
p = "The Google Maps JavaScript API",
|
||||
c = "google",
|
||||
l = "importLibrary",
|
||||
q = "__ib__",
|
||||
m = document,
|
||||
b = window;
|
||||
// @ts-ignore
|
||||
b = b[c] || (b[c] = {});
|
||||
// @ts-ignore
|
||||
const d = b.maps || (b.maps = {}),
|
||||
r = new Set(),
|
||||
e = new URLSearchParams(),
|
||||
u = () =>
|
||||
// @ts-ignore
|
||||
h || (h = new Promise(async (f, n) => {
|
||||
await (a = m.createElement("script"));
|
||||
a.id = this.id;
|
||||
e.set("libraries", [...r] + "");
|
||||
// @ts-ignore
|
||||
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 = this.url + `?` + e;
|
||||
d[q] = f;
|
||||
a.onerror = () => (h = n(Error(p + " could not load.")));
|
||||
// @ts-ignore
|
||||
a.nonce = this.nonce || m.querySelector("script[nonce]")?.nonce || "";
|
||||
m.head.append(a);
|
||||
}));
|
||||
// @ts-ignore
|
||||
d[l] ? console.warn(p + " only loads once. Ignoring:", g) : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n)));
|
||||
})(params);
|
||||
/* eslint-enable */
|
||||
}
|
||||
|
||||
// While most libraries populate the global namespace when loaded via bootstrap params,
|
||||
// this is not the case for "marker" when used with the inline bootstrap loader
|
||||
// (and maybe others in the future). So ensure there is an importLibrary for each:
|
||||
const libraryPromises = this.libraries.map((library) =>
|
||||
this.importLibrary(library)
|
||||
);
|
||||
// ensure at least one library, to kick off loading...
|
||||
if (!libraryPromises.length) {
|
||||
libraryPromises.push(this.importLibrary("core"));
|
||||
}
|
||||
Promise.all(libraryPromises).then(
|
||||
() => this.callback(),
|
||||
(error) => {
|
||||
const event = new ErrorEvent("error", { error }); // for backwards compat
|
||||
this.loadErrorCallback(event);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the loader state.
|
||||
*/
|
||||
private reset(): void {
|
||||
this.deleteScript();
|
||||
this.done = false;
|
||||
this.loading = false;
|
||||
this.errors = [];
|
||||
this.onerrorEvent = null;
|
||||
}
|
||||
|
||||
private resetIfRetryingFailed(): void {
|
||||
if (this.failed) {
|
||||
this.reset();
|
||||
}
|
||||
}
|
||||
|
||||
private loadErrorCallback(e: ErrorEvent): void {
|
||||
this.errors.push(e);
|
||||
|
||||
if (this.errors.length <= this.retries) {
|
||||
const delay = this.errors.length * 2 ** this.errors.length;
|
||||
|
||||
console.error(
|
||||
`Failed to load Google Maps script, retrying in ${delay} ms.`
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
this.deleteScript();
|
||||
this.setScript();
|
||||
}, delay);
|
||||
} else {
|
||||
this.onerrorEvent = e;
|
||||
this.callback();
|
||||
}
|
||||
}
|
||||
|
||||
private callback(): void {
|
||||
this.done = true;
|
||||
this.loading = false;
|
||||
|
||||
this.callbacks.forEach((cb) => {
|
||||
cb(this.onerrorEvent);
|
||||
});
|
||||
|
||||
this.callbacks = [];
|
||||
}
|
||||
|
||||
private execute(): void {
|
||||
this.resetIfRetryingFailed();
|
||||
|
||||
if (this.loading) {
|
||||
// do nothing but wait
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.done) {
|
||||
this.callback();
|
||||
} else {
|
||||
// short circuit and warn if google.maps is already loaded
|
||||
if (window.google && window.google.maps && window.google.maps.version) {
|
||||
console.warn(
|
||||
"Google Maps already loaded outside @googlemaps/js-api-loader. " +
|
||||
"This may result in undesirable behavior as options and script parameters may not match."
|
||||
);
|
||||
this.callback();
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.setScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
202
node_modules/@googlemaps/markerclusterer/LICENSE
generated
vendored
Normal file
202
node_modules/@googlemaps/markerclusterer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
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.
|
||||
105
node_modules/@googlemaps/markerclusterer/README.md
generated
vendored
Normal file
105
node_modules/@googlemaps/markerclusterer/README.md
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
# Google Maps JavaScript MarkerClusterer
|
||||
|
||||
[](https://www.npmjs.com/package/@googlemaps/markerclusterer)
|
||||

|
||||

|
||||
[](https://codecov.io/gh/googlemaps/js-markerclusterer)
|
||||

|
||||
[](https://github.com/semantic-release/semantic-release)
|
||||
[](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/)
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
## 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
|
||||
113
node_modules/@googlemaps/markerclusterer/dist/algorithms/core.d.ts
generated
vendored
Normal file
113
node_modules/@googlemaps/markerclusterer/dist/algorithms/core.d.ts
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 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[];
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/core.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/core.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {};
|
||||
46
node_modules/@googlemaps/markerclusterer/dist/algorithms/grid.d.ts
generated
vendored
Normal file
46
node_modules/@googlemaps/markerclusterer/dist/algorithms/grid.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/grid.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/grid.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {};
|
||||
21
node_modules/@googlemaps/markerclusterer/dist/algorithms/index.d.ts
generated
vendored
Normal file
21
node_modules/@googlemaps/markerclusterer/dist/algorithms/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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";
|
||||
25
node_modules/@googlemaps/markerclusterer/dist/algorithms/noop.d.ts
generated
vendored
Normal file
25
node_modules/@googlemaps/markerclusterer/dist/algorithms/noop.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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[];
|
||||
}
|
||||
43
node_modules/@googlemaps/markerclusterer/dist/algorithms/supercluster.d.ts
generated
vendored
Normal file
43
node_modules/@googlemaps/markerclusterer/dist/algorithms/supercluster.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/supercluster.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/supercluster.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {};
|
||||
43
node_modules/@googlemaps/markerclusterer/dist/algorithms/superviewport.d.ts
generated
vendored
Normal file
43
node_modules/@googlemaps/markerclusterer/dist/algorithms/superviewport.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/superviewport.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/superviewport.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {};
|
||||
56
node_modules/@googlemaps/markerclusterer/dist/algorithms/utils.d.ts
generated
vendored
Normal file
56
node_modules/@googlemaps/markerclusterer/dist/algorithms/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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 {};
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/utils.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/algorithms/utils.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {};
|
||||
41
node_modules/@googlemaps/markerclusterer/dist/cluster.d.ts
generated
vendored
Normal file
41
node_modules/@googlemaps/markerclusterer/dist/cluster.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/cluster.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/cluster.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {};
|
||||
20
node_modules/@googlemaps/markerclusterer/dist/index.d.ts
generated
vendored
Normal file
20
node_modules/@googlemaps/markerclusterer/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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";
|
||||
1830
node_modules/@googlemaps/markerclusterer/dist/index.dev.js
generated
vendored
Normal file
1830
node_modules/@googlemaps/markerclusterer/dist/index.dev.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
956
node_modules/@googlemaps/markerclusterer/dist/index.esm.js
generated
vendored
Normal file
956
node_modules/@googlemaps/markerclusterer/dist/index.esm.js
generated
vendored
Normal file
@@ -0,0 +1,956 @@
|
||||
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
|
||||
1
node_modules/@googlemaps/markerclusterer/dist/index.esm.js.map
generated
vendored
Normal file
1
node_modules/@googlemaps/markerclusterer/dist/index.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@googlemaps/markerclusterer/dist/index.min.js
generated
vendored
Normal file
2
node_modules/@googlemaps/markerclusterer/dist/index.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@googlemaps/markerclusterer/dist/index.min.js.map
generated
vendored
Normal file
1
node_modules/@googlemaps/markerclusterer/dist/index.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@googlemaps/markerclusterer/dist/index.umd.js
generated
vendored
Normal file
2
node_modules/@googlemaps/markerclusterer/dist/index.umd.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@googlemaps/markerclusterer/dist/index.umd.js.map
generated
vendored
Normal file
1
node_modules/@googlemaps/markerclusterer/dist/index.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
31
node_modules/@googlemaps/markerclusterer/dist/marker-utils.d.ts
generated
vendored
Normal file
31
node_modules/@googlemaps/markerclusterer/dist/marker-utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="google.maps" />
|
||||
/**
|
||||
* Supports markers of either either "legacy" or "advanced" types.
|
||||
*/
|
||||
export type Marker = google.maps.Marker | google.maps.marker.AdvancedMarkerElement;
|
||||
/**
|
||||
* util class that creates a common set of convenience functions to wrap
|
||||
* shared behavior of Advanced Markers and Markers.
|
||||
*/
|
||||
export declare class MarkerUtils {
|
||||
static isAdvancedMarkerAvailable(map: google.maps.Map): boolean;
|
||||
static isAdvancedMarker(marker: Marker): marker is google.maps.marker.AdvancedMarkerElement;
|
||||
static setMap(marker: Marker, map: google.maps.Map | null): void;
|
||||
static getPosition(marker: Marker): google.maps.LatLng;
|
||||
static getVisible(marker: Marker): boolean;
|
||||
}
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/marker-utils.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/marker-utils.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export {};
|
||||
77
node_modules/@googlemaps/markerclusterer/dist/markerclusterer.d.ts
generated
vendored
Normal file
77
node_modules/@googlemaps/markerclusterer/dist/markerclusterer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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 { Algorithm, AlgorithmOptions } from "./algorithms";
|
||||
import { Renderer } from "./renderer";
|
||||
import { Cluster } from "./cluster";
|
||||
import { OverlayViewSafe } from "./overlay-view-safe";
|
||||
import { Marker } from "./marker-utils";
|
||||
export type onClusterClickHandler = (event: google.maps.MapMouseEvent, cluster: Cluster, map: google.maps.Map) => void;
|
||||
export interface MarkerClustererOptions {
|
||||
markers?: Marker[];
|
||||
/**
|
||||
* An algorithm to cluster markers. Default is {@link SuperClusterAlgorithm}. Must
|
||||
* provide a `calculate` method accepting {@link AlgorithmInput} and returning
|
||||
* an array of {@link Cluster}.
|
||||
*/
|
||||
algorithm?: Algorithm;
|
||||
algorithmOptions?: AlgorithmOptions;
|
||||
map?: google.maps.Map | null;
|
||||
/**
|
||||
* An object that converts a {@link Cluster} into a `google.maps.Marker`.
|
||||
* Default is {@link DefaultRenderer}.
|
||||
*/
|
||||
renderer?: Renderer;
|
||||
onClusterClick?: onClusterClickHandler;
|
||||
}
|
||||
export declare enum MarkerClustererEvents {
|
||||
CLUSTERING_BEGIN = "clusteringbegin",
|
||||
CLUSTERING_END = "clusteringend",
|
||||
CLUSTER_CLICK = "click"
|
||||
}
|
||||
export declare const defaultOnClusterClickHandler: onClusterClickHandler;
|
||||
/**
|
||||
* MarkerClusterer creates and manages per-zoom-level clusters for large amounts
|
||||
* of markers. See {@link MarkerClustererOptions} for more details.
|
||||
*
|
||||
*/
|
||||
export declare class MarkerClusterer extends OverlayViewSafe {
|
||||
/** @see {@link MarkerClustererOptions.onClusterClick} */
|
||||
onClusterClick: onClusterClickHandler;
|
||||
/** @see {@link MarkerClustererOptions.algorithm} */
|
||||
protected algorithm: Algorithm;
|
||||
protected clusters: Cluster[];
|
||||
protected markers: Marker[];
|
||||
/** @see {@link MarkerClustererOptions.renderer} */
|
||||
protected renderer: Renderer;
|
||||
/** @see {@link MarkerClustererOptions.map} */
|
||||
protected map: google.maps.Map | null;
|
||||
protected idleListener: google.maps.MapsEventListener;
|
||||
constructor({ map, markers, algorithmOptions, algorithm, renderer, onClusterClick, }: MarkerClustererOptions);
|
||||
addMarker(marker: Marker, noDraw?: boolean): void;
|
||||
addMarkers(markers: Marker[], noDraw?: boolean): void;
|
||||
removeMarker(marker: Marker, noDraw?: boolean): boolean;
|
||||
removeMarkers(markers: Marker[], noDraw?: boolean): boolean;
|
||||
clearMarkers(noDraw?: boolean): void;
|
||||
/**
|
||||
* Recalculates and draws all the marker clusters.
|
||||
*/
|
||||
render(): void;
|
||||
onAdd(): void;
|
||||
onRemove(): void;
|
||||
protected reset(): void;
|
||||
protected renderClusters(): void;
|
||||
}
|
||||
16
node_modules/@googlemaps/markerclusterer/dist/markerclusterer.test.d.ts
generated
vendored
Normal file
16
node_modules/@googlemaps/markerclusterer/dist/markerclusterer.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {};
|
||||
24
node_modules/@googlemaps/markerclusterer/dist/overlay-view-safe.d.ts
generated
vendored
Normal file
24
node_modules/@googlemaps/markerclusterer/dist/overlay-view-safe.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="google.maps" />
|
||||
export interface OverlayViewSafe extends google.maps.OverlayView {
|
||||
}
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
export declare class OverlayViewSafe {
|
||||
constructor();
|
||||
}
|
||||
92
node_modules/@googlemaps/markerclusterer/dist/renderer.d.ts
generated
vendored
Normal file
92
node_modules/@googlemaps/markerclusterer/dist/renderer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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";
|
||||
/**
|
||||
* Provides statistics on all clusters in the current render cycle for use in {@link Renderer.render}.
|
||||
*/
|
||||
export declare class ClusterStats {
|
||||
readonly markers: {
|
||||
sum: number;
|
||||
};
|
||||
readonly clusters: {
|
||||
count: number;
|
||||
markers: {
|
||||
mean: number;
|
||||
sum: number;
|
||||
min: number;
|
||||
max: number;
|
||||
};
|
||||
};
|
||||
constructor(markers: Marker[], clusters: Cluster[]);
|
||||
}
|
||||
export interface Renderer {
|
||||
/**
|
||||
* Turn a {@link Cluster} into a `Marker`.
|
||||
*
|
||||
* Below is a simple example to create a marker with the number of markers in the cluster as a label.
|
||||
*
|
||||
* ```typescript
|
||||
* return new google.maps.Marker({
|
||||
* position,
|
||||
* label: String(markers.length),
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
render(cluster: Cluster, stats: ClusterStats, map: google.maps.Map): Marker;
|
||||
}
|
||||
export declare class DefaultRenderer implements Renderer {
|
||||
/**
|
||||
* 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 }: Cluster, stats: ClusterStats, map: google.maps.Map): Marker;
|
||||
}
|
||||
80
node_modules/@googlemaps/markerclusterer/package.json
generated
vendored
Normal file
80
node_modules/@googlemaps/markerclusterer/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "@googlemaps/markerclusterer",
|
||||
"version": "2.5.3",
|
||||
"description": "Creates and manages per-zoom-level clusters for large amounts of markers.",
|
||||
"keywords": [
|
||||
"cluster",
|
||||
"google",
|
||||
"maps",
|
||||
"marker"
|
||||
],
|
||||
"homepage": "https://github.com/googlemaps/js-markerclusterer",
|
||||
"bugs": {
|
||||
"url": "https://github.com/googlemaps/js-markerclusterer/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/googlemaps/js-markerclusterer.git"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"author": "Justin Poehnelt",
|
||||
"main": "dist/index.umd.js",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/*"
|
||||
],
|
||||
"scripts": {
|
||||
"docs": "typedoc src/index.ts && cp -r dist docs/dist && npm run examples && cp -r public docs/public",
|
||||
"examples": "rollup -c rollup.config.examples.js",
|
||||
"dev": "rollup -c rollup.config.examples.js --watch",
|
||||
"format": "eslint . --fix",
|
||||
"lint": "eslint .",
|
||||
"prepare": "rm -rf dist && rollup -c",
|
||||
"test": "jest --passWithNoTests src/*",
|
||||
"test:all": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"supercluster": "^8.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.11.5",
|
||||
"@babel/runtime-corejs3": "^7.11.2",
|
||||
"@googlemaps/jest-mocks": "^2.19.1",
|
||||
"@googlemaps/js-api-loader": "^1.12.3",
|
||||
"@rollup/plugin-babel": "^6.0.0",
|
||||
"@rollup/plugin-commonjs": "^25.0.0",
|
||||
"@rollup/plugin-html": "^1.0.0",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.0",
|
||||
"@rollup/plugin-typescript": "^11.0.0",
|
||||
"@types/d3-interpolate": "^3.0.1",
|
||||
"@types/google.maps": "^3.53.1",
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/supercluster": "^7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": ">=4.1.0",
|
||||
"@typescript-eslint/parser": ">=4.1.0",
|
||||
"core-js": "^3.6.5",
|
||||
"d3-interpolate": "^3.0.1",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-jest": "^27.6.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "^26.4.2",
|
||||
"prettier": "^2.1.1",
|
||||
"rollup": "^2.26.11",
|
||||
"rollup-plugin-copy": "^3.4.0",
|
||||
"rollup-plugin-serve": "^2.0.2",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"selenium-webdriver": "^4.0.0-alpha.7",
|
||||
"ts-jest": "^26.3.0",
|
||||
"typedoc": "^0.25.0",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://wombat-dressing-room.appspot.com"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user